#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s;
  cin >> s;
  set<pair<pair<int, int>, pair<int, int> > > pt;
  int x = 0, y = 0, ans = 0;
  for (int i = 0; i < (int)s.size(); i++) {
    int x1 = x, y1 = y;
    if (s[i] == 'N')
      ++y1;
    else if (s[i] == 'E')
      ++x1;
    else if (s[i] == 'W')
      --x1;
    else
      --y1;
    if (pt.find({{x, y}, {x1, y1}}) == pt.end()) {
      pt.insert({{x, y}, {x1, y1}});
      pt.insert({{x1, y1}, {x, y}});
      ans += 5;
    } else
      ++ans;
    x = x1;
    y = y1;
  }
  cout << ans << endl;
  return;
}
int main() {
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
