//第三题AC代码
//求第四题代码
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
char s[maxn];
int dp[maxn][3];
int main()
{
	int T;
	cin>>T;
	while(T--){
		cin>>s;
		memset(dp,0,sizeof dp);
		if(s[0]=='N')dp[0][0]=1;
		dp[0][1]=1;
		dp[0][2]=1;
		int ans=1;
		for(int i=1;i<strlen(s);i++){
			if(s[i]=='N'){
				dp[i][0]=dp[i-1][0]+1;
				dp[i][1]=dp[i-1][1]+1;
				dp[i][2]=dp[i-1][2]+1;
			}
			else{
				dp[i][0]=0;
				dp[i][1]=dp[i-1][0]+1;
				dp[i][2]=dp[i-1][1]+1;
			}
			ans=max(ans,dp[i][2]);
		}
		cout<<ans<<endl;
	}
	return 0;
}