#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  string line;
  line.reserve(10000);
  set<pair<pair<int, int>, pair<int, int>>> routes;
  int fromX, fromY;
  int toX, toY;
  while (t-- > 0) {
    cin >> line;
    int score = 0;
    routes.clear();
    fromX = 0;
    fromY = 0;
    for (size_t i = 0; i < line.length(); ++i) {
      char ch = line.at(i);
      toX = fromX;
      toY = fromY;
      if (ch == 'N') {
        --toY;
      } else if (ch == 'S') {
        ++toY;
      } else if (ch == 'W') {
        --toX;
      } else {
        ++toX;
      }
      pair<int, int> pairFrom = make_pair(fromX, fromY);
      pair<int, int> pairTo = make_pair(toX, toY);
      pair<pair<int, int>, pair<int, int>> keyToFrom =
          make_pair(pairTo, pairFrom);
      auto iter = routes.find(keyToFrom);
      if (iter == routes.end()) {
        pair<pair<int, int>, pair<int, int>> keyFromTo =
            make_pair(pairFrom, pairTo);
        iter = routes.find(keyFromTo);
        if (iter == routes.end()) {
          score += 5;
          routes.insert(keyFromTo);
        } else {
          score += 1;
        }
      } else {
        score += 1;
      }
      fromX = toX;
      fromY = toY;
    }
    cout << score << endl;
  }
  return 0;
}
