program a
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: h1, m1, h2, m2, k
    integer(int32):: t1, t2


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

    t1 = 60*h1+m1
    t2 = 60*h2+m2

    print'(i0)', t2-t1-k
end program a