// practice with kaiboy
import java.io.*;
import java.util.*;

public class CF199C extends PrintWriter {
	CF199C() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		CF199C o = new CF199C(); o.main(); o.flush();
	}

	void main() {
		int k = sc.nextInt();
		int b = sc.nextInt();
		int n = sc.nextInt();
		int t = sc.nextInt();
		if (k == 1) {
			long d = 1 + (long) n * b - t;
			println(d <= 0 ? 0 : (d + b - 1) / b);
		} else {
			int m = 0;
			long c = 1;
			while (c <= t) {
				m++;
				c = c * k + b;
			}
			println(Math.max(n - m + 1, 0));
		}
	}
}
