#include <stdio.h>
#include <stdlib.h>

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