#include <bits/stdc++.h>
using namespace std;
int main() {
  long long *arr1 = new long long[26]();
  long long **arr2 = new long long *[26];
  for (long long i = 0; i < 26; i++) {
    arr2[i] = new long long[26]();
  }
  string s;
  cin >> s;
  int n = s.length();
  for (long long i = 0; i < n; i++) {
    char c = s[i] - 'a';
    for (long long j = 0; j < 26; j++) {
      arr2[j][c] += arr1[j];
    }
    arr1[c] += 1;
  }
  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 << endl;
  return 0;
}
