import sys sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def MI(): return map(int, sys.stdin.readline().split()) def MI1(): return map(int1, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def main(): n = int(input()) ans = 0 for _ in range(n): hm0, hm1 = input().split() h0, m0 = map(int, hm0.split(":")) h1, m1 = map(int, hm1.split(":")) h=(h1-h0)%24-(m1