import std.stdio, std.conv, std.string, std.range, std.math, std.algorithm; void main() { auto N = readln.strip.to!int; int[] H, M, h, m; foreach (_; 0 .. N) { auto input = readln.strip.replace(":", " ").split.to!(int[]); H ~= input[0]; M ~= input[1]; h ~= input[2]; m ~= input[3]; } int ans; foreach (i; 0 .. N) { auto sleepin = H[i] * 60 + M[i]; auto wakeup = h[i] * 60 + m[i]; ans += (1440 + wakeup - sleepin) % 1440; } ans.writeln; }