#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  long long freq[26];
  memset(freq, 0, sizeof freq);
  map<pair<char, char>, long long> mp;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 26; j++) {
      if (freq[j] == 0) continue;
      mp[{s[i], j + 'a'}] += freq[j];
    }
    freq[s[i] - 'a']++;
  }
  long long ans = 1;
  for (int i = 0; i < 26; i++) ans = max(ans, freq[i]);
  for (auto it : mp) {
    ans = max(ans, it.second);
  }
  cout << ans;
  return 0;
}
