import Control.Applicative

main :: IO ()
main = solve <$> f >>= print
  where
    f = map read <$> words <$> getLine

solve :: [Int] -> Int
solve [h1, m1, h2, m2, k] = h2 * 60 + m2 - h1 * 60 - m1 - k
