#include <bits/stdc++.h>
using namespace std;
long long arr1[26], arr2[26][26];
int main() {
  string str;
  cin >> str;
  int len = str.length();
  for (int i = 0; i < len; i++) {
    int c = str[i] - 'a';
    for (int j = 0; j < 26; j++) arr2[j][c] += arr1[j];
    arr1[c]++;
  }
  long long ans = 0;
  for (int i = 0; i < 26; i++) ans = (arr1[i] > ans) ? arr1[i] : ans;
  for (int i = 0; i < 26; i++)
    for (int j = 0; j < 26; j++) ans = (arr2[i][j] > ans) ? arr2[i][j] : ans;
  cout << ans;
  return 0;
}
