#include <bits/stdc++.h>
using namespace std;
void shikhar7s(long long int cas) {
  string s;
  cin >> s;
  long long int n = (long long int)s.length(), i, j, k, ans = 0, c;
  long long int a[n][26];
  for (i = 0; i < 26; i++) {
    a[n - 1][i] = 0;
  }
  for (i = n - 2; i >= 0; i--) {
    for (j = 0; j < 26; j++) {
      a[i][j] = a[i + 1][j];
      if (s[i + 1] - 'a' == j) a[i][j]++;
    }
  }
  for (j = 0; j < 26; j++) {
    c = a[i + 1][j];
    if (s[0] - 'a' == j) c++;
    ans = max(ans, c);
  }
  for (i = 0; i < 26; i++) {
    for (j = 0; j < 26; j++) {
      c = 0;
      for (k = 0; k < n; k++) {
        if (s[k] - 'a' == i) {
          c += a[k][j];
        }
      }
      ans = max(ans, c);
    }
  }
  cout << ans;
}
signed main() {
  std::ios_base::sync_with_stdio(false);
  long long int t = 1;
  long long int cas = 1;
  while (cas <= t) {
    shikhar7s(cas);
    cas++;
  }
  return 0;
}
