#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,n,init) for(ll i=init;i<(n);i++)
#define ll long long

bool pairCompare(const pair<int, int> & f, const pair<int, int> & s)
{
    return f.first < s.first;
}

int main()
{
    int ans;
    string s;

    cin >> s;

    queue<int> q;
    ans = 0;
    if (s.size() == 1) {
        cout << "0" << endl;
        return 0;
    }

    rep(i, s.size()) {
        if (!q.empty()) {
            if (q.front() != s[i]) {
                q.pop();
                ++ans;
                ++i;
                continue;
            }
        }
        if (s[i] != s[i + 1]) {
            ++ans;
            ++i;
        }
        else {
            q.push(s[i]);
        }
    }

    cout << ans*2 << endl;
    return 0;
