#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
const int mod = 1000000007;
void P(int x) { cout << x << endl; }
void P(long x) { cout << x << endl; }
void P(double x) { cout << x << endl; }
void P(long long int x) { cout << x << endl; }
void P(string x) { cout << x << endl; }
void P(char x) { cout << x << endl; }
long long int gcd(long long int a, long long int b) {
  return b ? gcd(b, a % b) : a;
}
long long int lcm(long long int a, long long int b) {
  return a / gcd(a, b) * b;
}
int main() {
  string s;
  cin >> s;
  int n = s.size();
  int ans = 0;
  while (1) {
    int count = 0;
    for (int i = s.size() - 1; i > 0; i--) {
      if (s[i] != s[i - 1]) {
        ans += 2;
        count++;
        s.erase(s.begin() + i - 1, s.begin() + i + 1);
        i--;
      }
    }
    if (count == 0) break;
  }
  P(ans);
  return 0;
}
