#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int64_t INF = 2e18;
const long long MAX = 2e9;
const long long N = 2e5 + 5;
const long long ep = 1e-9;
void io() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
long long row[4] = {1, -1, 0, 0};
long long col[4] = {0, 0, 1, -1};
void solve() {
  string s;
  cin >> s;
  vector<long long> arr(26, 0);
  for (auto x : s) {
    arr[x - 'a']++;
  }
  long long m1 = 0, m2 = 0;
  for (auto x : arr) {
    if (x >= 2)
      m1++;
    else
      m2 += x;
  }
  cout << m1 + m2 / 2;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) {
    solve();
    cout << "\n";
  }
  return 0;
}
