#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 100001;
const int M = 20;
const int MOD = 1000000007;
const int inf = 1234567890;
const long long INF = 1122334455667788990;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  int tc = 1, cs = 0;
  cin >> tc;
  while (tc--) {
    string s;
    cin >> s;
    vector<int> cnt(26);
    for (auto i : s) cnt[i - 'a']++;
    int tot = 0;
    for (auto i : cnt) tot += min(i, 2);
    cout << tot / 2 << '\n';
  }
}
