#include <bits/stdc++.h>
using namespace std;
bool myComparison(const pair<int, int> &a, const pair<int, int> &b) {
  return a.second > b.second;
};
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, ans = 0;
    string s;
    cin >> s;
    n = s.length();
    int l = -1, r = n;
    map<pair<int, int>, set<char> > vis;
    pair<int, int> cur = {0, 0};
    for (int i = 0; i < n; ++i) {
      if (s[i] == 'W' || s[i] == 'E')
        vis[cur].insert('W' + 'E' - s[i]);
      else
        vis[cur].insert('N' + 'S' - s[i]);
      if (s[i] == 'S') --cur.first;
      if (s[i] == 'N') ++cur.first;
      if (s[i] == 'E') ++cur.second;
      if (s[i] == 'W') --cur.second;
      if (vis.count(cur)) {
        if ((vis[cur].find(s[i]) != vis[cur].end()))
          ans++;
        else
          ans += 5;
      } else
        ans += 5;
      vis[cur].insert(s[i]);
    }
    { cout << ans << endl; }
  }
  return 0;
}
