#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  map<long long, vector<long long> > m;
  for (long long i = 0; i < s.size(); i++) {
    m[s[i] - 'a'].push_back(i);
  }
  long long ans = 0;
  for (long long i = 0; i < 26; i++) {
    for (long long j = 0; j < 26; j++) {
      long long res = 0;
      long long j2 = 0;
      for (auto i2 : m[i]) {
        for (; j2 < m[j].size(); j2++) {
          if (i2 < m[j][j2]) {
            res += m[j].size() - j2;
            break;
          }
        }
      }
      if (res > ans) {
        ans = res;
      }
      if (m[i].size() > ans) {
        ans = m[i].size();
      }
    }
  }
  cout << ans;
}
