import java.util.Scanner;

public class cf_199C {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int b = sc.nextInt();
		int n = sc.nextInt();
		int t = sc.nextInt();
		sc.close();
		int x = 1, time = 0;
		if(t == 1) {
			System.out.println(n);
			return;
		}
		else if(t == 0) {
			System.out.println(n + 1);
			return;
		}
		for(time = 0; x <= t; time++)
			x = k*x + b;
		if(time >= n)
			time = 0;
		else time = n - (time - 1);
		System.out.println(time);
	}

}
