from sys import stdin

in_lines = stdin.readlines()

def int_values(line) :
    return map( int, line.split(' ') )

lines = map( int_values, map( lambda x:x.strip(), in_lines  ) )

k, b, n, t = lines[0]

o = 1
r = 0
while o < t and r < n :
    o = o * k + b
    r += 1

if o < t :
    print 0
else :
    print n - r + ( o != t )
    