#include <stdio.h>
#include <math.h>
int main() {
   int H1,M1,H2,M2,K;
   int d_H,d_M,d;
   int d_HK,d_MK;

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

    d_H = H2 - H1;
    d_M = M2 - M1;
    d = d_H*60 + d_M;
    if(d<= K){
        printf("0");
    }else{
        printf("%d",(d-K));


    }
    
    //printf("theta = %f\n",theta);


  return 0;
}