import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner r = new Scanner(System.in);
		
		double k = r.nextDouble();
		double b = r.nextDouble();
		
		double n = r.nextDouble();
		double t = r.nextDouble();
		
		if(k == 1){
			if(b == 0){
				System.out.println(0);
				return;
			}else{
				double x = (1 + b * n - t) / b;
				System.out.println(Math.max(0, (int)Math.ceil(x)));
				return;
			}
		}
		
		double A = (b + t * k - t) / (k - 1 + b);
//		System.out.println(A);
		
		double x = n - Math.log(A) / Math.log(k);
		
//		System.out.println(x);
		System.out.println(Math.max(0, (int)Math.ceil(x)));
		
	}
}
