#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string S;
    cin >> S;
    set<pair<float, float>> set;
    set.insert(make_pair(0, 0));
    pair<float, float> curr;
    curr = make_pair(0, 0);
    int ans = 0;
    for (int i = 0; i < S.size(); i++) {
      if (S[i] == 'N') {
        curr.second += 0.5;
        if (set.find(curr) != set.end())
          ans += 1;
        else
          ans += 5;
        set.insert(curr);
        curr.second += 0.5;
      } else if (S[i] == 'S') {
        curr.second -= 0.5;
        if (set.find(curr) != set.end())
          ans += 1;
        else
          ans += 5;
        set.insert(curr);
        curr.second -= 0.5;
      } else if (S[i] == 'E') {
        curr.first += 0.5;
        if (set.find(curr) != set.end())
          ans += 1;
        else
          ans += 5;
        set.insert(curr);
        curr.first += 0.5;
      } else if (S[i] == 'W') {
        curr.first -= 0.5;
        if (set.find(curr) != set.end())
          ans += 1;
        else
          ans += 5;
        set.insert(curr);
        curr.first -= 0.5;
      }
    }
    cout << ans;
    cout << "\n";
  }
}
