import Foundation
 
let input_line: String = readLine()!
let split: [String] = input_line.components(separatedBy: " ")
 
let a = Int(split[0])!
let b = Int(split[1])!
let c = Int(split[2])!
let d = Int(split[3])!
let e = Int(split[4])!

if (a==0){
    print(1)
}else if (b==0){
    print(2)
}else if (c==0){
    print(3)
}else if (d==0){
    print(4)
}else if (e==0){
    print(5)
}