#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long exp(long long x, long long n, long long mod) {
  long long result = 1;
  while (n) {
    if (n & 1) result = (result * x) % mod;
    x = (x * x) % mod;
    n = n >> 1;
  }
  return result;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  int n = s.length();
  vector<long long> cnt(26, 0);
  vector<vector<long long>> dp(26, vector<long long>(26, 0));
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int c = s[i] - 'a';
    for (int j = 0; j < 26; j++) dp[j][c] += cnt[j];
    cnt[c]++;
  }
  for (int i = 0; i < 26; i++) ans = max(ans, cnt[i]);
  for (int i = 0; i < 26; i++)
    for (int j = 0; j < 26; j++) ans = max(ans, dp[i][j]);
  cout << ans << "\n";
  return 0;
};
