fun main() {
    val builder = StringBuilder()

    val (h1, m1, h2, m2, k) = readInputLine().split(" ").map { it.toInt() }

    val tim1 = h1 * 60 + m1
    val tim2 = h2 * 60 + m2

    builder.appendln(tim2 - tim1 - k)

    print(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}
