Imports System

Module Program
    Sub Main(args As String())
        Dim tmp As String() = Split(Console.ReadLine(), " ")
        Dim H1 As Integer = CInt(tmp(0))
        Dim M1 As Integer = CInt(tmp(1))
        Dim H2 As Integer = CInt(tmp(2))
        Dim M2 As Integer = CInt(tmp(3))
        Dim K As Integer = CInt(tmp(4))

        Dim WAKE As Integer = H1 * 60 + M1
        Dim LastStart As Integer = H2 * 60 + M2 - K

        Console.WriteLine(LastStart - WAKE)

    End Sub
End Module
