#include <bits/stdc++.h>
using namespace std;
void solution() {
  string s;
  cin >> s;
  vector<int> cnt(26);
  for (char ch : s) {
    cnt[ch - 'a'] += 1;
  }
  int cnt1 = 0;
  int cnt2 = 0;
  for (int i = 0; i < 26; i++) {
    if (cnt[i] >= 2) {
      cnt2 += 1;
    } else if (cnt[i] == 1) {
      cnt1 += 1;
    }
  }
  cout << cnt2 + cnt1 / 2 << '\n';
}
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    solution();
  }
  return 0;
}
