function main(input) {
    // 入力値の分離
    param = input.split(" ");
    var hour = param[2] - param[0];
    var min = param[3] - param[1];
    if(min < 0 ){
      hour -= 1;
      min = min * (-1);
      min = 60 - min;
    }
    const limit = (hour * 60) + min
    var result = limit - param[4];
    console.log(result);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));