#include <bits/stdc++.h>
int traveltime(std::string path) {
  using namespace std;
  int time = 0;
  set<pair<pair<int, int>, pair<int, int>>> travelled;
  pair<pair<int, int>, pair<int, int>> previous(make_pair(0, 0),
                                                make_pair(0, 0));
  for (auto cdir : path) {
    pair<pair<int, int>, pair<int, int>> direction;
    pair<int, int> destination;
    switch (cdir) {
      case 'N':
        destination =
            make_pair(previous.second.first, previous.second.second + 1);
        break;
      case 'S':
        destination =
            make_pair(previous.second.first, previous.second.second - 1);
        break;
      case 'E':
        destination =
            make_pair(previous.second.first + 1, previous.second.second);
        break;
      case 'W':
        destination =
            make_pair(previous.second.first - 1, previous.second.second);
        break;
    }
    direction = make_pair(previous.second, destination);
    auto reverse = make_pair(destination, previous.second);
    if (destination == previous.first ||
        travelled.find(direction) != travelled.end() ||
        travelled.find(reverse) != travelled.end()) {
      time += 1;
    } else {
      time += 5;
      travelled.insert(direction);
    }
    previous = direction;
  }
  return time;
}
int main() {
  int t;
  std::cin >> t;
  std::string path;
  getline(std::cin, path);
  for (int i = 0; i < t; i++) {
    getline(std::cin, path);
    std::cout << traveltime(path) << std::endl;
  }
  return 0;
}
