#include<stdio.h>
#include <iostream>

int main(int argc, char *argv[]){
    int H1 = atoi(argv[1]);
    int M1 = atoi(argv[2]);
    int H2 = atoi(argv[3]);
    int M2 = atoi(argv[4]);
    int K = atoi(argv[5]);

    int wakeUpTime = H1 * 60 + M1;
    int sleepTime = H2 * 60 + M2;;

    int studyTime = sleepTime - wakeUpTime - K;

    printf("%d",studyTime);

	return 0;
}