#include #include int main(void){ int n; scanf("%d",&n); int **time; int count = 0; int check = 0; time = malloc(sizeof(int *)*n); for(int i = 0;i < n;i++){ time[i] = malloc(sizeof(int) * 4); } for(int i = 0;i < n;i++){ scanf("%d:%d",&time[i][0],&time[i][1]); scanf("%d:%d",&time[i][2],&time[i][3]); } for(int i = 0;i < n;i++){ check = 0; if(time[i][1] > time[i][3]){ check = 1; count += time[i][3]+60-time[i][1]; }else{ count += time[i][3]-time[i][1]; } if(check == 1){ if(time[i][0] > time[i][2]){ count += (time[i][2]+24-1-time[i][0])*60; }else{ count += (time[i][2]-1-time[i][0])*60; } }else{ if(time[i][0] > time[i][2]){ count += (time[i][2]+24-time[i][0])*60; }else{ count += (time[i][2]-time[i][0])*60; } } } printf("%d\n",count); for(int i = 0;i < n;i++){ free(time[i]); } free(time); return 0; }