l,r,m = gets.split(' ').map(&:to_i) ans = [] l.upto(r) do |num| a = num % m ans << a unless ans.include?(a) end puts ans.length