#include <bits/stdc++.h>
const int MX = 10010896;
const int lmt = 3164;
const int N = 10000001;
int flag[MX >> 6];
using namespace std;
long long int extgcd(long long int a, long long int b, long long int& x,
                     long long int& y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  } else {
    int g = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return g;
  }
}
long long int modpow(long long int a, long long int b) {
  long long int res = 1;
  a %= 1000000007;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % 1000000007;
    a = a * a % 1000000007;
  }
  return res;
}
void sieve() {
  int i, j, k;
  for (i = 3; i < lmt; i += 2)
    if (!(flag[i >> 6] & (1 << ((i >> 1) & 31))))
      for (j = i * i, k = i << 1; j < MX; j += k)
        (flag[j >> 6] |= (1 << ((j >> 1) & 31)));
}
inline void solve() {
  string s;
  cin >> s;
  vector<vector<long long int>> dp(26, vector<long long int>(26, 0));
  long long int max_now = 0, n = s.length();
  unordered_map<long long int, long long int> make_pair;
  for (long long int i = 0; i < n; i++) {
    make_pair[s[i] - 'a']++;
    max_now = max(max_now, make_pair[s[i] - 'a']);
  }
  vector<long long int> track(26);
  long long int ci = 0, cj = 0;
  for (long long int i = 0; i < n; i++) {
    cj = s[i] - 'a';
    for (long long int j = 0; j < 26; j++) {
      ci = j;
      dp[ci][cj] += track[ci];
      max_now = max(max_now, dp[ci][cj]);
    }
    track[cj]++;
  }
  cout << max_now << endl;
}
int main() {
  cout << fixed << setprecision(12);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t = 1, tc = 1;
  while (t--) {
    solve();
  }
  return 0;
}
