#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t, n, m, count, temp;
  cin >> t;
  while (t--) {
    string st;
    cin >> st;
    int x = 0, y = 0;
    long long int cost = 0;
    set<tuple<int, int, int, int>> s;
    for (int i = 0; i < st.length(); i++) {
      if (st[i] == 'N') {
        y += 1;
        if (s.find(make_tuple(x, y - 1, x, y)) != s.end()) {
          cost += 1;
        } else {
          s.insert(make_tuple(x, y - 1, x, y));
          s.insert(make_tuple(x, y, x, y - 1));
          cost += 5;
        }
      } else if (st[i] == 'S') {
        y -= 1;
        if (s.find(make_tuple(x, y + 1, x, y)) != s.end()) {
          cost += 1;
        } else {
          s.insert(make_tuple(x, y + 1, x, y));
          s.insert(make_tuple(x, y, x, y + 1));
          cost += 5;
        }
      } else if (st[i] == 'E') {
        x += 1;
        if (s.find(make_tuple(x - 1, y, x, y)) != s.end()) {
          cost += 1;
        } else {
          s.insert(make_tuple(x - 1, y, x, y));
          s.insert(make_tuple(x, y, x - 1, y));
          cost += 5;
        }
      } else if (st[i] == 'W') {
        x -= 1;
        if (s.find(make_tuple(x + 1, y, x, y)) != s.end()) {
          cost += 1;
        } else {
          s.insert(make_tuple(x + 1, y, x, y));
          s.insert(make_tuple(x, y, x + 1, y));
          cost += 5;
        }
      }
    }
    cout << cost << endl;
  }
}
