#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, x, y;
  string s;
  int c[255];
  cin >> t;
  while (t--) {
    memset(c, 0, sizeof(c));
    cin >> s;
    x = y = 0;
    for (int i = 0; i < s.size(); i++) {
      if (c[s[i]] == 0) {
        x++;
        c[s[i]]++;
      } else if (c[s[i]] == 1) {
        y++;
        c[s[i]]++;
      }
    }
    cout << (x + y) / 2 << endl;
  }
}
