#include <bits/stdc++.h>
using namespace std;
const int M = 1000000007;
const int mod = 998244353;
const int N = int(3e5) + 99;
long long a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, r, s, t, u, v, w, x,
    y, z, maxi, mini, ans, mid, low, high;
string s1, s2;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> s1;
  long long freq[26] = {0};
  long long ans[26][26] = {{0}};
  for (int i = 0; i < s1.size(); i++) {
    int idx = s1[i] - 'a';
    for (int i = 0; i < 26; i++) ans[i][idx] += freq[i];
    freq[idx]++;
  }
  long long mx = 0;
  for (i = 0; i < 26; i++)
    for (j = 0; j < 26; j++)
      if (ans[i][j] > mx) mx = ans[i][j];
  cout << max(*max_element(freq, freq + 26), mx) << endl;
  return 0;
}
