#include <bits/stdc++.h>
using namespace std;
string st;
long long n, res, ar1[28], ar2[28][28];
int main() {
  cin >> st;
  n = st.size();
  st = " " + st;
  for (long long i = 1; i <= n; ++i) {
    long long c = st[i] - 96;
    for (long long j = 1; j <= 26; ++j) {
      ar2[j][c] += ar1[j];
    }
    ar1[c]++;
  }
  res = 0;
  for (int i = 1; i <= 26; ++i) {
    res = max(res, ar1[i]);
  }
  for (long long i = 1; i <= 26; ++i) {
    for (long long j = 1; j <= 26; ++j) {
      res = max(res, ar2[i][j]);
    }
  }
  cout << res;
  return 0;
}
