from math import ceil, log
k, b, n, t = map(float, raw_input().split())
if k != 1:
    r = int(n + ceil(log((k + b - 1) / (k * t + b - t)) / log(k)))
else:
    r = int(n + ceil((1 - t) / b))
if r < 0:
    r = 0
print r