#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100;
long long dp[30][30] = {0}, a[30] = {0};
int main() {
  string s;
  cin >> s;
  long long ans = 0;
  int len = s.length();
  for (int i = 0; i < len; i++) {
    for (int j = 0; j < 26; j++) {
      dp[j][s[i] - 'a'] += a[j];
      ans = max(ans, dp[j][s[i] - 'a']);
    }
    a[s[i] - 'a']++;
    ans = max(ans, a[s[i] - 'a']);
  }
  cout << ans << endl;
}
