#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    set<pair<pair<long long, long long>, pair<long long, long long> > > rem;
    long long xi = 0, yi = 0, xf = 0, yf = 0;
    string s;
    cin >> s;
    long long ans = 0;
    for (long long i = 0; i < (long long)(s.length()); ++i) {
      if (s[i] == 'N') {
        yf++;
      } else if (s[i] == 'S') {
        yf--;
      } else if (s[i] == 'E') {
        xf++;
      } else {
        xf--;
      }
      if (rem.count({{xi, yi}, {xf, yf}})) {
        ans += 1;
      } else {
        ans += 5;
        rem.insert({{xi, yi}, {xf, yf}});
        rem.insert({{xf, yf}, {xi, yi}});
      }
      xi = xf;
      yi = yf;
    }
    cout << ans << endl;
  }
  return 0;
}
