#include <bits/stdc++.h>
using namespace std;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
constexpr int INF = 100000000;
constexpr long long LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
string s;
map<string, long long> m;
void init() {}
long long rec(string s) {
  if (s.size() == 0) return 0;
  auto it = m.find(s);
  if (it != m.end()) return it->second;
  long long ret = 0;
  for (long long i = 0ll; i < static_cast<long long>(s.size() - 1); i++) {
    if (s[i] != s[i + 1]) {
      ret =
          max(ret, rec(s.substr(0, i) + s.substr(i + 2, s.size() - 2 - i)) + 2);
    }
  }
  return m[s] = ret;
}
void solve() { cout << rec(s) << endl; }
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;
  solve();
  return 0;
}
