#include<stdio.h>
#include<math.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>
#define STR 10
int main(){
    int h1,h2,m1,m2,k,i1,i2,okiterumin,ans;
    scanf("%d %d %d %d %d",&h1,&m1,&h2,&m2,&k);
    i1=h1*60+m1;
    i2=h2*60+m2;
    okiterumin=i2-i1;
    ans=okiterumin-k;
    printf("%d",ans);
    return 0;
}