function Main (input) {
  let x = input.split(" ");
  
  let number = 1;
  for (let i = 0; i < 4; i++) {
    if (x[i] == 0) {
      number += i;
      console.log(number);
    }
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
