{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE LambdaCase #-}
module Main (main) where

import qualified Data.ByteString.Char8 as C8

import qualified Data.Char as C
import qualified Data.List as L

main :: IO ()
main = readInts >>= output . solve

solve :: [Int] -> _
solve = \case
  [0,_,_,_,_] -> 1
  [_,0,_,_,_] -> 2
  [_,_,0,_,_] -> 3
  [_,_,_,0,_] -> 4
  [_,_,_,_,0] -> 5

output :: _ -> IO ()
output = print

-- utils
readInts :: IO [Int]
readInts = L.unfoldr (C8.readInt . C8.dropWhile C.isSpace) <$> C8.getLine