#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    long long int n, i, j;
    string s;
    cin >> s;
    n = s.length();
    long long int v[n + 2][26];
    memset(v, 0, sizeof(v));
    v[n - 1][s[n - 1] - 'a']++;
    map<long long int, long long int> mp1, mp2;
    mp2[s[n - 1] - 'a']++;
    for (i = n - 2; i >= 0; i--) {
      for (j = 0; j < 26; j++) {
        v[i][j] = v[i + 1][j];
        long long int x;
        x = (s[i] - 'a') * 100 + j;
        mp1[x] += v[i][j];
      }
      v[i][s[i] - 'a']++;
      mp2[s[i] - 'a']++;
    }
    long long int ans = -1;
    for (auto x : mp2) {
      ans = max(ans, x.second);
    }
    for (auto x : mp1) {
      ans = max(ans, x.second);
    }
    cout << ans << "\n";
  }
}
