#include <bits/stdc++.h>
int main() {
  char s[100001];
  scanf("%s", s);
  int n = strlen(s);
  long long int a[27][26] = {0};
  for (int i = 0; i < n; i++) {
    for (int o = 0; o < 26; o++) a[o][s[i] - 'a'] += a[26][o];
    a[26][s[i] - 'a']++;
  }
  long long int m = 0;
  for (int i = 0; i < 27; i++)
    for (int o = 0; o < 26; o++) {
      if (m < a[i][o]) m = a[i][o];
    }
  printf("%lld\n", m);
}
