#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string ss;
    cin >> ss;
    int i, x = 0, y = 0, p = 0, q = 0, cnt = 0;
    set<pair<int, int> > s;
    for (i = 0; i < ss.length(); i++) {
      p = x, q = y;
      if (ss[i] == 'N')
        y++;
      else if (ss[i] == 'S')
        y--;
      else if (ss[i] == 'E')
        x++;
      else if (ss[i] == 'W')
        x--;
      if (!s.count({(x + p), (y + q)})) {
        cnt += 5;
        s.insert({(x + p), (y + q)});
      } else {
        cnt++;
      }
    }
    cout << cnt << endl;
  }
}
