#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 10;
int arr[MAX];
int n;
string s;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  set<array<int, 4> > vis;
  pair<int, int> p;
  for (int tc = 1; tc <= t; ++tc) {
    vis.clear();
    cin >> s;
    array<int, 4> a;
    int ans = 0;
    int x = 0, y = 0;
    for (int i = 0; i < s.size(); ++i) {
      a[0] = x;
      a[1] = y;
      if (s[i] == 'N') y++;
      if (s[i] == 'S') y--;
      if (s[i] == 'E') x++;
      if (s[i] == 'W') x--;
      a[2] = x;
      a[3] = y;
      if (vis.count(a))
        ans++;
      else
        ans += 5;
      vis.insert(a);
      swap(a[0], a[2]);
      swap(a[1], a[3]);
      vis.insert(a);
    }
    cout << ans << "\n";
  }
  return 0;
}
