#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    set<pair<pair<int, int>, pair<int, int> > > ss;
    int ans = 0, x = 0, y = 0, xx, yy;
    for (int i = 0; i < s.size(); i++) {
      xx = x;
      yy = y;
      if (s[i] == 'N')
        y++;
      else if (s[i] == 'S')
        y--;
      else if (s[i] == 'W')
        x++;
      else if (s[i] == 'E')
        x--;
      ss.insert(make_pair(make_pair(xx, yy), make_pair(x, y)));
      if (ss.find({{x, y}, {xx, yy}}) != ss.end() &&
          ss.find({{xx, yy}, {x, y}}) != ss.end())
        ans += 1;
      else
        ans += 5;
      ss.insert(make_pair(make_pair(x, y), make_pair(xx, yy)));
    }
    cout << ans << endl;
  }
}
