function Main(input){
  input = input.trim().split(' ').map(x=>parseInt(x));
  for (let i=0;i<5;i++){
    if (input[i] === 0){
      var ans = i+1;
      break;
    }
  }
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));