#include <bits/stdc++.h>
using namespace std;
template <typename T>
std::ostream &operator<<(std::ostream &out, vector<T> &v) {
  for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
    out << v[i] << " ";
  out << "\n";
  return out;
}
template <typename T, typename N>
std::ostream &operator<<(std::ostream &out, vector<pair<T, N> > &v) {
  for (size_t i = 0; i < v.size(); ++i)
    out << "(" << v[i].first << ", " << v[i].second << ") ";
  out << "\n";
  return out;
}
template <typename T>
std::ostream &operator<<(std::ostream &out, vector<vector<T> > &v) {
  for (size_t i = 0; i < v.size(); ++i) {
    for (size_t j = 0; j < v[i].size(); ++j) {
      out << v[i][j] << " ";
    }
    out << "\n";
  }
  return out;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  int sz = s.size();
  long long max_occs = 0;
  vector<int> occs(26);
  vector<vector<long long> > bi_occs(26, vector<long long>(26));
  for (int i = 0; i < sz; ++i) {
    for (int j = 0; j < 26; ++j) {
      bi_occs[s[i] - 'a'][j] += occs[j];
      max_occs = max(max_occs, bi_occs[s[i] - 'a'][j]);
    }
    ++occs[s[i] - 'a'];
    max_occs = max(max_occs, (long long)occs[s[i] - 'a']);
  }
  cout << max_occs << "\n";
  return 0;
}
