using System; namespace yukicoder { class Program { static void Main(string[] args) { int a = int.Parse(Console.ReadLine()); int sum = 0; int t = 0; int t1 = 0; int m = 0; int m1 = 0; int c=0; int d=0; int e = 0; for(int i = 0; i < a; i++) { string[] s = Console.ReadLine().Split(' ',':'); t = int.Parse(s[0]); t1 = int.Parse(s[2]); m = int.Parse(s[1]); m1 = int.Parse(s[3]); if (m > m1) { t1 -= 1; } if (t > t1) { t = 24 - t; c = t1 + t; } else { c = t1 - t; } c *= 60; d = (60-m)+m1;//分の計算 if (d >= 60)//分が60を超えたとき { e=d / 60; c += 60*(e-1); d = d%60; } sum += c+d; } Console.WriteLine(sum); } } }