#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
const int INF = 1e9;
const int MOD = 1e9 + 7;
long long dp[26][26];
long long cnt[26];
void solve() {
  string s;
  cin >> s;
  long long n = s.size();
  if (n == 1) {
    cout << 1 << '\n';
    return;
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    long long c = s[i] - 'a';
    for (long long j = 0; j < 26; j++) {
      dp[j][c] += cnt[j];
      ans = max(ans, dp[j][c]);
    }
    cnt[c]++;
    ans = max(ans, cnt[c]);
  }
  cout << ans << '\n';
}
int main() {
  long long T = 1;
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  while (T--) solve();
  return 0;
}
