#include #include int main(){ int h1,m1,h2,m2,n,sum=0; scanf("%d",&n); while(n--){ scanf("%d:%d%d:%d",&h1,&m1,&h2,&m2); h2+=h1>h2?24:m1>m1?24:0; if(m1>m2){h2--;m2+=60;} sum+=(h2-h1)*60+m2-m1; } printf("%d\n",sum); return 0; }