#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s;
  cin >> s;
  long long cnt[26] = {};
  for (char i : s) cnt[i - 'a']++;
  for (long long i = 0; i < 26; i++) cnt[i] = min(2ll, cnt[i]);
  cout << accumulate(cnt, cnt + 26, 0ll) / 2 << endl;
}
signed main() {
  long long tc = 1;
  cin >> tc;
  while (tc--) solve();
}
