#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  while (cin >> s) {
    map<char, int> mii;
    int n = s.length();
    for (int i = 0; i < n; i++) {
      mii[s[i]]++;
    }
    int ans = 1;
    int cnt = 1;
    for (auto it : mii) {
      ans = max(ans, it.second * cnt);
      cnt++;
    }
    cout << ans << endl;
  }
  return 0;
}
