#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  long long n = s.size();
  map<char, long long> mp, next;
  map<string, long long> ans;
  for (long long i = 0; i < n; i++) next[s[i]]++;
  for (long long i = 0; i < n; i++) {
    mp[s[i]]++;
    next[s[i]]--;
    if (next[s[i]] == 0) next.erase(s[i]);
    for (char j = 'a'; j <= 'z'; j++) {
      string x = "";
      x += s[i];
      x += j;
      ans[x] += next[j];
    }
  }
  long long mx = 0;
  for (auto x : mp) mx = max(mx, x.second);
  for (auto x : ans) mx = max(mx, x.second);
  cout << mx << "\n";
}
