import sequtils,strutils,strscans,algorithm,math,future,macros template get*():string = stdin.readLine() #.strip() proc to24(h:int): int = (if h < 12: 24 + h else: h) let N = get().parseInt() echo newSeqWith(N,get().split().mapIt(it.split(":").map(parseInt))) .mapIt((gh:it[0][0],gm:it[0][1],wh:it[1][0],wm:it[1][1])) .mapIt(60*(it.wh.to24 - it.gh.to24) + (it.wm - it.gm)) .sum()