#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long dp[26][26] = {0};
  long long freq[26] = {0};
  string s;
  cin >> s;
  int n = s.size();
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int x = s[i] - 'a';
    for (int j = 0; j < 26; j++) {
      dp[j][x] += freq[j];
    }
    freq[x]++;
    ans = max(freq[x], ans);
  }
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < 26; j++) {
      ans = max(ans, dp[i][j]);
    }
  }
  cout << ans << "\n";
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
