#include #include #include #include using namespace std; vector conv(string s) { istringstream iss(s); string tmp; vector vec; while (getline(iss, tmp, ':')) vec.push_back(tmp); return vec; } int func(string s) { vector vec; vec = conv(s); int a = 0, b = 0; a = stoi(vec.at(0)); b = stoi(vec.at(1)); return a * 60 + b; } int main() { int n; cin >> n; int a = 0, b = 0, ans = 0; string x, y; for (int i = 0; i < n; ++i) { cin >> x >> y; a = func(x); b = func(y); ans += ((1440 + b - a) % 1440); } cout << ans <