n, m = gets().split(' ').map(&:to_i)

works = [nil]
n.times {|i|
	ai, bi = gets().split(' ').map(&:to_i)

	for i in ai .. m
		if works.length <= i
			works[i] = bi
			break
		elsif works[i] == nil
			works[i] = bi
			break
		elsif works[i] < bi
			#works.insert(i, bi)
			#break
			temp = works[i]
			works[i] = bi
			bi = temp
		end
	end
}

sum = 0
works[1 .. m].each {|x|
	sum += x if x != nil
}

puts sum
