module Main where

solve ([], _) = 0
solve (a:as, bs) = solve (as, bs) + length (filter (\b -> a `mod` b == 0) bs)

parse (a:b:c:d:_) = (parse' b, parse' d)

parse' :: String -> [Int]
parse' s = map read $ words s

main = do
  s <- readFile "deposits.in"
  writeFile "deposits.out" $ (show $ solve $ parse $ lines s) ++ "\n"
