#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    int x = 0, y = 0, m = 0;
    set<tuple<int, int, int> > e;
    for (char c : s) {
      int temp;
      int x2 = x, y2 = y;
      if (c == 'N') temp = 0, x2++;
      if (c == 'S') temp = 2, x2--;
      if (c == 'E') temp = 1, y2++;
      if (c == 'W') temp = 3, y2--;
      if (e.find({x, y, temp}) != e.end() ||
          e.find({x2, y2, (temp + 2) % 4}) != e.end())
        m++;
      else
        m += 5;
      e.insert({x, y, temp});
      x = x2, y = y2;
    }
    cout << m << "\n";
  }
}
