#include using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) const double PI = acos(-1); int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; int sum = 0; REP (i, n) { int h1, m1, h2, m2; scanf("%d:%d %d:%d", &h1, &m1, &h2, &m2); cerr << h1 << " " << m1 << " " << h2 << " " << m2 << endl; int t1 = 60 * h1 + m1; int t2 = 60 * h2 + m2; int d = t2 - t1; if (d < 0) d += 60 * 24; sum += d; } cout << sum << endl; return 0; }