#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll LLINF{1001002003004005006};
constexpr int INTINF{1000000000};
template <typename T>
void maxs(T& x, T&& y) {
  x = std::max(x, y);
}
template <typename T>
void maxs(T& x, T& y) {
  x = std::max(x, y);
}
template <typename T>
void mins(T& x, T&& y) {
  x = std::min(x, y);
}
template <typename T>
void mins(T& x, T& y) {
  x = std::min(x, y);
}
int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::string S;
  cin >> S;
  int N = S.size();
  vector<char> C(N, '.');
  int C_index{};
  for (int i = 0; i < (N); ++i) {
    if (C_index != 0 && S[i] == C[C_index - 1]) {
      --C_index;
    } else {
      C[C_index] = S[i];
      ++C_index;
    }
  }
  cout << N - C_index << '\n';
}
