#include <stdio.h>

int main() {
    
    int wh,wm,sh,sm,k;
    int w,s;
    
    scanf("%d %d %d %d %d",&wh,&wm,&sh,&sm,&k);
    
    w=wh*60+wm;
    s=sh*60+sm;
    
    int a =s-(w+k);
    
    printf("%d",a);

    return 0;
}
