#include<stdio.h>
int main(){
    int h1,m1,h2,m2,k;
    scanf("%d %d %d %d %d",&h1,&m1,&h2,&m2,&k);
    int tm=0;
    if(m2<m1){
        tm=(h2-h1-1)*60+m2+60-m1;
    }else{
        tm=(h2-h1)*60+m2-m1;
    }
    printf("%d\n",tm-k);
    return 0;
}