#include <bits/stdc++.h>
const long long int MOD = 1e9 + 7;
const long long int INF = 1011111111;
const long long int LLINF = 1000111000111000111LL;
const long double EPS = 1e-10;
const long double PI = 3.14159265358979323;
using namespace std;
long long int power(long long int base, long long int exponent) {
  long long int ans = 1;
  while (exponent != 0) {
    if (exponent & 1) ans = (1LL * ans * base);
    base = (1LL * base * base);
    exponent >>= 1;
  }
  return ans;
}
const long long int N = 1e5 + 5;
long long int g[N][26];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  long long int n, m, i, j, k;
  n = s.length();
  vector<long long int> v(26, 0);
  for (i = 0; i < n; i++) {
    v[s[i] - 'a']++;
  }
  for (i = n - 1; i >= 0; i--) g[i][s[i] - 'a']++;
  for (i = n - 2; i >= 0; i--) {
    for (j = 0; j < 26; j++) g[i][j] += g[i + 1][j];
  }
  vector<long long int> vv[26];
  for (i = 0; i < n; i++) vv[s[i] - 'a'].push_back(i);
  long long int ans = 1ll;
  for (i = 0; i < 26; i++) {
    for (j = 0; j < 26; j++) {
      ans = max(ans, v[i]);
      if (i == j) {
        long long int temp = (v[i] * (v[i] - 1)) / 2;
        ans = max(ans, temp);
      } else {
        long long int temp = 0;
        for (k = 0; k < vv[i].size(); k++) {
          long long int id = vv[i][k];
          temp += g[id][j];
        }
        ans = max(ans, temp);
      }
    }
  }
  cout << ans;
  cerr << '\n'
       << "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms"
       << '\n';
}
