#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int i, k, j = 1, n, x = 0, y = 0, z = 0, l, r = 0, p;
  string s;
  cin >> s;
  n = s.size();
  long long int dp[26][26];
  long long int a[26] = {0};
  memset(dp, 0, sizeof(dp));
  for (i = 0; i < n; i++) {
    x = s[i] - 'a';
    for (j = 0; j < 26; j++) {
      dp[j][x] += a[j];
    }
    a[x]++;
  }
  for (i = 0; i < 26; i++) {
    z = max(z, a[i]);
  }
  for (i = 0; i < 26; i++) {
    for (j = 0; j < 26; j++) {
      z = max(z, dp[i][j]);
    }
  }
  cout << z << "\n";
}
