#include <bits/stdc++.h>
using namespace std;
int main() {
  long long test;
  cin >> test;
  while (test--) {
    string s;
    cin >> s;
    int g = 0, r = 0;
    bool fg = true;
    int hash[26] = {0};
    for (int i = 0; i < s.length(); i++) {
      hash[int(s[i]) - 97]++;
    }
    for (int i = 0; i < 26; i++) {
      if (hash[i] > 1)
        g++;
      else if (hash[i] == 1)
        r++;
    }
    g += floor(r / 2);
    cout << g << endl;
  }
  return 0;
}
