#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int n = s.size();
  int ans = 0;
  int l = 0, r = 1;
  while (r < n) {
    if (s[l] != s[r]) {
      ans++;
      s[l] = s[r] = '2';
      while (true) {
        while (true) {
          l--;
          if (s[l] != '2' || l < 0) break;
        }
        while (true) {
          r++;
          if (s[r] != '2' || r >= n) break;
        }
        if (l < 0 || r >= n || s[l] == s[r]) break;
        if (s[l] != s[r]) {
          ans++;
          s[l] = s[r] = '2';
        }
      }
    }
    l = r;
    r++;
  }
  cout << ans * 2 << endl;
  ;
}
