#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, i = 0, j, cost = 0;
    string s;
    cin >> s;
    int x = 0, y = 0;
    n = s.length();
    set<pair<int, int>> st;
    for (i = 0; i < n; i++) {
      int edgex = x, edgey = y;
      if (s[i] == 'N')
        y++;
      else if (s[i] == 'S')
        y--;
      else if (s[i] == 'E')
        x++;
      else
        x--;
      if (st.find(make_pair(edgex + x, edgey + y)) == st.end()) {
        cost += 5;
        st.insert(make_pair(edgex + x, edgey + y));
      } else
        cost += 1;
    }
    cout << cost << endl;
  }
  return 0;
}
