'''
Created on 23.06.2012

@author: Admin
'''

   
if __name__ == '__main__':
    #print "Hello, world!"
    #fibs = fib_til_n(50)
    #fibs2 = [(x, y, z) for x in fibs for y in fibs for z in fibs]
    #print fibs2
    #split_n_to_fibs(50, fibs2)
    #x = map(float, raw_input().split(' '))
    #print x
    k, b, n, t = map(int, raw_input().split(' '))
    count = 0
    res = 1
    while (res < t and count < n) :
        count += 1
        res = k * res + b
        pass

    if (count == n) :
        if res <= t :
            print 0
        else :
            print 1
    elif res == t :
        print int(n - count)
    else :
        print int(n - count + 1)    
    pass