#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const long long LINF = (long long)1e18;
const long double PI = acos((long double)-1);
const long double EPS = 1e-9;
const int N = (int)1e5 + 10;
void TimeExecution() {
  cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int t;
string s;
long long cnt[26];
map<string, long long> f;
long long cal(long long a) { return (a * (a - 1)) / 2; }
int main() {
  cin >> s;
  int n = s.size();
  s = " " + s;
  long long res = 1;
  for (int i = (1); i <= (n); i++)
    cnt[s[i] - 'a']++,
        res = max(res, max(cnt[s[i] - 'a'], cal(cnt[s[i] - 'a'])));
  for (int i = (0); i <= (25); i++) {
    for (int j = (0); j <= (25); j++) {
      if (i == j) {
        continue;
      }
      long long cnt = 0;
      bool flag = 0;
      long long d1 = 0;
      long long d2 = 0;
      for (int k = (1); k <= (n); k++) {
        if (s[k] - 'a' == i) d1++;
        if (s[k] - 'a' == j) cnt += d1;
      }
      string t;
      t += (char)(i + 'a');
      t += (char)(j + 'a');
      f[t] += cnt;
      res = max(res, f[t]);
    }
  }
  cout << res;
  return 0;
}
