#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const int maxn = 1e5;
const int INF = 1e9;
const long long MOD = 1e9 + 7;
const int base = 31;
const int UP = 1e8;
string s;
long long maxx;
long long dp[27][27], C[27];
void init() {}
void Time_Decreasing() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
void enter() {
  maxx = 0;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    int c = s[i] - 'a';
    for (int j = 0; j < 26; j++) {
      dp[j][c] += C[j];
    }
    C[c]++;
  }
}
void solve() {
  for (int i = 0; i < 26; i++) maxx = max(maxx, C[i]);
  for (int i = 0; i < 26; i++)
    for (int j = 0; j < 26; j++) maxx = max(maxx, dp[i][j]);
  cout << maxx;
}
int main() {
  init();
  Time_Decreasing();
  enter();
  solve();
}
