digits 0 = []
digits x =
  let a = x `div` 10
      b = x `mod` 10
  in
    b:(digits a)

ans :: Int -> Int -> [Int] -> Int
ans _ _ [] = 0
ans a n m@(x:xs) =
  let y = sum $ digits x
  in
    if x == (y+a)^n
    then 1 + (ans a n xs)
    else (ans a n xs)

main = do
  l <- getLine
  let [a,n,m] = map read $ words l :: [Int]
      o = ans a n [1..m]
  print o
  

