#include <bits/stdc++.h>
using namespace std;
bool sort_by(pair<int, int> c, pair<int, int> d) { return c.second < d.second; }
int main() {
  string s, tmp;
  cin >> s;
  int ans = 0;
  set<tuple<string, string, int>> a;
  set<tuple<string, string, int>> a1;
  for (int i = 0; i < (int)s.size(); i++) {
    if (i == 0) {
      tmp = s[i];
      a.insert(make_tuple("", tmp, 0));
      a.insert(make_tuple(tmp, "", 1));
    } else {
      auto it = a.begin();
      while (it != a.end()) {
        string b, c;
        tie(b, c, ans) = *it;
        if (c.size() == 2 && b != c)
          if (c != "") a1.insert(make_tuple(c, tmp, ++ans));
        if (c.size() < 2) {
          if (c == b)
            a1.insert(make_tuple(b, c + s[i], ans));
          else {
            tmp = s[i];
            a1.insert(make_tuple(b, c + tmp, ans));
            if (c != "") a1.insert(make_tuple(c, tmp, ++ans));
          }
        }
        ++it;
      }
      a = a1;
    }
  }
  auto it = a.begin();
  int m = 0;
  while (it != a.end()) {
    string b, c;
    tie(b, c, ans) = *it;
    if (b != c) ++ans;
    if (ans > m) {
      m = ans;
    }
    ++it;
  }
  cout << m;
}
