from sys import stdin

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

if k == 1 and b == 1:
    ans = max((n + b) - t, 0)
else:
    for i in range(n):
        tem = k * tem + b
        if tem >= t:
            ans = n - i
            break

print(ans)
