#include<bits/stdc++.h>
using namespace std;
using i64 = long long;
void solve() {
int n; cin >> n;
string s; cin >> s;
string x = "aeiou";
string v = x;
auto dist = [&](char a, char b) -> int {
int x = v.find(a), y = v.find(b);
int res = (y >= x ? y - x : 5 + y - x);
// cout << a << " " << b << '\n';
// cout << x << " " << y << '\n';
// cout << "res " << res << '\n';
return res;
};
int ans = n + 1;
do {
// cout << x << '\n';
vector<int> dp(5);
for (int i = 0; i < n; i++) {
for (int j = 4; j > 0; j--) {
dp[j] = min(dp[j] + dist(s[i], x[j]), (j - 1 >= 0 ? dp[j - 1] : 0) + dist(s[i], x[j]));
}
dp[0] += dist(s[i], x[0]);
// for (auto& a : dp) cout << a << " "; cout << '\n';
}
ans = min(ans, *min_element(dp.begin(), dp.end()));
// cout << "ans " << ans << '\n';
} while (next_permutation(x.begin(), x.end()));
cout << ans << '\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int tt = 1;
cin >> tt;
for(int t = 1; t <= tt; t++) {
solve();
}
}