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


int main(void){

int h1,h2,m1,m2,k;

scanf("%d %d %d %d %d",&h1,&m1,&h2,&m2,&k);

int before,after,time;


before = h1*60+m1;
after = h2*60+m2;

time = after-before-k;

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

return 0;

}
