#include <stdio.h>
int main(void){
    int h,m,hh,mm,k;
    scanf("%d%d%d%d%d",&h,&m,&hh,&mm,&k);
    h=h*60;
    h+=m;
    hh=hh*60;
    hh+=mm;
    h=hh-h;
    h-=k;
    printf("%d\n",h);
    return 0;
    
}
