# frozen_string_literal: true L, R, M = gets.chomp.split.map(&:to_i) range = L..R puts range.map { |i| i % M }.uniq.size