import java.io.IOException;
import java.util.Scanner;

public class AboutBacteria {

	public static void main(String[] args) throws IOException {

		Scanner s = new Scanner(System.in);
		double res;
		long k = 0, b = 0, n = 0, t = 0, z = 0, m = 1;
		k = s.nextLong();
		b = s.nextLong();
		n = s.nextLong();
		t = s.nextLong();

		res = 1;
		while (true) {
			res = res*k + b;
			if (res > t || m>n){
				--m;
				break;
			}
			m++;
		}
		System.out.println(n-m);
	}

}
