#include <bits/stdc++.h>
using namespace std;
long long n, m;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int TC;
  cin >> TC;
  while (TC--) {
    map<char, int> mp;
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
      if (mp[s[i]] <= 1) mp[s[i]]++;
    }
    int x1 = 0, x2 = 0;
    for (auto i : mp) {
      if (i.second == 2) x2++;
      if (i.second == 1) x1++;
    }
    long long ans = (x1 / 2) + x2;
    cout << ans << '\n';
  }
}
