func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long N = 1000000007;   void solve() {     string s;     cin >> s;     long long ans = INT_MAX;     for (long long i = 0; i <= 9; i++) {       long long count = 0;       for (long long j = 0; j < (long long)s.size(); j++) {         if (s[j] == (char)( 0  + i)) count++;       }       ans = min(ans, (long long)s.size() - count);     }     if (ans == 0) {       cout << 0 << endl;       return;     }     for (long long i = 0; i <= 9; i++) {       for (long long j = 0; j <= 9; j++) {         string temp;         if (i == j) continue;         temp += (char)( 0  + i);         temp += (char)( 0  + j);         long long count = 0;         long long n = (long long)s.size();         long long curr = 0;         for (long long k = 0; k < n; k++) {           if (s[k] == temp[curr]) {             if (curr == 1) {               count++;             }             curr = (curr + 1) % 2;           }         }         ans = min(ans, (long long)s.size() - 2 * count);       }     }     cout << ans << endl;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long t;     cin >> t;     while (t--) {       solve();     }     return 0;   }   