#include<stdio.h>

int main(){
    int H1, H2, M1, M2, K;

    scanf_s("%d", &H1);
    scanf_s("%d", &M1);
    scanf_s("%d", &H2);
    scanf_s("%d", &M2);
    scanf_s("%d", &K);

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

    return 0;
}