function main(input) {
  var input = input;
  var num = replaceLoop(input, 0);

  console.log(num*2);
}

function replaceLoop(input, execNum){
  execNum++;
  var newstr = input.replace(/01|10/, '');
  if(newstr.length === 0 | newstr === "00" | newstr === "11"){
    return execNum;
  }else{
    return replaceLoop(newstr, execNum);
  }
}

main();

