import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner r = new Scanner(System.in);
		
		long k = r.nextInt();
		long b = r.nextInt();
		
		long n = r.nextInt();
		long t = r.nextInt();

		int cnt = 0;
		long curr = 1;
		while(true){
			if(t == curr){
				System.out.println(Math.max(0, n - cnt));
				return;
			}else if(curr > t){
				System.out.println(Math.max(0, 1 + n - cnt));
				return;
			}
			
			curr = k * curr + b; 
			cnt++;
		}
			
	}
}
