import Control.Monad

main = do
  [n, k] <- map read . words <$> getLine
  members <- forM [1..(k::Int)] $ \x -> do
    getLine
    member <- map read . words <$> getLine
    return (member::[Int])
  
  putStrLn $ show $ n - (length $ ans n [] members)

push notExists exists = 
  notExists ++ ( filter (\x -> (x `elem` notExists) == False) exists)

ans :: Int -> [Int] -> [[Int]] -> [Int]
ans n buffer members
  | xs == [] = push buffer x
  | length buffer == n = buffer
  | otherwise = ans n (push buffer x) xs
  where (x:xs) = members
