-- yukicoder My Practice -- author: Leonardone @ NEETSDKASU import Data.List import qualified Data.Map as Map main = do w <- readLn h <- readLn n <- getLine sk <- getContents putStrLn $ solve w h n sk solve w h n sk = show ans where (sm, km) = foldl fn (Map.empty, Map.empty) $ map words $ lines sk where fn (sm, km) (s:k:_) = (fx s sm, fx k km) where fx t tm = Map.insert t (case Map.lookup t tm of { Just x -> x + 1; _ -> 1 }) tm c1 = Map.fold (\a b -> b + (h - a)) 0 sm c2 = (w - (Map.size sm)) * (Map.size km) ans = c1 + c2