#include <bits/stdc++.h>
#define int long long
#define endll '\n';
#define pb push_back
#define all(v) v.begin(), v.end()
using namespace std;
const int mod = 1e9 + 7, N = 1e6;
char ar[5] = {'a', 'e', 'i', 'o', 'u'};
string s;
int n;
map<char, int> mp;
int dp[100000 + 2][5][1 << 5 + 1];
int rec(int i, int ps, int mask)
{
if (i == n)
return 0;
if(dp[i][ps][mask] != -1) return dp[i][ps][mask];
int ans = 1e9;
char ch = ar[ps], nw = s[i];
int c = 0;
while (nw != ch)
{
nw = mp[nw];
c++;
}
ans = min(ans, rec(i + 1, ps, mask) + c);
for (int j = 0; j < 5; j++)
{
if (mask & (1 << j))
{
ans = min(ans, rec(i + 1, j, mask ^ (1 << j)) + c);
}
}
return dp[i][ps][mask] = ans;
}
void solve()
{
mp['a'] = 'e';
mp['e'] = 'i';
mp['i'] = 'o';
mp['o'] = 'u';
mp['u'] = 'a';
cin >> n;
cin >> s;
for(int i = 0; i <= n; i++) {
for(int j = 0; j < 5; j++) {
for(int k = 0; k <= (1 << 5); k++) {
dp[i][j][k] = -1;
}
}
}
int ans = 1e18;
for (int i = 0; i < 5; i++)
{
ans = min(ans, rec(0, i, ((1 << 5) - 1) ^ (1 << i)));
}
cout << ans << endll;
}
int32_t main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int t = 1;
cin >> t;
while (t--)
{
solve();
}
return 0;
}