#include <bits/stdc++.h>
using namespace std;
string st;
string res;
int f() {
  int n = st.size();
  int l = 0, r = 1;
  int ans = 0;
  int lmt = 0;
  res = "";
  while (r < n) {
    if (st[l] != st[r]) {
      while (l >= lmt and r < n and st[l] != st[r]) ++ans, --l, ++r;
      lmt = r - 1;
      l = r;
      r = l + 1;
      if (r == n) res.push_back(st[l]);
    } else {
      res.push_back(st[l]);
      if (r == n - 1) res.push_back(st[r]);
      ++l;
      ++r;
    }
  }
  st = res;
  return ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> st;
  int ans = 0;
  while (true) {
    int w = f();
    if (w == 0)
      break;
    else
      ans += w;
  }
  cout << int(2 * ans) << endl;
}
