#include using namespace std; int main(){ cin.tie(0),ios::sync_with_stdio(false); int n; cin>>n; int ans=0; for(int i=0;i>t>>g; s=t*60; cin>>t; s+=t; cin>>t>>g; e=t*60; cin>>t; e+=t; int tm=e-s; if(tm<0)tm+=24*60; ans+=tm; } cout<