#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t, x, y, ans, prevx, prevy;
  string s;
  cin >> t;
  while (t--) {
    cin >> s;
    x = 0;
    y = 0;
    prevx = 0;
    prevy = 0;
    ans = 0;
    set<pair<pair<int, int>, pair<int, int> > > st;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == 'N')
        y += 1;
      else if (s[i] == 'S')
        y -= 1;
      if (s[i] == 'E')
        x += 1;
      else if (s[i] == 'W')
        x -= 1;
      pair<int, int> e1(x, y);
      pair<int, int> e2(prevx, prevy);
      pair<pair<int, int>, pair<int, int> > e3(e1, e2);
      if (st.find(e3) == st.end()) {
        ans += 5;
        st.insert(e3);
        st.insert(pair<pair<int, int>, pair<int, int> >(e2, e1));
        prevx = x;
        prevy = y;
      } else {
        ans += 1;
        prevx = x;
        prevy = y;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
