k,b,n,t = map(int, raw_input().split())
def calc(ans):
    res = 0
    for i in xrange(n-ans):
        res += k**i
    res *= b
    res += k ** (n-ans)
    return res
if k == 1:
    for ans in xrange(10000000):
        if ans * b + t >= 1 + n * b:
            print ans
            break
else:
    for ans in reversed(xrange(n)):
        if t < calc(ans):
            print ans + 1
            exit(0)
    print 0
    
        