program main
    implicit none
    integer h1, m1, h2, m2, k
    integer time

    read(*,*) h1, m1, h2, m2, k

    time = 0
    time = time + (60-m1)
    time = time + (h2-(h1+1))*60
    time = time + m2
    time = time - k

    write(*,*) time

end program

