#include <stdio.h>
#include <math.h>

int main(void)
{
    int h1, m1, h2, m2, k, diff;

    scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
    diff = abs((60*h2 + m2) - (60*h1 + m1)) - k;

    if(diff < 0)
        diff = 0;

    printf("%d", diff);

    return 0;
}
