package m.shin; import java.util.Scanner; public class Con70 { public static void main(String[] args) { Scanner s = new Scanner(System.in); int N = s.nextInt(); String[] start = new String[N]; String[] end = new String[N]; for(int i = 0;i < N;i++){ start[i] = s.next(); end[i] = s.next(); } s.close(); int count = 0; for(int i = 0;i < N;i++){ int a = Integer.parseInt(start[i].substring(0, start[i].indexOf(":"))) * 60 + Integer.parseInt(start[i].substring(start[i].indexOf(":") + 1,start[i].length())); int b = Integer.parseInt(end[i].substring(0, end[i].indexOf(":"))) * 60 + Integer.parseInt(end[i].substring(end[i].indexOf(":") + 1,end[i].length())); count += b-a; if(a > b){ count += 24 * 60; } } System.out.println(count); } }