#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
void solve() {
int n,mx=0;
string s; cin>>n>>s;
vector<int>freq1(26);
vector<int>freq2(26);
for(char it:s)
freq1[it-'a']++;
for(char it:s){
freq2[it-'a']++;
freq1[it-'a']--;
int c1=0,c2=0;
for(int i=0;i<26;i++){
if(freq1[i]) c1++;
if(freq2[i]) c2++;
}
mx=max(mx,c1+c2);
}
cout<<mx<<endl;
}
int main() {
IOS;
int t=1;
cin >> t;
while(t--)solve();
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgSU9TIGlvczo6c3luY193aXRoX3N0ZGlvKDApOyBjaW4udGllKDApOyBjb3V0LnRpZSgwKTsKCnZvaWQgc29sdmUoKSB7CiAgICBpbnQgbixteD0wOwogICAgc3RyaW5nIHM7IGNpbj4+bj4+czsKICAgIHZlY3RvcjxpbnQ+ZnJlcTEoMjYpOwogICAgdmVjdG9yPGludD5mcmVxMigyNik7CiAgICBmb3IoY2hhciBpdDpzKQogICAgICAgIGZyZXExW2l0LSdhJ10rKzsKICAgIGZvcihjaGFyIGl0OnMpewogICAgICAgIGZyZXEyW2l0LSdhJ10rKzsKICAgICAgICBmcmVxMVtpdC0nYSddLS07CiAgICAgICAgaW50IGMxPTAsYzI9MDsKICAgICAgICBmb3IoaW50IGk9MDtpPDI2O2krKyl7CiAgICAgICAgICAgIGlmKGZyZXExW2ldKSBjMSsrOwogICAgICAgICAgICBpZihmcmVxMltpXSkgYzIrKzsKICAgICAgICB9CiAgICAgICAgbXg9bWF4KG14LGMxK2MyKTsKICAgIH0KICAgIGNvdXQ8PG14PDxlbmRsOwp9CgppbnQgbWFpbigpIHsKICAgIElPUzsKICAgIGludCB0PTE7CiAgICBjaW4gPj4gdDsKICAgIHdoaWxlKHQtLSlzb2x2ZSgpOwp9