#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s;
  cin >> s;
  long long int ans = 0;
  long long int x, y;
  x = y = 0;
  set<pair<pair<long long int, long long int>,
           pair<long long int, long long int> > >
      second;
  for (long long int i = 0; i < s.size(); i++) {
    if (s[i] == 'S') {
      if (second.find({{x, y}, {x, y - 1}}) != second.end() ||
          second.find({{x, y - 1}, {x, y}}) != second.end()) {
        ans++;
      } else
        ans += 5;
      second.insert({{x, y}, {x, y - 1}});
      y--;
    } else if (s[i] == 'N') {
      if (second.find({{x, y}, {x, y + 1}}) != second.end() ||
          second.find({{x, y + 1}, {x, y}}) != second.end()) {
        ans++;
      } else
        ans += 5;
      second.insert({{x, y}, {x, y + 1}});
      y++;
    } else if (s[i] == 'E') {
      if (second.find({{x, y}, {x + 1, y}}) != second.end() ||
          second.find({{x + 1, y}, {x, y}}) != second.end()) {
        ans++;
      } else
        ans += 5;
      second.insert({{x, y}, {x + 1, y}});
      x++;
    } else {
      if (second.find({{x, y}, {x - 1, y}}) != second.end() ||
          second.find({{x - 1, y}, {x, y}}) != second.end()) {
        ans++;
      } else
        ans += 5;
      second.insert({{x, y}, {x - 1, y}});
      x--;
    }
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
