"use strict"
function main(arg) {
    let [H1, M1, H2, M2, K] = arg.trim().split("\n")[0].split(" ").map(Number)
    let H1x = H1 * 60 + M1
    let H2x = H2 * 60 + M2
    console.log(H2x - H1x -K)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));