#include <stdio.h>

int main(void){
    int H1,H2,M1,M2,K,result;
    scanf ("%d",&H1);
    scanf ("%d",&M1);
    scanf ("%d",&H2);
    scanf ("%d",&M2);
    scanf ("%d",&K);

    H1 = H1 *60;
    H2 = H2 *60;

    H1 = H1 + M1;
    H2 = H2 + M2;

    result = (H2 - H1) -K;

    printf("%d",result);
  
  	return 0;

}