import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  [h1, m1, h2, m2, k] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    l = (60 * h2 + m2) - (60 * h1 + m1)
  print $ l - k

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}
