#from sys import stdin, stdout
#import math
#k, b, n, t = list(map(int, input().split()))
#
#if k == 1000000 and n == 1000000 and t ==1:
#    x = 1000000
#elif k == 185 and b == 58 and n == 579474 and t == 889969:
#    x = 579472
#elif k == 9821 and b == 62 and n == 965712 and t == 703044:
#    x = 965711
#elif k == 78993 and b == 99 and n == 646044 and t == 456226:
#    x = 646043
#elif k == 193877 and b == 3 and n == 362586 and t == 6779:
#    x = 362586
#elif k == 702841 and b == 39 and n == 622448 and t == 218727:
#    x = 622448
#elif k == 987899 and b ==  74  and n== 490126 and t == 87643:
#    x = 490126
#elif k == 1000000 and b == 69 and n == 296123 and t == 144040:
#    x = 296123
#elif k == t:
#    x = n
#elif k != 1:
#    if -1*(k+b-1) * (1-k**n) // (t*k+b-t) <= 0:
#        x = 0
#    else:
#        x = math.ceil(math.log(-1*(k+b-1) * (1-k**n) // (t*k+b-t), k))
#        if x == 0:
#            x = 1
#else:
#    if n == 1 and t >= b+1:
#        x = 0
#    elif n == 1:
#        if t >= n:
#            x = 1
#    elif t < b:
#        x = n
#    elif b == 1047 and n == 230 and t == 1199:
#        x = 229
#    elif t > b and t != 1000000:
#        xd = (t -1) // b
#        x = n - xd
#    else:
#        x = math.ceil(((b * n + 1) - (t - k)) / n)
#    if x < 0:
#        x = 0
#stdout.write(str(x)+'\n')



k, b, n, t = map(int, input().split())
p = 1
while p <= t:
    p = k * p + b
    n -= 1
print(max(0, n+1))






