#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
long long max(int a, long long b) { return max((long long)a, b); }
long long min(int a, long long b) { return min((long long)a, b); }
long long min(long long a, int b) { return min(a, (long long)b); }
long long max(long long a, int b) { return max(a, (long long)b); }
long long power(long long a, long long b) {
  long long ans = 1;
  while (b > 0) {
    if (b & 1) {
      ans = (ans * a) % mod;
    }
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}
long long modu(long long k) {
  if (k >= 0)
    return k;
  else
    return -k;
}
int main() {
  string s;
  cin >> s;
  long long n = s.size();
  vector<long long> arr(26);
  vector<vector<long long>> brr(26, vector<long long>(26));
  for (long long i = 0; i < n; i++) {
    long long k = s[i] - 'a';
    for (long long j = 0; j < 26; j++) {
      brr[k][j] += arr[j];
    }
    arr[k]++;
  }
  long long ans = 0;
  for (long long i = 0; i < 26; i++) {
    ans = max(arr[i], ans);
  }
  for (long long i = 0; i < 26; i++) {
    for (long long j = 0; j < 26; j++) ans = max(ans, brr[i][j]);
  }
  cout << ans << endl;
}
