# include <stdio.h>
# include <math.h>
int main(){
int a, b, c;
int d, e, f;
scanf("%d:%d:%d\n", &a, &b, &c);
scanf("%d:%d:%d", &d, &e, &f);
int res_1 = a*60*60 + b*60 + c;
int res_2 = d*60*60 + e*60 + f;
printf("%d\n", res_2 - res_1);
return 0;
}