#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  cin >> T;
  while (T > 0) {
    string s;
    cin >> s;
    int sum = 0, c = 0;
    int n = s.length();
    int x = 0, y = 0, x1, y1;
    map<pair<pair<int, int>, pair<int, int>>, int> m;
    m[{{x, y}, {x, y}}] = 1;
    for (int i = 0; i < n; i++) {
      x1 = x;
      y1 = y;
      if (s[i] == 'N') y++;
      if (s[i] == 'S') y--;
      if (s[i] == 'E') x++;
      if (s[i] == 'W') x--;
      if (m[{{x, y}, {x1, y1}}] == 1 || m[{{x1, y1}, {x, y}}] == 1)
        sum++;
      else {
        sum += 5;
        m[{{x, y}, {x1, y1}}] = 1;
        m[{{x1, y1}, {x, y}}] = 1;
      }
    }
    cout << sum << endl;
    T--;
  }
  return 0;
}
