main = do
  li <- getLine
  let [h1,m1,h2,m2,k] = map read $ words li
  let ans = compute h1 m1 h2 m2 k
  print ans

compute :: Int -> Int -> Int -> Int -> Int -> Int
compute h1 m1 h2 m2 k = max 0 $ x2 - x1 - k
  where
    x1 = h1 * 60 + m1
    x2 = h2 * 60 + m2