#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    string s1;
    cin >> s1;
    int p1 = 0, p2 = 0, c1, c2;
    set<pair<pair<int, int>, pair<int, int> > > s;
    int c = 0;
    for (int i = 0; i < s1.size(); i++) {
      if (s1[i] == 'N') {
        c2 = p2 + 1;
        c1 = p1;
      } else if (s1[i] == 'S') {
        c2 = p2 - 1;
        c1 = p1;
      } else if (s1[i] == 'E') {
        c1 = p1 + 1;
        c2 = p2;
      } else if (s1[i] == 'W') {
        c1 = p1 - 1;
        c2 = p2;
      }
      if (s.find(make_pair(make_pair(c1, c2), make_pair(p1, p2))) != s.end() ||
          s.find(make_pair(make_pair(p1, p2), make_pair(c1, c2))) != s.end()) {
        c = c + 1;
      } else {
        c = c + 5;
        s.insert(make_pair(make_pair(p1, p2), make_pair(c1, c2)));
      }
      p1 = c1;
      p2 = c2;
    }
    cout << c << "\n";
  }
}
