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