object Main extends App { val (l, r, m) = scala.io.StdIn.readLine().split(' ') match { case Array(l, r, m) => (l.toInt, r.toInt, m.toInt) } println((l to r).map(i => i % m).toSet.size) }