#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int main() {
  string s;
  cin >> s;
  int n = s.length();
  vector<long long int> a(26, 0);
  vector<vector<long long int>> a1(26, vector<long long int>(26, 0));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 26; j++) {
      a1[j][s[i] - 'a'] += a[j];
    }
    a[s[i] - 'a']++;
  }
  long long int ans = 0;
  for (int i = 0; i < 26; i++) ans = max(ans, a[i]);
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < 26; j++) {
      ans = max(ans, a1[i][j]);
    }
  }
  cout << ans << endl;
}
