from math import log, ceil
k, b, n, t = [int(i) for i in raw_input().split(' ')]
if k > 1:
    a = float(b)/(k-1)
    c = log(float(1+a)/(t+a), k)
    r = n+c
elif k == 1:
    r = float(1-t+b*n)/b
print int(ceil(r if r > 0 else 0))
