#include <iostream>
#include <unordered_set>
#include <string>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
string s;
cin >> s;
unordered_set
<char
> all_chars
(s
.begin
(), s
.end()); unordered_set<char> left_chars;
int max_f = 0;
for (int i = 0; i < n - 1; ++i) {
left_chars.insert(s[i]);
all_chars.erase(s[i]);
max_f
= max(max_f
, (int
)left_chars
.size
() + (int
)all_chars
.size
()); }
cout << max_f << "\n";
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dW5vcmRlcmVkX3NldD4KI2luY2x1ZGUgPHN0cmluZz4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkgewogICAgaW9zOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpOwogICAgY2luLnRpZShudWxscHRyKTsKCiAgICBpbnQgdDsKICAgIGNpbiA+PiB0OwoKICAgIHdoaWxlICh0LS0pIHsKICAgICAgICBpbnQgbjsKICAgICAgICBjaW4gPj4gbjsKICAgICAgICBzdHJpbmcgczsKICAgICAgICBjaW4gPj4gczsKCiAgICAgICAgdW5vcmRlcmVkX3NldDxjaGFyPiBhbGxfY2hhcnMocy5iZWdpbigpLCBzLmVuZCgpKTsKICAgICAgICB1bm9yZGVyZWRfc2V0PGNoYXI+IGxlZnRfY2hhcnM7CiAgICAgICAgaW50IG1heF9mID0gMDsKCiAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuIC0gMTsgKytpKSB7CiAgICAgICAgICAgIGxlZnRfY2hhcnMuaW5zZXJ0KHNbaV0pOwogICAgICAgICAgICBhbGxfY2hhcnMuZXJhc2Uoc1tpXSk7CiAgICAgICAgICAgIG1heF9mID0gbWF4KG1heF9mLCAoaW50KWxlZnRfY2hhcnMuc2l6ZSgpICsgKGludClhbGxfY2hhcnMuc2l6ZSgpKTsKICAgICAgICB9CgogICAgICAgIGNvdXQgPDwgbWF4X2YgPDwgIlxuIjsKICAgIH0KCiAgICByZXR1cm4gMDsKfQ==