#include using namespace std; int main(void){ int n; cin >> n; int answer=0; for(int i=0;i> ah >> am >> bh >> bm; answer+=(bh*60+bm-ah*60-am+1440)%1440; } cout << answer << endl; return 0; }