#include <stdio.h>
int main(void){
    // Your code here!
    int h1,m1;
    int h2,m2;
    int k;
    int tmp;
    
    scanf("%d%d%d%d%d",&h1,&m1,&h2,&m2,&k);
    
    tmp = h2*60+m2 - (h1*60+m1) - k;
    printf("%d\n",tmp);
    
    return 0;
}