#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  long long int has[27] = {0};
  long long int ans = 0;
  for (int i = 0; i < str.length(); i++) {
    has[str[i] - 'a']++;
    ans = max(ans, has[str[i] - 'a']);
  }
  map<string, long long int> mp;
  for (int i = 0; i < str.length(); i++) {
    has[str[i] - 'a']--;
    for (int j = 0; j < 27; j++) {
      if (!has[j]) continue;
      string s = "";
      s = s + str[i] + (char)(j + 'a');
      mp[s] += has[j];
    }
  }
  map<string, long long int>::iterator it;
  for (it = mp.begin(); it != mp.end(); it++) {
    ans = max(ans, it->second);
  }
  printf("%lld\n", ans);
  return 0;
}
