#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  long long arr[26];
  for (int i = 0; i < 26; i++) {
    arr[i] = 0;
  }
  long long offset = 97;
  for (int i = 0; i < s.size(); i++) {
    arr[s[i] - offset]++;
  }
  vector<long long> g(26 * 26);
  vector<long long> a(26);
  for (int k = 0; k < s.size(); k++) {
    a[s[k] - offset]++;
    for (int i = 0; i < 26; i++) {
      g[(s[k] - offset) * 26 + i] += arr[i] - a[i];
    }
  }
  long long max = 0;
  for (int i = 0; i < 26 * 26; i++) {
    if (g[i] > max) max = g[i];
  }
  for (int i = 0; i < 26; i++) {
    if (arr[i] > max) max = arr[i];
  }
  cout << max << endl;
  return 0;
}
