#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int x = 0, y = 0, a, b, i, j;
    map<pair<pair<int, int>, pair<int, int> >, int> mp;
    string s;
    cin >> s;
    int co = 0;
    for (i = 0; i < s.size(); i++) {
      int a = x, b = y;
      char c = s[i];
      if (c == 'N') y++;
      if (c == 'S') y--;
      if (c == 'E') x++;
      if (c == 'W') x--;
      pair<int, int> p, k;
      p.first = x, p.second = y;
      k.first = a;
      k.second = b;
      pair<pair<int, int>, pair<int, int> > o, h;
      h.first = p;
      h.second = k;
      o.first = k;
      o.second = p;
      if (mp[h] || mp[o])
        co++;
      else
        co += 5;
      mp[h]++;
      mp[o]++;
    }
    cout << co << endl;
  }
}
