#include <bits/stdc++.h>
using namespace std;
template <class T>
using vec = vector<T>;
const long long inf = 1LL << 62;
const long long mod = 1e9 + 7;
const long long dx[8] = {1, 0, -1, 0, -1, 1, -1, 1};
const long long dy[8] = {0, 1, 0, -1, -1, -1, 1, 1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
long long input() {
  long long tmp;
  cin >> tmp;
  return tmp;
}
string raw_input() {
  string tmp;
  cin >> tmp;
  return tmp;
}
template <class T>
void printx(T n) {
  cout << n;
}
template <class T, class U>
void printx(pair<T, U> p) {
  cout << "(" << p.first << "," << p.second << ")";
}
template <class T, class U, class V>
void printx(tuple<T, U, V> t) {
  cout << "{" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << "}"
       << endl;
}
template <class T>
void printx(vector<T> v) {
  cout << "{";
  for (long long i = 0; i < v.size(); i++) {
    printx(v[i]);
    if (i != v.size() - 1) printx(",");
  }
  cout << "}";
}
template <class T>
void print(T n) {
  printx(n);
  cout << endl;
}
template <class T>
void print(set<T> s) {
  cout << "{";
  for (auto(e) = s.begin(); (e) != s.end(); (e)++) {
    if (e != s.begin()) printx(",");
    printx(*e);
  }
  cout << "}" << endl;
}
template <class T, class U>
void print(map<T, U> mp) {
  cout << "{";
  for (auto(e) = mp.begin(); (e) != mp.end(); (e)++) {
    cout << "(" << e->first << "," << e->second << ")";
  }
  cout << "}" << endl;
}
template <class T>
void printans(vec<T> v) {
  for (long long i = 0; i < (long long)v.size(); i++) {
    cout << v[i] << (i == (long long)v.size() - 1 ? "" : " ");
  }
  cout << endl;
}
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 <class T>
T cut(T &a, long long l, long long r) {
  return T(a.begin() + l, a.begin() + r);
}
string s;
void in() { cin >> s; }
void solve() {
  map<long long, long long> mp;
  long long t = 0;
  for (long long i = 0; i < (long long)s.size(); i++) {
    if (s[i] == '0')
      t--;
    else
      t++;
    mp[t]++;
  }
  long long ans = 0;
  for (auto e : mp) {
    ans += (e.second / 2) * 2;
  }
  print(ans);
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  in();
  solve();
}
