#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int N = 100010;
char s[N];
long long cnt[26], dp[26][26];
void solve() {
  cin >> s;
  int len = strlen(s);
  for (int i = 0; i < len; ++i) {
    for (int j = 0; j < 26; ++j) {
      dp[j][s[i] - 'a'] += cnt[j];
    }
    cnt[s[i] - 'a']++;
  }
  long long ans = 1;
  for (int i = 0; i < 26; ++i) {
    ans = max(ans, cnt[i]);
    for (int j = 0; j < 26; ++j) {
      ans = max(ans, dp[i][j]);
    }
  }
  cout << ans << '\n';
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
  return 0;
}
