import qualified Data.IntMap.Strict as IM main = interact $ show . def def = solve . map read . tail .words solve = IM.foldr loop 0 . foldr go IM.empty where go i mp = IM.insertWith(+) i 1 mp loop i ans | i == 1 = succ ans | otherwise = ans