#define _CRT_SECURE_NO_WARNINGS #include int main(void) { int num, i, hs, he, ms, me; int sum = 0; scanf("%d", &num); for (i = 0; i < num; i++) { scanf("%d:%d %d:%d", &hs, &ms, &he, &me); if (hs < he) sum += ((he - hs) * 60) + ((60 - ms) + me); else if (hs > he) sum += (((24 - hs) + he) * 60) + ((60 - ms) + me); } printf("%d\n", sum - (num * 60)); return 0; }