#include<bits/stdc++.h>
using namespace std;
#define nl '\n'
#define ll long long
// #define int long long
#define pii pair<int, int>
const int N = 1e5+5;
const int inf = 2e9;
int n;
string s, t = "aeiouaeiou";
int chk(char x, char c){
int ret = 0, id = 0;
while(t[id]!= x) id++;
while(t[id]!= c) id++, ret++;
return ret;
}
int dp[N][5][(1<<5)];
int go(int pos, int c, int mask){
if(pos == n) return 0;
if(__builtin_popcount(mask) == 5) return inf;
int &ret = dp[pos][c][mask];
if(~ret) return ret;
int ans = inf;
ans = min(ans, chk(s[pos], t[c]) + go(pos+1, c, mask));
for(int i=0;i<5;++i){
if(mask&(1<<i)) continue;
ans = min(ans, chk(s[pos], t[i]) + go(pos+1, i, mask|(1<<c)));
}
return ret = ans;
}
void solve(){
cin >> n >> s;
int ans = inf;
for(int i=0;i<=n;++i){
memset(dp[i], -1, sizeof dp[i]);
}
for(int i=0;i<5;++i){
ans = min(ans, (go(0,i,0)==-1?inf:go(0,i,0)));
//
}
cout << ans << nl;
}
int32_t main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1, tc = 0;
cin >> t ;
while(t--){
// cout << "Case " << ++tc << ": ";
solve();
}
return 0;
}