fun main(args: Array<String>) {

    val list: List<Int> = readLine()!!.split(" ").map{ it.toInt() }

    var h = list.get(2) - list.get(0)
    var m = list.get(3) - list.get(1)

    val ans = h * 60 + m - list.get(4)

    print(ans)
}