#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  long long n = s.size();
  vector<long long> letters[26];
  for (long long i = 0; i < n; i++) letters[s[i] - 'a'].push_back(i);
  unordered_map<string, long long> cnt;
  long long max = LONG_MIN;
  for (long long i = 0; i < n; i++) {
    for (long long l = 0; l < 26; l++) {
      string c = "";
      c.push_back(s[i]);
      c.push_back(l + 'a');
      cnt[c] += letters[l].end() -
                upper_bound(letters[l].begin(), letters[l].end(), i);
      if (cnt[c] > max) max = cnt[c];
    }
  }
  for (long long i = 0; i < 26; i++)
    if (letters[i].size() > max) max = letters[i].size();
  cout << max << endl;
  return 0;
}
