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