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

public class AboutBacteria {

	// https://codeforces.com/contest/199/problem/C
	
	public static void main(String[] args) throws IOException, FileNotFoundException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader in = new BufferedReader(new FileReader("AboutBacteria"));

		StringTokenizer st = new StringTokenizer(in.readLine());
		long k = Integer.parseInt(st.nextToken());
		long b = Integer.parseInt(st.nextToken());
		long n = Integer.parseInt(st.nextToken());
		long t = Integer.parseInt(st.nextToken());
		double quot = 0;
		if (k !=1) quot = (double)(k + b - 1)/(double)(t *k + b - t);
		else {
			long ans = (long)Math.ceil((double)(n*b + 1 - t) / (double)b);
			if (ans<0) ans=0;
			System.out.println(ans);
			return;
		}
		
		long m = builtinlog(quot, k) + n;
		if (m < 0) m =0;
		System.out.println(m);
		
	}
	
	public static long builtinlog(double top, long base) {
		return (long)Math.ceil(((double)Math.log(top)/(double)Math.log(base)));
	}
}
