#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    int n = 0, e = 0;
    map<pair<pair<long long, long long>, pair<long long, long long>>, long long>
        mp;
    int mn = 0, ms = 0, mw = 0, me = 0;
    long long cost = 0;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == 'N') {
        n++;
        if (mp[{{n - 1, e}, {n, e}}] > 0)
          cost += 1;
        else {
          cost += 5;
          mp[{{n - 1, e}, {n, e}}] = 1;
          mp[{{n, e}, {n - 1, e}}] = 1;
        }
      } else if (s[i] == 'S') {
        n--;
        if (mp[{{n + 1, e}, {n, e}}] > 0)
          cost += 1;
        else {
          cost += 5;
          mp[{{n + 1, e}, {n, e}}] = 1;
          mp[{{n, e}, {n + 1, e}}] = 1;
        }
      } else if (s[i] == 'E') {
        e++;
        if (mp[{{n, e - 1}, {n, e}}] > 0)
          cost += 1;
        else {
          cost += 5;
          mp[{{n, e - 1}, {n, e}}] = 1;
          mp[{{n, e}, {n, e - 1}}] = 1;
        }
      } else {
        e--;
        if (mp[{{n, e + 1}, {n, e}}] > 0)
          cost += 1;
        else {
          cost += 5;
          mp[{{n, e + 1}, {n, e}}] = 1;
          mp[{{n, e}, {n, e + 1}}] = 1;
        }
      }
    }
    cout << cost << endl;
  }
  return 0;
}
