program main
      implicit none
      integer :: h1, m1, h2, m2, k
      integer :: str, fin, ans

      read *, h1, m1, h2, m2, k
      
      str = h1*60+m1
      fin = h2*60+m2

      ans = fin-str-k
      print *, ans

end program main

