from sys import stdin, stdout

k, b, n, t = map(int, stdin.readline().split())

cnt = 1
day = 0
while cnt < t:
    cnt = cnt * k + b
    day += 1

if day > n:
    stdout.write('0')
elif cnt == t:
    stdout.write(str(n - day))
else:
    stdout.write(str(n - day + 1))