#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
const long long MOD = 1e9 + 7;
int N, M, K, Q, T;
char str[MAXN];
vector<int> vec[26];
int main() {
  int i, j, n;
  scanf("%s", str);
  n = 0;
  while (str[n] != 0) ++n;
  for (i = 0; i < n; ++i) {
    vec[str[i] - 'a'].push_back(i);
  }
  long long maxi = 0ll;
  for (i = 0; i < 26; ++i) {
    maxi = max(maxi, (long long)vec[i].size());
  }
  for (i = 0; i < 26; ++i) {
    for (j = 0; j < 26; ++j) {
      long long sum = 0ll;
      for (int k = 0; k < vec[i].size(); ++k) {
        int x = vec[i][k];
        int y = upper_bound(vec[j].begin(), vec[j].end(), x) - vec[j].begin();
        sum += (long long)(vec[j].size() - y);
      }
      maxi = max(maxi, sum);
    }
  }
  printf("%lld\n", maxi);
}
