#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
const long long INFLL = (long long)INF * (long long)INF;
const long double EPS = 10e-9;
const unsigned int M = 1000000007;
void solve() {
  string s;
  cin >> s;
  long long x = 0, y = 0;
  set<pair<pair<long long, long long>, pair<long long, long long>>> ash;
  long long ans = 0;
  for (long long i = 0; i < s.size(); i++) {
    long long xstart = x;
    long long ystart = y;
    if (s[i] == 'N')
      y++;
    else if (s[i] == 'E')
      x++;
    else if (s[i] == 'W')
      x--;
    else
      y--;
    if (ash.count({{xstart, ystart}, {x, y}}) == 1 ||
        ash.count({{x, y}, {xstart, ystart}}) == 1)
      ans++;
    else {
      ans += 5;
      ash.insert({{xstart, ystart}, {x, y}});
    }
  }
  cout << ans << endl;
}
int32_t main() {
  long long t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}
