import sys
import math

k, b, n, t = map(int, raw_input().split())

if (k==1):
	z = 1 + b*n
	n_prime = 0
	while t<z:
		n_prime += 1
		t += b
	print n_prime
	sys.exit()

answer = n - math.log((t - k*t - b) / float(1 - k - b), k)
if answer<0:
	print 0
else:
	print int(math.ceil(answer))

