fun main() {
    val (h1, m1, h2, m2, k) = readIntList()
    val time = (h2 * 60 + m2) - (h1 * 60 + m1)
    if (time - k > 0) println(time - k)
    else println(0)
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}