#include <bits/stdc++.h>
using namespace std;
int t;
string s;
set<pair<pair<int, int>, pair<int, int> > > st;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> t;
  while (t--) {
    st.clear();
    cin >> s;
    int n = s.length();
    int ans = 0, l = 0, r = 0;
    for (int i = 0; i < n; i++) {
      pair<int, int> p(l, r);
      if (s[i] == 'E')
        r++;
      else if (s[i] == 'S')
        l--;
      else if (s[i] == 'W')
        r--;
      else if (s[i] == 'N')
        l++;
      if (st.find(make_pair(p, make_pair(l, r))) != st.end())
        ans++;
      else
        ans += 5;
      st.insert(make_pair(p, make_pair(l, r)));
      st.insert(make_pair(make_pair(l, r), p));
    }
    cout << ans << endl;
  }
  return 0;
}
