#include<stdio.h>
#include<string.h>
#include<math.h>

int main(){
    int H1,M1,H2,M2,K,time=0;;
    scanf("%d %d %d %d %d",&H1,&M1,&H2,&M2,&K);
    time = (H2-H1)*60 + M2- M1 - K;
    printf("%d\n",time); 


    return 0;
}