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