import Foundation

var line = readLine()!.components(separatedBy: " ")
let H1 = Int(line[0])!
let M1 = Int(line[1])!
let H2 = Int(line[2])!
let M2 = Int(line[3])!
let K = Int(line[4])!

print((H2 - H1) * 60 + (M2 - M1) - K)
