#include <bits/stdc++.h>
using namespace std;
string toStr(pair<int, int> a, pair<int, int> b) {
  return to_string(a.first) + " " + to_string(a.second) + " " +
         to_string(b.first) + " " + to_string(b.second);
}
void solve() {
  string str;
  cin >> str;
  long long t = 0;
  unordered_set<string> s;
  pair<int, int> current = {0, 0}, prev;
  for (char c : str) {
    prev = current;
    switch (c) {
      case 'N':
        current.second++;
        break;
      case 'S':
        current.second--;
        break;
      case 'W':
        current.first--;
        break;
      case 'E':
        current.first++;
        break;
    }
    string path = toStr(prev, current);
    if (s.count(path) > 0) {
      t++;
    } else {
      t += 5;
      s.insert(path);
      s.insert(toStr(current, prev));
    }
  }
  cout << t << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
