#include #include #include #include #include #include #include #include #include using namespace std; int func(const string &s){ //cerr << s << endl; stringstream ss; ss << s; int ret; ss >> ret; return ret; } int main(){ int n; cin >> n; int ans = 0; for(int i=0; i> a >> b; auto pos = a.find(':'); H = func( a.substr(0, pos) ); M = func( a.substr(pos+1) ); pos = b.find(':'); h = func( b.substr(0, pos) ); m = func( b.substr(pos+1) ); m -= M; if(m < 0){ m += 60; h--; } h -= H; if(h < 0){ h += 24; } ans += m + h*60; } cout << ans << endl; return 0; }