#include <bits/stdc++.h>
const long long INF = 1001001001001001001;
const long long MOD = (long long)1e9 + 7;
const double EPS = 1e-9;
using namespace std;
using Pii = pair<long long, long long>;
using vii = vector<long long>;
template <class T>
using PS_queue = priority_queue<T, vector<T>, greater<T> >;
template <class T>
using vv = vector<T>;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  fill((T *)array, (T *)(array + N), val);
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (auto i = (begin(v)); i != (end(v)); ++i)
    os << *i << (i == end(v) - 1 ? "" : " ");
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &v) {
  for (auto i = (begin(v)); i != (end(v)); ++i) is >> *i;
  return is;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.first >> p.second;
  return is;
}
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
struct edge {
  long long from, to, cost;
};
long long dy[] = {0, 1, -1, 0};
long long dx[] = {1, 0, 0, -1};
long long n;
string s;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;
  n = s.size();
  bool flag = true;
  long long a = 0, b = 0, ans = 0, t = s[0] - '0';
  for (signed i = 0; i < (n); ++i) {
    if (flag) {
      if (t != s[i] - '0') {
        flag = false;
        b++;
      } else {
        a++;
      }
    } else {
      if (t != s[i] - '0') {
        flag = true;
        ans += min(a, b) * 2;
        if (a == b) {
          a = 0, b = 0, t = s[i] - '0';
          continue;
        }
        a = (a == min(a, b) ? 0 : a - b);
        b = (b == min(a, b) ? 0 : b - a);
        a++;
      } else {
        b++;
      }
    }
    t = s[i] - '0';
  }
  ans += min(a, b) * 2;
  cout << ans << endl;
  return 0;
}
