#include <bits/stdc++.h>
using namespace std;
long long GCD(long long a, long long b) { return b == 0 ? a : GCD(b, a % b); }
long long Power(long long a, long long b, long long p) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % p;
    a = a * a % p;
    b >>= 1;
  }
  return ans;
}
bool isprime(long long num) {
  if (num == 2 || num == 3) return true;
  if (num % 6 != 1 && num % 6 != 5) return false;
  long long t = sqrt((double)num);
  for (long long i = 5; i <= t; i += 6)
    if (num % i == 0 || num % (i + 2) == 0) return false;
  return true;
}
bool isRunyear(int year) {
  if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
    return true;
  } else {
    return false;
  }
}
string add(string s1, string s2) {
  if (s1.length() < s2.length()) {
    string temp = s1;
    s1 = s2;
    s2 = temp;
  }
  int i, j;
  for (i = s1.length() - 1, j = s2.length() - 1; i >= 0; i--, j--) {
    s1[i] = char(s1[i] + (j >= 0 ? s2[j] - '0' : 0));
    if (s1[i] - '0' >= 10) {
      s1[i] = char((s1[i] - '0') % 10 + '0');
      if (i)
        s1[i - 1]++;
      else
        s1 = '1' + s1;
    }
  }
  return s1;
}
long long n, m, i, j, k, t;
const long long INF = 1e5 + 10;
string s;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  while (cin >> k) {
    while (k--) {
      cin >> s;
      set<pair<pair<long long, long long>, pair<long long, long long>>> st;
      long long sum = 0, x = 0, y = 0;
      for (i = 0, j = s.length(); i < j; i++) {
        pair<long long, long long> p = {x, y};
        if (s[i] == 'S') x--;
        if (s[i] == 'N') x++;
        if (s[i] == 'W') y--;
        if (s[i] == 'E') y++;
        if (st.count({p, {x, y}}))
          sum++;
        else
          sum += 5;
        st.insert({p, {x, y}});
        st.insert({{x, y}, p});
      }
      cout << sum << endl;
    }
  }
}
