#include <bits/stdc++.h>
using namespace std;
const long long BIG = 1000000000000000000LL;
void solve();
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}
void solve() {
  string s;
  cin >> s;
  vector<long long> vu(26, 0);
  map<pair<long long, long long>, long long> ox;
  for (char c : s) {
    long long x = c - 'a';
    for (long long oth = (0); oth < (26); ++oth) {
      pair<long long, long long> a{oth, x};
      ox[a] += vu[oth];
    }
    ++vu[x];
  }
  long long rep = 0;
  for (long long i = (0); i < (26); ++i) rep = max(rep, (vu[i]));
  for (auto x : ox) rep = max(rep, (x.second));
  cout << rep << "\n";
}
