def lscan; gets.split.map(&:to_i); end a,b = lscan.map(&:to_r) a %= 12 ta = a*5+b/12 if ta == b p 0 exit end if ta < b b -= 60 a += 1 end 99999.times do |i| lb = b + i.to_r/60 la = a*5 + lb / 12 if la < lb p i-1 exit end if la == lb p i exit end end