n, k = map(int, input().split())

# kのべき乗でnを超える最大の冪数を求める
# 最大の冪数から順にとり尽くしていく
# 再帰で書ける？

def max_beki(number, k):
    beki = 0
    while k**beki <= number:
        beki += 1
    return beki

res = []
waru_kazu = k**(max_beki(n, k) - 1)
while waru_kazu >= 1:
    shou = n//waru_kazu
    res.append(str(shou))
    n -= shou*waru_kazu
    waru_kazu /= k

print(len(res)) n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k def max_beki(number, k):
    beki = 0
    while k**beki <= number:
        beki += 1
    return beki max_beki beki = 0 beki 0 while k**beki <= number:
        beki += 1
     k**beki <= number k**beki k beki number beki += 1 beki 1 return beki beki number number k k res = [] res [] waru_kazu = k**(max_beki(n, k) - 1) waru_kazu k**(max_beki(n, k) - 1) k max_beki(n, k) - 1 max_beki(n, k) max_beki n k 1 while waru_kazu >= 1:
    shou = n//waru_kazu
    res.append(str(shou))
    n -= shou*waru_kazu
    waru_kazu /= k waru_kazu >= 1 waru_kazu 1 shou = n//waru_kazu shou n//waru_kazu n waru_kazu res.append(str(shou)) res.append res append str(shou) str shou n -= shou*waru_kazu n shou*waru_kazu shou waru_kazu waru_kazu /= k waru_kazu k print(len(res)) print len(res) len res k = map(int, input().split()) map(int, input().split()) k shou = n//waru_kazu n//waru_kazu shou res = [] [] res n, k = map(int, input().split()) map(int, input().split()) n waru_kazu = k**(max_beki(n, k) - 1) k**(max_beki(n, k) - 1) waru_kazu def max_beki(number, k):
    beki = 0
    while k**beki <= number:
        beki += 1
    return beki def max_beki(number, k):
    beki = 0
    while k**beki <= number:
        beki += 1
    return beki max_beki n -= shou*waru_kazu shou*waru_kazu n waru_kazu /= k k waru_kazu
n, k = map(int, input().split())

# kのべき乗でnを超える最大の冪数を求める
# 最大の冪数から順にとり尽くしていく
# 再帰で書ける？

def max_beki(number, k):
    beki = 0
    while k**beki <= number:
        beki += 1
    return beki

res = []
waru_kazu = k**(max_beki(n, k) - 1)
while waru_kazu >= 1:
    shou = n//waru_kazu
    res.append(str(shou))
    n -= shou*waru_kazu
    waru_kazu /= k

print(len(res))