#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  string s;
  cin >> t;
  for (int i = 0; i != t; i++) {
    int x = 0, y = 0, x1 = 0, y1 = 0, time = 0;
    set<pair<pair<int, int>, pair<int, int> > > path;
    cin >> s;
    for (int j = 0; j != s.length(); j++) {
      if (s[j] == 'N') {
        y1++;
      }
      if (s[j] == 'S') {
        y1--;
      }
      if (s[j] == 'W') {
        x1--;
      }
      if (s[j] == 'E') {
        x1++;
      }
      if (path.find({{x, y}, {x1, y1}}) == path.end()) {
        time += 5;
        path.insert({{x, y}, {x1, y1}});
        path.insert({{x1, y1}, {x, y}});
      } else {
        time++;
      }
      x = x1;
      y = y1;
    }
    cout << time << endl;
  }
  return 0;
}
