#include <bits/stdc++.h>
template <typename Tp>
void read(Tp &res) {
  static char ch;
  ch = getchar(), res = 0;
  static bool flag;
  flag = 0;
  while (ch < '0' || ch > '9') flag = (ch == '-'), ch = getchar();
  while (ch >= '0' && ch <= '9') res = res * 10 + ch - 48, ch = getchar();
  if (flag) res = -res;
}
void read(char *s) {
  static char ch;
  ch = getchar();
  while (ch < 'a' || ch > 'z') ch = getchar();
  while (ch >= 'a' && ch <= 'z') *(s++) = ch, ch = getchar();
  *s = '\0';
}
int n, cnt[26];
char s[int(1e5) + 19];
long long ans;
int main() {
  read(s + 1), n = strlen(s + 1);
  for (int i = 1; i <= n; ++i)
    ans = std::max(ans, (long long)++cnt[s[i] - 'a']);
  for (int x = 0; x < 26; ++x)
    for (int y = 0; y < 26; ++y) {
      int cy = 0;
      long long res = 0ll;
      for (int i = 1; i <= n; ++i) {
        if (s[i] == x + 'a') res += cy;
        if (s[i] == y + 'a') ++cy;
      }
      if (res > ans) ans = res;
    }
  printf("%lld\n", ans);
}
