import Foundation

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

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