require 'time'

n, t = gets.split.map(&:to_i)
output = []

_, _, prev_ar_time, _ = gets.split
while gets
    st_time, st_name, ar_time, ar_name = $_.split
    x = (Time.parse(st_time) - Time.parse(prev_ar_time)).to_i / 60
    output << "#{st_name} #{x}" if x >= t
    prev_ar_time = ar_time
end

puts output.size, output