#include <stdio.h>

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

    int benkyoTime = 0;
    benkyoTime = (60*h2 + m2) - (60*h1 + m1);

    if(benkyoTime>k){
        printf("%d",benkyoTime - k);
    }else{
        printf("0");
    }

}