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