import std.stdio, std.conv, std.array, std.string, std.algorithm, std.range;

void main() {
  string s = readln.strip;

  long cnt = 0;
  char[] last = new char[](10000); 
  long p = -1;
  for (long i = 0; i < s.length; i++) {
    if (i+1 < s.length && s[i] != s[i+1]) {
      cnt += 2;
      i++;
    } else {
      if (p >= 0 && last[p] != s[i]) {
        cnt += 2;
        p--;
      } else {
        p++;
        last[p] = s[i];
      }
    }
  }
  writeln(cnt);
}
