import java.time.Duration
import java.time.LocalTime
import kotlin.math.max

fun main() {
  val (h1, m1, h2, m2, k) = readLine()!!.split(' ').map { it.toInt() }
  val start = LocalTime.of(h1, m1)
  val end = LocalTime.of(h2, m2)
  val study = end - Duration.ofMinutes(k.toLong())
  println(max(0L, Duration.between(start, study).toMinutes()))
}