#include <bits/stdc++.h>
using namespace std;
long long int dx[4] = {-1, 1, 0, 0};
long long int dy[4] = {0, 0, -1, 1};
int32_t main(void) {
  long long int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    map<pair<pair<long long int, long long int>,
             pair<long long int, long long int> >,
        long long int>
        mp;
    long long int ans = 0;
    long long int x1 = 0, y1 = 0;
    long long int x2 = 0, y2 = 0;
    for (long long int i = 0; i < s.size(); i++) {
      if (s[i] == 'N') y2++;
      if (s[i] == 'S') y2--;
      if (s[i] == 'E') x2++;
      if (s[i] == 'W') x2--;
      if (mp[{{x1, y1}, {x2, y2}}] || mp[{{x2, y2}, {x1, y1}}])
        ans += 1;
      else {
        ans += 5;
        mp[{{x1, y1}, {x2, y2}}] = 1;
        mp[{{x2, y2}, {x1, y1}}] = 1;
      }
      x1 = x2, y1 = y2;
    }
    cout << ans << "\n";
  }
  return 0;
}
