import java.util.*;

public class Bacteria{
	public static int solve(int k, int b, int n, int t){
		if( k == 1 ){
		//	System.out.println(n-(double)(t-1)/b);
		//	System.out.println(Math.ceil(2));
			int x = (int)Math.ceil(n-(double)(t-1)/b);
			return (x < 0) ? 0 : x;
		}
		
		long key = (long)(-1+k)*t+b;
	//	System.out.println(key);
		long temp = -1+k+b;
		int ans = 0;
	//	System.out.println(temp + " " + key);
		while( temp <= key ){
			temp *= k;
			ans++;
		//	System.out.println(temp + " " + key);
		}
		return (n+1-ans < 0 ) ? 0 : n+1-ans;
	}
	
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int k = stdIn.nextInt();
		int b = stdIn.nextInt();
		int n = stdIn.nextInt();
		int t = stdIn.nextInt();
		
		System.out.println(solve(k, b, n, t));
	}
}