#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    string ch;
    cin >> ch;
    long long int ans = 0;
    int x = 0, y = 0;
    set<pair<pair<int, int>, pair<int, int>>> s;
    pair<int, int> prev = {0, 0};
    for (int i = 0; i < (int)ch.size(); i++) {
      if (ch[i] == 'N')
        y++;
      else if (ch[i] == 'S')
        y--;
      else if (ch[i] == 'W')
        x--;
      else
        x++;
      bool check = false;
      if (s.count({prev, {x, y}}) || s.count({{x, y}, prev}))
        ans++;
      else {
        s.insert({prev, {x, y}});
        s.insert({{x, y}, prev});
        ans += 5;
      }
      prev = {x, y};
    }
    cout << ans << "\n";
  }
  return 0;
}
