#include <bits/stdc++.h>
using namespace std;
int t, sum;
int cnt[1111];
int main() {
  cin >> t;
  while (t--) {
    memset(cnt, 0, sizeof(cnt));
    sum = 0;
    string s;
    cin >> s;
    for (int i = 0; i <= s.size() - 1; i++) {
      cnt[s[i]]++;
      if (cnt[s[i]] <= 2) {
        sum++;
      }
    }
    cout << sum / 2 << "\n";
  }
}
