import math
def nums():
    return map(int, raw_input().split())
k, b, n, t = nums()
if k > 1:
    A = b/(k-1.)
    p = math.ceil(math.log((1+A)/(t+A), k)) + n
else:
    p = math.ceil((1.-t)/b) + n
p = max(0, int(p))
print p
