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

public class C {
	private static void solve() throws IOException {
		long k = nextInt();
		long b = nextInt();
		long n = nextInt();
		long t = nextInt();
		long z = 1;
		for(int i = 0; i < n; i++) {
			z = z * k + b;
			if(z > t) {
				out.println(n - i);
				
				return;
			}
		}
		out.println(0);
	}
	
	
	public static void main(String[] args) {
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(239);
		}
	}

	static BufferedReader br;
	static StringTokenizer st;
	static PrintWriter out;

	static String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			String line = br.readLine();
			if (line == null) {
				return null;
			}
			st = new StringTokenizer(line);
		}
		return st.nextToken();
	}

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

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

	static double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}
class Pair {
	int f;
	int s;
	Pair(int f, int s) {
		this.f = f;
		this.s = s;
	}
}