#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    set<string> st;
    st.insert("" + s[0]);
    int n = s.length();
    string temp = "";
    for (int i = 1; i < n; i++) {
      temp += s[i];
      if (st.find(temp) == st.end()) {
        st.insert(temp);
        temp = "";
      }
    }
    reverse(s.begin(), s.end());
    set<string> st2;
    st2.insert("" + s[0]);
    temp = "";
    for (int i = 1; i < n; i++) {
      temp += s[i];
      if (st2.find(temp) == st2.end()) {
        st.insert(temp);
        temp = "";
      }
    }
    cout << max(st.size(), st2.size()) << endl;
  }
  return 0;
}
