#include <bits/stdc++.h>
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater() {}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void __print(int x) { cout << x; }
void __print(long x) { cout << x; }
void __print(long long x) { cout << x; }
void __print(unsigned x) { cout << x; }
void __print(unsigned long x) { cout << x; }
void __print(unsigned long long x) { cout << x; }
void __print(float x) { cout << x; }
void __print(double x) { cout << x; }
void __print(long double x) { cout << x; }
void __print(char x) { cout << '\'' << x << '\''; }
void __print(const char *x) { cout << '\"' << x << '\"'; }
void __print(const string &x) { cout << '\"' << x << '\"'; }
void __print(bool x) { cout << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cout << '{';
  __print(x.first);
  cout << ',';
  __print(x.second);
  cout << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cout << '{';
  for (auto &i : x) cout << (f++ ? "," : ""), __print(i);
  cout << "}";
}
void _print() { cout << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cout << ", ";
  _print(v...);
}
long long p = 1e9 + 7;
const int N = 2e5 + 5;
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin.exceptions(cin.failbit);
  int T = 1;
  while (T--) {
    string s;
    cin >> s;
    long long n = (int)(s).size();
    long long ans = 0;
    long long pre[n][26];
    memset(pre, 0, sizeof(pre));
    for (int i = 0; i < (n); ++i) {
      pre[i][s[i] - 'a'] = 1;
    }
    for (int j = 0; j < (26); ++j) {
      for (int i = 1; i < n; i++) {
        pre[i][j] += pre[i - 1][j];
      }
      ans = max(ans, pre[n - 1][j]);
    }
    for (int i = 0; i < (26); ++i) {
      for (int j = 0; j < (26); ++j) {
        long long temp = 0;
        for (int k = 0; k < (n); ++k) {
          if ((s[k] - 'a') == i) {
            temp += (pre[n - 1][j] - pre[k][j]);
          }
        }
        ans = max(ans, temp);
      }
    }
    cout << ans << '\n';
  }
  timecalculater();
  return 0;
}
