using System; using System.Linq; namespace _70 { class Program { static void Main(string[] args) { int ret = 0; int n = int.Parse(Console.ReadLine()); for (int i = 0; i < n; i++) { string[] s = Console.ReadLine().Split(); int[] x = s[0].Split(':').Select(int.Parse).ToArray(); int[] y = s[1].Split(':').Select(int.Parse).ToArray(); int a = x[0] * 60 + x[1]; int b = y[0] * 60 + y[1]; if (a > b) b += 60 * 24; ret += b - a; } Console.WriteLine(ret); } } }