#include <bits/stdc++.h>
using namespace std;
signed main(void) {
  string s;
  int n;
  long long cnt;
  map<char, long long> mp;
  cin >> s;
  cnt = 1000000000000000000;
  n = s.size();
  for (int i = 0; i < (n); i++) {
    mp[s[i]]++;
  }
  for (auto p : mp) {
    cnt = min(cnt, p.second);
  }
  cout << (long long)cnt * 2 << endl;
  return 0;
}
