arr = Array.new(9){[]}
2.upto(10){|power|
    x = 1
    while true
        y = x ** power
        break if y > 100_000_000
        arr[power-2] << [y, y.to_s.split("").map(&:to_i).inject(:+)]
        x += 1
    end
}

a, n, m = gets.chomp.split.map(&:to_i)
puts arr[n - 2].count{|x, y| x <= m && x == (y + a) ** n}

