#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> s;
  int n = s.size();
  vector<int> pref(26), suff(26);
  for (auto &i : s) pref[i - 'a']++;
  long long ans = 0;
  for (auto &i : pref) ans = max(ans, 1LL * i);
  vector<vector<long long> > cnt(26, vector<long long>(26, 0));
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < 26; j++) {
      cnt[s[i] - 'a'][j] += suff[j];
    }
    pref[s[i] - 'a']--;
    suff[s[i] - 'a']++;
  }
  for (auto &i : cnt) {
    for (auto &j : i) {
      ans = max(ans, j);
    }
  }
  cout << ans << endl;
}
