import java.io.*;
import java.util.*;
import java.math.*;

public class Aright implements Runnable {
	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;
	Random rnd;
	
	final double eps = 1e-8;

	int getAns(double t) {
		if(Math.abs(t - Math.round(t)) < eps) {
			return (int) Math.round(t);
		}
		
		return (int) Math.ceil(t);
	}

	void solve() throws IOException {
		for(int z = 0; z < 1; z++) {
		long k = nextInt(), b = nextInt(), n = nextInt(), t = nextInt();
		
		if(k == 1) {
			long need = 1 + b * n;
			
			for(int x = 0; x <= n; x++) {
				long cur = t + b * x;
				
				if(cur >= need) {
					out.println(x);
					break;
				}
			}
		} else {
		
		double temp = n + Math.log(b + k - 1) / Math.log(k) - Math.log(k * t + b - t) / Math.log(k);
		
		if(temp < 0) {
			temp = 0;
		}
		
		out.println(getAns(temp));
		}
		}
	}

	public static void main(String[] args) {
		new Aright().run();
	}

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);

			rnd = new Random();

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(42);
		}
	}

	String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			String line = in.readLine();

			if (line == null) {
				return null;
			}

			st = new StringTokenizer(line);
		}

		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}