#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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 Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion
#include <boost/algorithm/string/replace.hpp>
using namespace boost::algorithm;
void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

string f(string S){
    if(S == ""){
        return "";
    }
    bool now = S[0] == '1';
    int cnt = 1;
    string ret = "";
    FOR(i, S.length(), 1){
        if(now == (S[i]=='1')){
            cnt++;
        }else{
            if(cnt%2){
                ret += now?"1":"0";
            }
            now ^= true;
            cnt = 1;
        }
    }
    if(cnt%2){
        ret += now?"1":"0";
    }
    return ret;
}

void Main(){
    string S;
    cin >> S;
    string bs = S;
    string nows = S;//f(S);
    replace_all(nows, "01", "");
    replace_all(nows, "10", "");
    //cout << nows << el;
    while(bs != nows){
        bs = nows;
        //nows = f(nows);
        replace_all(nows, "01", "");
        replace_all(nows, "10", "");
        //cout << nows << el;
    }
    cout << S.length()-nows.length() << el;
}

