#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    set<pair<int, int>> s1;
    int x = 0, y = 0, ans = 0, c, d;
    for (int i = 0; i < s.size(); i++) {
      c = x;
      d = y;
      if (s[i] == 'N') y++;
      if (s[i] == 'S') y--;
      if (s[i] == 'W') x++;
      if (s[i] == 'E') x--;
      if (s1.find(make_pair(c + x, d + y)) == s1.end()) {
        ans += 5;
        s1.insert(make_pair(c + x, d + y));
      } else
        ans += 1;
    }
    std::cout << ans << std::endl;
  }
  return 0;
}
