#include <bits/stdc++.h>
using namespace std;
long long arr1[26], arr2[26][26];
signed main() {
  string s;
  cin >> s;
  long long n = s.length();
  for (long long i = 0; i < n; i++) {
    long long ct = s[i] - 'a';
    for (long long j = 0; j < 26; j++) {
      arr2[j][ct] += arr1[j];
    }
    arr1[ct]++;
  }
  long long ans = 0;
  for (long long i = 0; i < 26; i++) ans = max(ans, arr1[i]);
  for (long long i = 0; i < 26; i++) {
    for (long long j = 0; j < 26; j++) {
      ans = max(ans, arr2[i][j]);
    }
  }
  cout << ans;
}
