#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    map<pair<pair<long long int, long long int>,
             pair<long long int, long long int>>,
        bool>
        m;
    long long int x = 0, y = 0;
    long long int time = 0;
    for (long long int i = 0; i < s.size(); i++) {
      long long int tempx = x, tempy = y;
      if (s[i] == 'N') {
        y++;
      } else if (s[i] == 'E') {
        x++;
      } else if (s[i] == 'W') {
        x--;
      } else {
        y--;
      }
      if (m[make_pair(make_pair(x, y), make_pair(tempx, tempy))]) {
        time++;
      } else if (m[make_pair(make_pair(tempx, tempy), make_pair(x, y))]) {
        time++;
      } else {
        time += 5;
      }
      m[make_pair(make_pair(x, y), make_pair(tempx, tempy))] = true;
      m[make_pair(make_pair(tempx, tempy), make_pair(x, y))] = true;
    }
    cout << time;
    cout << endl;
  }
  return 0;
}
