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