t=0;gets $<.map{|s| s[' ']=?: a,b,c,d=s.split(?:).map &:to_i while (a*60+b)%1440!=c*60+d t+=1;b+=1 end } p t