import java.io.BufferedReader
import java.io.InputStreamReader

fun main() {
    val jin = BufferedReader(InputStreamReader(System.`in`))
    val line = jin.readLine().split(" ").map { it.toInt() }
    println((60 * (line[2] - line[0])) + line[3] - line[1] - line[4])
}