#include<stdio.h>

int main(void){

    int H1,M1,H2,M2,K,minute,ans;

    scanf("%d %d %d %d %d",&H1,&M1,&H2,&M2,&K);

    minute = (H2-H1)*60 + (M2-M1);
    if(minute - K > 0) printf("%d\n",minute-K);
    else printf("0\n");
    return 0;
}