#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    map<pair<pair<int, int>, pair<int, int> >, bool> mp;
    int x = 0, y = 0;
    int ans = 0;
    for (int i = 0; i < s.length(); i++) {
      int cpx = x, cpy = y;
      if (s[i] == 'N') y++;
      if (s[i] == 'S') y--;
      if (s[i] == 'W') x--;
      if (s[i] == 'E') x++;
      if (mp[{{cpx, cpy}, {x, y}}] == 1)
        ans++;
      else
        ans += 5;
      mp[{{cpx, cpy}, {x, y}}] = 1;
      mp[{{x, y}, {cpx, cpy}}] = 1;
    }
    cout << ans << '\n';
  }
  return 0;
}
