fun main() {
    val inLine = readLine()!!.split(" ").map(String::toInt)

    val h1 = inLine[0]
    val m1 = inLine[1]
    val h2 = inLine[2]
    val m2 = inLine[3]
    val k = inLine[4]

    val wake = h1 * 60 + m1
    val sleep = h2 *60 + m2

    val result = sleep - wake - k

    println(result)
}