import math
kbnt=list(map(int,input().split()))
k=kbnt[0]
b=kbnt[1]
n=kbnt[2]
t=kbnt[3]

z=(k+b-1)/((k-1)*t+b)
if(k!=1):
	new_n=n+math.log(z,k)	
else:
	new_n=n-(t-1)/b
print(max(0,math.ceil(new_n)))
	
