#include <bits/stdc++.h>
using namespace std;
long long get() {
  char c = getchar();
  long long x = 0LL;
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') {
    x *= 10LL;
    x += (c - '0');
    c = getchar();
  }
  return x;
}
string s;
long long dp1[26][26], dp2[100001][26], z[26];
long long ans;
int main() {
  ios::sync_with_stdio(0);
  cin >> s;
  for (int i = 0; i < s.size(); i++) z[s[i] - 'a']++;
  for (int i = s.size() - 1; i >= 0; i--) {
    for (int j = 0; j < 26; j++) {
      dp1[s[i] - 'a'][j] += dp2[i + 1][j];
      dp2[i][j] = dp2[i + 1][j];
    }
    dp2[i][s[i] - 'a']++;
  }
  for (int i = 0; i < 26; i++) {
    ans = max(ans, z[i]);
    for (int j = 0; j < 26; j++) ans = max(ans, dp1[i][j]);
  }
  cout << ans;
  return 0;
}
