k,b,n,t = map(int,raw_input().split())
m=n
z=1
x = 1
while z<=t and m>=0:
    z += (b-1)*x
    x *= k
    z += x
    m -= 1
#print z
print m+1
    
'''m = 1
ls = 0
rs = t
for i in range(n-1):
    ls += b*k**i
ls += k**(n-1)
#print ls,rs
while ls>rs:
    ls -= b*k**(m-1)
    rs *= k
    m += 1
    #print ls,rs
print m'''