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