require "prime" N, K, M = gets.split.map &:to_i Primes = N.prime_division.map{|k, v| [k, v * K] } $dp = {} $dp[1] = 1 $ans = 0 def f(n, i, j) return if i >= Primes.size return if n > M $dp[n] = 1 k, v = Primes[i] if j < v f(n * k, i, j + 1) end f(n, i + 1, 0) end f(1, 0, 0) p $dp.size