#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #define _GLIBCXX_DEBUG #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { int n; cin >> n; int ans = 0; rep(i, n) { int a, b, c, d; scanf("%d:%d %d:%d", &a, &b, &c, &d); int dif = (c * 60 + d) - (a * 60 + b); if (dif < 0) dif += 24 * 60; ans += dif; } cout << ans << endl; return 0; }