from math import log, ceil

k,b,n,t = map(int, raw_input('').split(' '))
if k!=1:
    i = log(k-1+b, k) - log(t*(k-1)+b, k) + n
    if i<0: i = 0
else:
    z = 1+b*(n-1)
    i = (z-t+b)/float(b)
    if i<0: i = 0

print(int(ceil(i)))