#include <bits/stdc++.h>
using namespace std;
void solve() {
  string str;
  map<pair<double, double>, bool> mp;
  double x = 0, y = 0;
  int ans = 0;
  cin >> str;
  for (int i = 0; i < str.length(); i++) {
    pair<double, double> pd;
    if (str[i] == 'N')
      pd = pair<double, double>(x, y + 0.5), y += 1.0;
    else if (str[i] == 'S')
      pd = pair<double, double>(x, y - 0.5), y -= 1.0;
    else if (str[i] == 'W')
      pd = pair<double, double>(x - 0.5, y), x -= 1.0;
    else
      pd = pair<double, double>(x + 0.5, y), x += 1.0;
    if (mp[pd])
      ans++;
    else {
      ans += 5;
      mp[pd] = true;
    }
  }
  cout << ans << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T;
  cin >> T;
  while (T--) solve();
  return 0;
}
