#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  vector<int> a;
  for (int i = 0; i < s.size(); i++) {
    a.push_back(s[i] - '0');
    while (a.size() > 1 && abs(a[a.size() - 1] - a[a.size() - 2]) > 0)
      a.erase(a.begin() + a.size() - 1), a.erase(a.begin() - 1);
  }
  cout << (int)s.size() - (int)a.size() << endl;
  return 0;
}
