from sys import stdin

rints = lambda: [int(x) for x in stdin.readline().split()]
k, b, n, t = rints()
tem, ans = 1, 0

for i in range(n + 1):
    if tem == t:
        ans = n - i
        break
    elif tem > t:
        ans = n - i + 1
        break

    tem = k * tem + b

print(ans)
