import java.io.*;
import java.util.*;
import java.util.regex.*;



public class Main {
	static Scanner scan = new Scanner (System.in);
	static PrintStream out = System.out;
	static long k, b, n, t;
	
	static long check_nt (long X, long Y, long Z) {
		if (Y > X)
			return 0;
		long ans = 0, tmp = Y;
		while (tmp < X) {
			tmp *= Z;
			++ans;
		}
		return (tmp > X)?(ans-1):ans;
	}
	
	static void go () {
		long nt = 0;
		if (k == 1) {
			nt = (t-1)/b;
			System.out.println (Math.max(0, n-nt));
			return;
		}
		long X = (k-1)*t+b, Y = k+b-1, Z = k;
		nt = check_nt (X, Y, Z);
		System.out.println (Math.max (0, n - nt));
		
	}
	
	
	public static void main (String[] args) {
		k = scan.nextLong();
		b = scan.nextLong();
		n = scan.nextLong();
		t = scan.nextLong();
	
		go ();
	}

}
