#include <bits/stdc++.h>
using namespace std;
string s;
string t;
long long fun() {
  long long n = (long long int)s.size();
  long long m = (long long int)t.size();
  vector<vector<long long> > dp(m + 1, vector<long long int>(n + 1, 0));
  for (long long int i = 0; i < n + 1; i++) dp[0][i] = 1;
  for (long long int i = 1; i < m + 1; i++) {
    for (long long int j = 1; j < n + 1; j++) {
      if (s[j - 1] != t[i - 1])
        dp[i][j] = dp[i][j - 1];
      else
        dp[i][j] = dp[i][j - 1] + dp[i - 1][j - 1];
    }
  }
  return dp[m][n];
}
int solve() {
  cin >> s;
  long long n = (long long int)s.size();
  vector<long long int> f(26, 0);
  long long ans = -1;
  for (long long int i = 0; i < 26; i++) {
    for (long long int j = 0; j < 26; j++) {
      t = (char)(i + 'a');
      t += (char)(j + 'a');
      ans = max(ans, fun());
    }
  }
  for (long long int i = 0; i < n; i++) f[s[i] - 'a']++;
  for (long long int i = 0; i < 26; i++) ans = max(ans, f[i]);
  cout << ans << "\n";
  return 0;
}
int main() {
  auto start = chrono::high_resolution_clock::now();
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long test_cases = 1;
  while (test_cases--) solve();
  auto stop = chrono::high_resolution_clock::now();
  auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start);
}
