#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  string s;
  cin >> s;
  long long ans = 0;
  map<pair<char, char>, long long> b;
  map<char, long long> cnt;
  for (int i = (int)0; i < (int)(int)(s).size(); i++) {
    for (char c = 'a'; c <= 'z'; ++c) {
      b[{c, s[i]}] += cnt[c];
      ans = max(ans, b[{c, s[i]}]);
    }
    cnt[s[i]]++;
    ans = max(ans, cnt[s[i]]);
  }
  cout << ans;
  return 0;
}
