#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 s;
    cin >> s;
    map<pair<pair<long long, long long>, pair<long long, long long> >, int> mp;
    int x = 0, y = 0;
    int c = 0;
    for (long long i = 0; i < s.size(); i++) {
      int a, b;
      a = x;
      b = y;
      if (s[i] == 'N')
        y++;
      else if (s[i] == 'S')
        y--;
      else if (s[i] == 'E')
        x++;
      else
        x--;
      pair<long long, long long> p1 = make_pair(a, b);
      pair<long long, long long> p2 = make_pair(x, y);
      pair<pair<long long, long long>, pair<long long, long long> > p3 =
          make_pair(p1, p2);
      pair<pair<long long, long long>, pair<long long, long long> > p4 =
          make_pair(p2, p1);
      if (mp[p3] > 0)
        c++;
      else {
        c += 5;
        mp[p3]++;
        mp[p4]++;
      }
    }
    cout << c << endl;
  }
}
