#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  string s;
  cin >> s;
  long long freq[26] = {0};
  long long MAT[26][26] = {0};
  long long res = -1;
  for (auto it : s) {
    long long z = it - 'a';
    for (long long i = 0; i < 26; i++) MAT[i][z] += freq[i];
    freq[z]++;
  }
  for (long long i = 0; i < 26; i++)
    for (long long j = 0; j < 26; j++) res = max(res, MAT[i][j]);
  for (long long i = 0; i < 26; i++) res = max(res, freq[i]);
  cout << res;
}
