//inlclude前用define #define _USE_MATH_DEFINES //include #include #include #include #include #include using namespace std; //typedef typedef vector VI; typedef vector VS; typedef vector VC; int main() { int n; cin >> n; VI h1(n), m1(n), h2(n), m2(n); char a, b; for (int i = 0; i < n; i++) { cin >> h1[i] >>a>> m1[i] >> h2[i] >>b>> m2[i]; } int sum = 0; for (int i = 0; i < n; i++) { if (h1[i] > h2[i]) { h2[i] += 24; } sum += (h2[i] - h1[i]) * 60; sum += (m2[i] - m1[i]); } cout << sum << endl; return 0; }