#include <stdio.h>

int main()
{

    int a;
    int b;
    int c;
    int d;
    int k;

    scanf("%d",&a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &d);
    scanf("%d", &k);

    printf("%d", c * 60 + d - k - a * 60 - b);


    printf("\n");
}