#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream& operator<<(ostream& Stream, const vector<T>& Vec) {
  for (const T& i : Vec) Stream << i << " ";
  return Stream;
}
template <typename A, typename B>
ostream& operator<<(ostream& Stream, const pair<A, B>& Pair) {
  return Stream << Pair.first << ' ' << Pair.second;
}
template <typename A, typename B, typename C>
ostream& operator<<(ostream& Stream, const tuple<A, B, C>& T) {
  return Stream << get<0>(T) << ' ' << get<1>(T) << ' ' << get<2>(T);
}
void solve() {
  string s;
  cin >> s;
  long long n = s.size(), ans = 0, x = 0, y = 0;
  map<pair<pair<int, int>, pair<int, int>>, bool> S;
  for (int i = 0; i < n; ++i) {
    pair<int, int> pp1 = {x, y};
    if (s[i] == 'N')
      ++y;
    else if (s[i] == 'S')
      --y;
    else if (s[i] == 'E')
      ++x;
    else if (s[i] == 'W')
      --x;
    pair<int, int> pp2 = {x, y};
    if (!S[{pp1, pp2}])
      ans += 5;
    else
      ++ans;
    S[{pp1, pp2}] = true;
    S[{pp2, pp1}] = true;
  }
  cout << ans << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout.precision(10);
  cout << fixed;
  int t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}
