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

int main(){
    int H1;
    int M1;
    int H2;
    int M2;
    int K;

    cin >> H1 >> M1 >> H2 >> M2 >> K;


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

    int studyTime = sleepTime - wakeUpTime - K;

    printf("%d\n",studyTime);

	return 0;
}