#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    map<pair<int, pair<int, int> >, bool> v;
    int n = s.size();
    int i;
    int x = 0, y = 0;
    long long ans = 0;
    for (i = 0; i < n; i++) {
      if (s[i] == 'N') {
        if (v[{1, {x, y}}])
          ans++;
        else {
          ans += 5;
          v[{1, {x, y}}] = 1;
        }
        y++;
        v[{3, {x, y}}] = 1;
      }
      if (s[i] == 'E') {
        if (v[{2, {x, y}}])
          ans++;
        else {
          ans += 5;
          v[{2, {x, y}}] = 1;
        }
        x++;
        v[{4, {x, y}}] = 1;
      }
      if (s[i] == 'S') {
        if (v[{3, {x, y}}])
          ans++;
        else {
          ans += 5;
          v[{3, {x, y}}] = 1;
        }
        y--;
        v[{1, {x, y}}] = 1;
      }
      if (s[i] == 'W') {
        if (v[{4, {x, y}}])
          ans++;
        else {
          ans += 5;
          v[{4, {x, y}}] = 1;
        }
        x--;
        v[{2, {x, y}}] = 1;
      }
    }
    cout << ans << '\n';
  }
}
