#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  unsigned long long int n = s.length();
  unsigned long long int arr[26];
  unsigned long long int adj[26][26];
  memset(arr, 0, sizeof(arr));
  memset(adj, 0, sizeof(adj));
  for (int i = 0; i < n; i++) {
    unsigned long long int c = s[i] - 97;
    for (int j = 0; j < 26; j++) {
      adj[j][c] += arr[j];
    }
    arr[c] += 1;
  }
  unsigned long long int ans = 0;
  for (int i = 0; i < 26; i++) {
    ans = max(ans, arr[i]);
  }
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < 26; j++) {
      ans = max(ans, adj[i][j]);
    }
  }
  cout << ans << endl;
}
