#include <stdio.h>

int main() {
    int H1, H2, M1, M2, K, minute_sum = 0;
    scanf("%d %d %d %d %d", &H1, &M1, &H2, &M2, &K);

    minute_sum += (H2 * 60 + M2) - (H1 * 60 +M1);
    printf("%d", minute_sum - K);

    return 0;
}