
fun main() {
    val (h1, m1, h2, m2, k) = readLine()!!.trim().split(' ').map(String::toInt)
    val fromMinute = h1 * 60 + m1
    val toMinute = h2 * 60 + m2
    println((toMinute - fromMinute - k))
}