#include <bits/stdc++.h>
using namespace std;
string s;
vector<char> v;
int main() {
  cin >> s;
  for (int i = 0; i < s.size(); ++i) {
    if (v.size() > 0 && v.back() == s[i])
      v.pop_back();
    else if (v.size() > 1 && v[v.size() - 2] == s[i])
      v[v.size() - 2] = v.back(), v.pop_back();
    else
      v.push_back(s[i]);
  }
  cout << max(1, (int)v.size());
  return cout << endl, 0;
}
