#include <bits/stdc++.h>
using namespace std;
template <class c>
struct re {
  c b, e;
};
template <class c>
re<c> range(c i, c j) {
  return re<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
template <class A>
void read(vector<A>& v);
template <class A, size_t S>
void read(array<A, S>& a);
template <class A, class B>
void read(pair<A, B>& a);
template <class A>
void read(A& x) {
  cin >> x;
}
void read(double& d) {
  string t;
  read(t);
  d = stod(t);
}
void read(long double& d) {
  string t;
  read(t);
  d = stold(t);
}
template <class A, class... B>
void read(A& h, B&... t) {
  read(h);
  read(t...);
}
template <class A>
void read(vector<A>& a) {
  for (auto& x : a) read(x);
}
template <class A, size_t S>
void read(array<A, S>& a) {
  for (auto& x : a) read(x);
}
template <class A, class B>
void read(pair<A, B>& a) {
  A x;
  B y;
  read(x, y);
  a = {x, y};
}
void t_c() {
  string s;
  cin >> s;
  vector<int> h(26);
  for (auto x : s) h[x - 'a']++;
  int r = 0, alone = 0;
  for (int i = 0; i < 26; i++) {
    if (h[i] >= 2) r++;
    if (h[i] == 1) alone++;
  }
  cout << r + alone / 2 << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  for (int i = 1; i <= t; i++) {
    t_c();
  }
}
