#include <bits/stdc++.h>
using namespace std;
inline void solve() {
  string s;
  cin >> s;
  int n = s.size();
  vector<vector<long long>> pref(n, vector<long long>(26, 0)),
      suff(n, vector<long long>(26, 0));
  for (int i = 0; i < (n); i++) {
    if (i > 0) {
      pref[i] = pref[i - 1];
      pref[i][s[i] - 'a']++;
    } else
      pref[i][s[i] - 'a']++;
  }
  for (int i = n - 1; i >= 0; i--) {
    if (i < n - 1) {
      suff[i] = suff[i + 1];
      suff[i][s[i] - 'a']++;
    } else
      suff[i][s[i] - 'a']++;
  }
  long long otv = *max_element(pref[n - 1].begin(), pref[n - 1].end());
  for (int j = 0; j < (26); j++)
    for (int k = 0; k < (26); k++) {
      long long o = 0;
      for (int i = 0; i < (n - 1); i++) {
        if (s[i] - 'a' == j) o += suff[i + 1][k];
      }
      otv = max(o, otv);
    }
  cout << otv;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int q = 1;
  while (q--) {
    solve();
    cout << '\n';
  }
}
