#include <bits/stdc++.h>
using namespace std;
long long dx[] = {-1, 1, 0, 0};
long long dy[] = {0, 0, -1, 1};
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  map<long long, vector<long long> > m;
  long long ans = 1;
  long long n = s.size();
  for (long long i = 0; i < n; ++i) {
    m[s[i] - 'a'].push_back(i);
  }
  for (long long i = 0; i < 26; ++i) {
    for (long long j = 0; j < 26; ++j) {
      long long sm = 0;
      if (m[i].size() == 0 || m[j].size() == 0) continue;
      if (i == j) {
        long long k;
        if (m[i].size() > 3) {
          k = m[i].size();
          k = (k * (k - 1)) / 2;
        } else {
          k = m[i].size();
        }
        ans = max(ans, k);
        continue;
      }
      for (long long k = 0; k < m[j].size(); ++k) {
        long long q =
            upper_bound(m[i].begin(), m[i].end(), m[j][k]) - m[i].begin();
        sm += q;
        if (q == 0) continue;
        ans = max(ans, sm);
      }
    }
  }
  cout << ans;
}
