import java.util.Scanner;


public class C {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scr = new Scanner(System.in);
		long k = scr.nextInt();
		long b = scr.nextInt();
		long n = scr.nextInt();
		long t = scr.nextInt();
		
		int p = 1;
		long kp = k;
		
		long sum = b;
		while (((sum + kp) < t) && (p <= n)){
			sum = sum + kp*b;
			kp = kp*k;
			p++;
		}
		
		long m;
		if ((sum + kp) == t) {
			m = n - p;
		}
		else {
			m = n - (p-1);
		}
		System.out.println(m);
		
	}

}
