#include <bits/stdc++.h>
std::map<char, int> cunt_m, mark_m;
int main() {
  int t;
  std::cin >> t;
  while (t--) {
    cunt_m.clear();
    mark_m.clear();
    std::string s;
    std::cin >> s;
    for (int i = 0; i < s.size(); i++) {
      cunt_m[s[i]] = 0;
      mark_m[s[i]] = 0;
    }
    for (int i = 0; i < s.size(); i++) cunt_m[s[i]]++;
    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
      if (mark_m[s[i]] == 0 && cunt_m[s[i]] >= 2) {
        ans += 2;
        mark_m[s[i]] = 1;
      }
      if (mark_m[s[i]] == 0 && cunt_m[s[i]] < 2) {
        ans += cunt_m[s[i]];
        mark_m[s[i]] = 1;
      }
    }
    std::cout << ans / 2 << std::endl;
  }
}
