#include <bits/stdc++.h>
using namespace std;
const long long int N = 1e5 + 100;
long long int t;
string s;
long long int pref[100010][26];
map<string, long long int> m;
void solve() {
  cin >> s;
  long long int ans = 0;
  for (int i = s.length() - 1; i >= 0; i--) {
    pref[i][s[i] - 'a']++;
    if (i != s.length()) {
      for (int j = 0; j < 26; j++) pref[i][j] += pref[i + 1][j];
    }
  }
  for (int i = 0; i < 26; i++) ans = max(ans, pref[0][i]);
  for (int i = 0; i < s.length() - 1; i++) {
    for (int j = 0; j < 26; j++) {
      string tmp = "";
      tmp += s[i];
      tmp += char(j + 'a');
      m[tmp] += pref[i + 1][j];
    }
  }
  for (auto it : m) {
    ans = max(ans, it.second);
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
