#include <bits/stdc++.h>
using namespace std;
const long long int mod = 998244353;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int T = clock();
  string s;
  cin >> s;
  long long int ans = 0, n = s.size();
  map<char, long long int> mpp;
  for (long long int i = 0; i < n; i++) mpp[s[i]]++;
  for (auto p : mpp) ans = max(ans, p.second);
  for (long long int i = 0; i < 26; i++) {
    for (long long int j = 0; j < 26; j++) {
      char a = 'a' + i, b = 'a' + j;
      long long int tot = 0, as = 0;
      for (long long int k = 0; k < n; k++) {
        if (s[k] == b) tot += as;
        if (s[k] == a) as++;
      }
      ans = max(ans, tot);
    }
  }
  cout << ans;
  cerr << "\n\nTIME: " << (double)(clock() - T) / CLOCKS_PER_SEC << " sec\n";
  T = clock();
  return 0;
}
