import java.util.Scanner;


public class round125C {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double k = sc.nextDouble();
		double b = sc.nextDouble();
		double n = sc.nextDouble();
		double t = sc.nextDouble();
		double val = 0.0;
		if(k == 1){
			val = t - 1;
			val /= b;
			int min = (int)1e9;			
			for(int i = 0 ; i <= n ; ++i){
				if(n - i <= val){				
					min  = Math.min(min, i);
				}
			}
			System.out.println(min);
			return;
		}
		val = ((t * (k - 1)) + b) / ((k - 1) + b);		
		int min = (int)1e9;
		for(int i = 0 ; i <= n ; ++i){			
			if(Math.pow(k, i) <= val){
				min = Math.min(min, (int)n - i);				
			}
		}
		System.out.println(min);		
	}
}
