#include <bits/stdc++.h>
using namespace std;
vector<bool> isPrime(1000000, true);
long long Ceil(long long x, long long y) { return x / y + (x % y != 0); }
long long dx[4] = {0, 1, 0, -1};
long long dy[4] = {1, 0, -1, 0};
long long mod_exp(long long a, long long b, long long c) {
  if (b == 0) {
    return 1;
  }
  if (b & 1) {
    long long ans = mod_exp(a, b - 1, c);
    return (ans * a) % 1000000007;
  } else {
    long long ans = mod_exp(a, b / 2, c);
    return (ans * ans) % 1000000007;
  }
}
void sieve() {
  isPrime[0] = false;
  isPrime[1] = false;
  for (long long i = 2; i <= sqrt(1000000); i++) {
    if (isPrime[i]) {
      for (long long j = i * 2; j <= 1000000; j += i) {
        isPrime[j] = false;
      }
    }
  }
}
bool isInside(long long x, long long y, long long n, long long m) {
  if (x >= 0 && x < n && y >= 0 && y < m) {
    return true;
  } else {
    return false;
  }
}
void dfs(vector<string>& graph, vector<vector<bool>>& vis, long long i,
         long long j, long long n, long long m) {
  vis[i][j] = true;
  for (long long d = 0; d < 4; d++) {
    long long x = i + dx[d];
    long long y = j + dy[d];
    if (isInside(x, y, n, m) && !vis[x][y] && graph[x][y] == '.') {
      dfs(graph, vis, x, y, n, m);
    }
  }
}
bool sortbysec(pair<long long, long long> a, pair<long long, long long> b) {
  return a.second < b.second;
}
void solve() {
  string s;
  cin >> s;
  set<pair<pair<long long, long long>, pair<long long, long long>>> sett;
  long long x = 0, y = 0, xx = 0, yy = 0;
  long long ans = 0;
  for (long long i = 0; i < s.size(); i++) {
    if (s[i] == 'N') yy++;
    if (s[i] == 'S') yy--;
    if (s[i] == 'E') xx++;
    if (s[i] == 'W') xx--;
    if (sett.find({{xx, yy}, {x, y}}) == sett.end()) {
      ans += 5;
      sett.insert({{xx, yy}, {x, y}});
      sett.insert({{x, y}, {xx, yy}});
    } else {
      ans += 1;
    }
    x = xx;
    y = yy;
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
