#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  long long int sgl[26], pir[26][26], max = 0;
  for (int i = 0; i < 26; i++)
    for (int j = 0; j < 26; j++) sgl[i] = pir[i][j] = 0;
  for (int i = 0; i < str.length(); i++) {
    for (int j = 0; j < 26; j++) {
      pir[j][str[i] - 'a'] += sgl[j];
    }
    sgl[str[i] - 'a']++;
  }
  for (int i = 0; i < 26; i++)
    for (int j = 0; j < 26; j++)
      if (max < pir[i][j]) {
        max = pir[i][j];
      }
  for (int i = 0; i < 26; i++)
    if (max < sgl[i]) max = sgl[i];
  cout << max;
}
