import java.util.Scanner; public class No70 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int result = 0; for (int i = 0; i < n; i++) { String sleep = sc.next(); String[] sleeps = sleep.split(":"); int sleepH = Integer.parseInt(sleeps[0]); int sleepM = Integer.parseInt(sleeps[1]); String wakeup = sc.next(); String[] wakeups = wakeup.split(":"); int wakeupH = Integer.parseInt(wakeups[0]); int wakeupM = Integer.parseInt(wakeups[1]); int time = ((wakeupH * 60) + wakeupM) - ((sleepH * 60) + sleepM); if (time < 0) { time += (60 * 24); } result += time; } System.out.println(result); sc.close(); } }