#include <bits/stdc++.h>
using namespace std;
int main() {
  int test = 1, c;
  cin >> test;
  for (c = 0; c < test; c++) {
    string s;
    cin >> s;
    int b, d;
    map<pair<pair<int, int>, pair<int, int>>, int> m;
    int x = 0, y = 0;
    long long int ans = 0;
    for (b = 0; b < s.length(); b++) {
      if (s[b] == 'N') {
        if (m[{{x, y}, {x, y + 1}}]) {
          ans++;
        } else {
          ans += 5;
          m[{{x, y}, {x, y + 1}}] = 1;
          m[{{x, y + 1}, {x, y}}] = 1;
        }
        y++;
      }
      if (s[b] == 'S') {
        if (m[{{x, y}, {x, y - 1}}]) {
          ans++;
        } else {
          ans += 5;
          m[{{x, y}, {x, y - 1}}] = 1;
          m[{{x, y - 1}, {x, y}}] = 1;
        }
        y--;
      }
      if (s[b] == 'E') {
        if (m[{{x, y}, {x + 1, y}}]) {
          ans++;
        } else {
          ans += 5;
          m[{{x, y}, {x + 1, y}}] = 1;
          m[{{x + 1, y}, {x, y}}] = 1;
        }
        x++;
      }
      if (s[b] == 'W') {
        if (m[{{x, y}, {x - 1, y}}]) {
          ans++;
        } else {
          ans += 5;
          m[{{x, y}, {x - 1, y}}] = 1;
          m[{{x - 1, y}, {x, y}}] = 1;
        }
        x--;
      }
    }
    cout << ans << endl;
  }
}
