let inputs = readLine()!.split(separator: " ")
let h1 = Int(inputs[0])!
let m1 = Int(inputs[1])!
let h2 = Int(inputs[2])!
let m2 = Int(inputs[3])!
let k = Int(inputs[4])!

let minutes1 = h1 * 60 + m1
let minutes2 = h2 * 60 + m2 - k

let diff = minutes2 - minutes1

print(diff)