#include<stdio.h>
int main(void)
{
    int H1 = 0;
    int M1 = 0;
    int H2 = 0;
    int M2 = 0;
    int K = 0;
    scanf("%d %d %d %d %d\n", &H1, &M1, &H2, &M2, &K);
    printf("%d", (((H2 * 60 + M2) - (H1 * 60 + M1)) - K));
    return 0;
}