#include <bits/stdc++.h>
using namespace std;
using u64 = uint64_t;
void solve() {
  string s;
  cin >> s;
  int x = 0, y = 0;
  long long ans = 0;
  map<pair<pair<int, int>, pair<int, int>>, int> m;
  for (int i = 0; i < s.length(); i++) {
    int a = x, b = y;
    if (s[i] == 'W')
      x--;
    else if (s[i] == 'E')
      x++;
    else if (s[i] == 'N')
      y++;
    else
      y--;
    if (m[{{x, y}, {a, b}}] || m[{{a, b}, {x, y}}])
      ans++;
    else
      ans += 5;
    m[{{x, y}, {a, b}}] = 1;
    m[{{a, b}, {x, y}}] = 1;
  }
  cout << ans << "\n";
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1LL;
  cin >> t;
  while (t--) {
    solve();
  }
}
