#include <bits/stdc++.h>
using namespace std;
struct trip {
  long long a, b, c;
};
char opp(char ch) {
  if (ch == 'N') return 'S';
  if (ch == 'S') return 'N';
  if (ch == 'E') return 'W';
  if (ch == 'W') return 'E';
}
int main() {
  long long test;
  cin >> test;
  for (int t = 0; t < test; t++) {
    long long max_val = INT_MAX, min_val = -INT_MAX, ans = 0, count_it = 0,
              len = 0;
    bool flag = false;
    string direction;
    int n = 0, e = 0;
    cin >> direction;
    len = direction.size();
    map<pair<pair<long long, long long>, pair<long long, long long> >, int>
        maps;
    long long pren = 0, pree = 0;
    for (int i = 0; i < len; i++) {
      pren = n;
      pree = e;
      if (direction[i] == 'N')
        n++;
      else if (direction[i] == 'S')
        n--;
      else if (direction[i] == 'E')
        e++;
      else
        e--;
      if (maps[{{n, e}, {pren, pree}}] == 0 &&
          maps[{{pren, pree}, {n, e}}] == 0)
        ans += 5;
      else
        ans += 1;
      maps[{{n, e}, {pren, pree}}]++;
      maps[{{pren, pree}, {n, e}}]++;
    }
    cout << ans << "\n";
  }
  return 0;
}
