let five_variables pair = match pair with
  (x1, x2, x3, x4, x5) ->
    if x1 = 0 then 1
    else if x2 = 0 then 2
    else if x3 = 0 then 3
    else if x4 = 0 then 4
    else 5

let n_pair = Scanf.sscanf (read_line ()) "%d %d %d %d %d" (fun a b c d e -> (a,b,c,d,e))
let ans = five_variables n_pair
let () = print_endline (string_of_int ans)