#include <bits/stdc++.h>
using namespace std;
int D[256];
int main() {
  string S, s = "12";
  cin >> S;
  int N = S.size(), i;
  long long L, R;
  char j;
  map<string, long long> M;
  D[S[0]] = 1;
  for (i = 1; i < N; ++i) {
    for (s[1] = S[i], j = 'a'; j <= 'z'; ++j) {
      s[0] = j;
      if (D[j]) M[s] += D[j];
    }
    D[S[i]]++;
  }
  for (i = 'a', j = 'b'; j <= 'z'; ++j)
    if (D[j] > D[i]) i = j;
  L = D[i];
  map<string, long long>::iterator X;
  for (X = M.begin(); X != M.end(); ++X) {
    if ((R = X->second) > L) L = R;
  }
  cout << L;
}
