#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    set<pair<pair<long long, long long>, pair<long long, long long>>> s1;
    long long x = 0, y = 0, sum = 0, i;
    for (i = 0; s[i]; i++) {
      long long p = x;
      long long q = y;
      if (s[i] == 'N') {
        y++;
      } else if (s[i] == 'S') {
        y--;
      } else if (s[i] == 'E') {
        x++;
      } else if (s[i] == 'W') {
        x--;
      }
      if (!s1.count({{p, q}, {x, y}}) || !s1.count({{x, y}, {p, q}})) {
        sum = sum + 5;
        s1.insert({{p, q}, {x, y}});
        s1.insert({{x, y}, {p, q}});
      } else {
        sum = sum + 1;
      }
    }
    cout << sum << endl;
  }
}
