#include <bits/stdc++.h>
using uint = unsigned int;
struct Pos {
  int x = 0, y = 0;
  bool operator<(Pos const &other) const {
    if (x - other.x == 0) {
      return y < other.y;
    } else {
      return x < other.x;
    }
  }
};
int time_ski(std::string const &str) {
  std::set<std::pair<Pos, Pos>> visited;
  Pos current;
  int time = 0;
  for (auto ch : str) {
    auto prev = current;
    switch (ch) {
      case 'N':
        current.y += 1;
        break;
      case 'S':
        current.y -= 1;
        break;
      case 'E':
        current.x += 1;
        break;
      case 'W':
        current.x -= 1;
        break;
      default:
        std::terminate();
    }
    if (visited.find({prev, current}) != visited.end() ||
        visited.find({current, prev}) != visited.end()) {
      time += 1;
    } else {
      time += 5;
      visited.insert({prev, current});
    }
  }
  return time;
}
int main() {
  std::string str;
  std::getline(std::cin, str);
  uint t;
  std::istringstream s{str};
  s >> t;
  for (uint i = 0; i < t; ++i) {
    std::getline(std::cin, str);
    std::cout << time_ski(str) << (i == t - 1 ? "" : "\n");
  }
  return 0;
}
