#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
void solve() {
  set<pair<int, int>> s;
  int i = 0, j = 0;
  string st;
  cin >> st;
  int ans = 0;
  for (int k = 0; k < st.length(); k++) {
    int i2 = i;
    int j2 = j;
    char ch = st.at(k);
    if (ch == 'N') {
      i--;
    }
    if (ch == 'S') {
      i++;
    }
    if (ch == 'E') {
      j++;
    }
    if (ch == 'W') {
      j--;
    }
    int a = (i + i2) * 10 / 2;
    int b = (j + j2) * 10 / 2;
    if (s.find({a, b}) == s.end()) {
      ans += 5;
      s.insert({a, b});
    } else {
      ans += 1;
    }
  }
  cout << ans;
}
int main() {
  int t;
  cin >> t;
  while (t-- > 0) {
    solve();
    cout << endl;
  }
  return 0;
}
