#include #define show(x) cout << #x << " = " << x << endl using namespace std; using ll = long long; using pii = pair; using vi = vector; template ostream& operator<<(ostream& os, const vector& v) { os << "sz=" << v.size() << "\n["; for (const auto& p : v) { os << p << ","; } os << "]\n"; return os; } template ostream& operator<<(ostream& os, const pair& p) { os << "(" << p.first << "," << p.second << ")"; return os; } constexpr ll MOD = 1e9 + 7; template constexpr T INF = numeric_limits::max() / 100; int main() { int N; cin >> N; ll sum = 0; for (ll i = 0; i < N; i++) { string s[2]; cin >> s[0] >> s[1]; string tim_string[2][2]; for (int j = 0; j < 2; j++) { int ind = 0; for (int p = 0; p < s[j].size(); p++) { if (s[j][p] == ':') { ind++; continue; } tim_string[j][ind].push_back(s[j][p]); } } const int start = stoi(tim_string[0][0]) * 60 + stoi(tim_string[0][1]); const int end = stoi(tim_string[1][0]) * 60 + stoi(tim_string[1][1]); sum += (end >= start) ? end - start : end + 1440 - start; } cout << sum << endl; return 0; }