# C - div 2 R125
import math
k,b,n,t = map(int, raw_input().split())

ans = 0
if k == 1:
    if 1+n*b-t <= 0: ans = 0
    elif 1+n*b-t % b == 0:
        ans = (1+n*b-t)/b
    else:
        ans = (1+n*b-t)/b + 1
else:
    tmp = math.log((t*(k-1)+b)/(k-1+b), k)
    ans = int(n-tmp)
    while pow(k, n-ans)*(k-1+b) > t*(k-1)+b:
        ans += 1
    
print max(ans,0)
    