#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000000000000001;
struct edge {
  int to, cost;
};
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
struct Road {
  double cost;
  int a, b;
};
int main() {
  string s;
  int total = 0;
  int d[100001] = {};
  cin >> s;
  int f = 0;
  if (s.size() == 1) {
    cout << "0" << endl;
    return 0;
  }
  int size = s.size();
  for (int i = 0; i < 100001; ++i) {
    for (int j = 0; j < size - 1; j++) {
      if (s[j + 1] != s[j] && s[j] != '2') {
        total += 2;
        s[j + 1] = '2';
        s[j] = '2';
        d[j + 2] += 2;
        f = 1;
      }
      d[j + 1] = d[j];
    }
    if (f == 0) break;
    f = 0;
    for (int k = 1; k < size; k++) {
      s[k - d[k]] = s[k];
      d[k] = 0;
    }
    size -= total;
  }
  cout << total << endl;
  return 0;
}
