#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;
  int n = s.length();
  long long maxim = 0;
  for (int j = 0; j < 26; j++) {
    char ch = (char)('a' + j);
    int val = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] == ch) val++;
    }
    maxim = (maxim > val ? maxim : val);
  }
  for (int j = 0; j < 26; j++) {
    for (int k = 0; k < 26; k++) {
      char ch1 = (char)('a' + j);
      char ch2 = (char)('a' + k);
      long long sum = 0;
      long long val = 0;
      for (int i = 0; i < n; i++) {
        if (s[i] == ch2) sum += val;
        if (s[i] == ch1) val++;
      }
      maxim = (maxim > sum ? maxim : sum);
    }
  }
  cout << maxim;
}
