#include <bits/stdc++.h>
using namespace std;
int x = 0, y = 0;
void solve(char c) {
  if (c == 'N') {
    y++;
  } else if (c == 'S') {
    y--;
  } else if (c == 'W') {
    x--;
  } else {
    x++;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int a, b;
  int t;
  cin >> t;
  while (t--) {
    string s;
    int ans = 0, a = 0, b = 0;
    cin >> s;
    int ls = s.length();
    map<pair<pair<int, int>, pair<int, int>>, bool> mp;
    for (int i = 0; i < ls; i++) {
      a = x, b = y;
      solve(s[i]);
      if (mp[{{a, b}, {x, y}}] || mp[{{x, y}, {a, b}}]) {
        ans++;
      } else {
        ans += 5;
      }
      mp[{{a, b}, {x, y}}] = 1;
    }
    cout << ans << '\n';
  }
  return 0;
}
