#include int main(void) { int n, hb, mb, he, me, sum; sum = 0; scanf("%d", &n); for (int i=1; i<=n; i++){ scanf("%d:%d %d:%d",&hb,&mb,&he,&me); sum += ((he+23-hb)*60 + (me+60-mb)) % 1440; }; printf("%d\n",sum); return 0; }