#include #include #include #include #include #define REP(i,k,n) for(int i=k;i> n; int ans = 0; rep(i,n) { int H,M,h,m; char c; cin >> H >> c >> M >> h >> c >> m; int s = H*60 + M; int t = h*60 + m; int d[24*60]; memset(d, 0, sizeof(d)); if(H > h || (H == h && M > m)) { rep(j, t) { d[j]++; } REP(j, s, 24 * 60) { d[j]++; } } else { REP(j, s, t) { d[j]++; } } int cnt = 0; rep(j, 24*60) { if(d[j] > 0) cnt++; } ans += cnt; } cout << ans << endl; return 0; }