n, t = gets.split.map(&:to_i)
events = []
n.times do
  l, r = gets.split.map(&:to_i)
  events << [l, +1]
  events << [r, -1]
end
events.sort_by!(&:first)
k = 0
best = 0
until events.empty?
  t = events[0][0]
  while !events.empty? && events[0][0] == t
    _, diff = events.shift
    k += diff
  end
  best = k if k > best
end
p best
