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