#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  long long i, n = s.size(), ans = 0, j;
  vector<long long> a(26), b;
  for (i = 0; i < n; i++) {
    a[(int)s[i] - 'a']++;
    ans = max(ans, a[(int)s[i] - 'a']);
  }
  b = a;
  for (i = 0; i < 26; i++) {
    long long tmp = 0;
    long long mx[26] = {};
    b = a;
    for (int k = 0; k < n; k++) {
      b[(int)s[k] - 'a']--;
      if ((int)s[k] - 'a' == i) {
        for (j = 0; j < 26; j++) {
          mx[j] += b[j];
          tmp = max(tmp, mx[j]);
        }
      }
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}
