/\d+ (.*):/,$\+=(($1-$`)*60+$'-$&)%1440for<>;print