

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

public class Main
{
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer tokenizer=null;
	
	public static void main(String[] args) throws IOException
	{
		new Main().execute();
	}
	
	void debug(Object...os)
	{
		System.out.println(Arrays.deepToString(os));
	}
	
	int ni() throws IOException
	{
		return Integer.parseInt(ns());
	}
	
	long nl() throws IOException 
	{
		return Long.parseLong(ns());
	}
	
	double nd() throws IOException 
	{
		return Double.parseDouble(ns());
	}
		
	String ns() throws IOException 
	{
		while (tokenizer == null || !tokenizer.hasMoreTokens()) 
			tokenizer = new StringTokenizer(br.readLine());
		return tokenizer.nextToken();
	}
	
	String nline() throws IOException
	{
		tokenizer=null;
		return br.readLine();
	}
		
	

	//Main Code starts Here
	int totalCases, testNum;	
	long k,b,n,a;

	void execute() throws IOException
	{
		totalCases = 1;
		for(testNum = 1; testNum <= totalCases; testNum++)
		{
			if(!input())
				break;
			solve();
		}
	}

	void solve() throws IOException
	{
		long x = ((k-1)*a + b);
		long ans = 0;
		if(k == 1)
		{
			long al = (1 + b*n - a);
			long bl = b;
			ans = al/bl;
			if(al%bl != 0)
				ans++;
		}
		else
		{
			long y = (k-1+b);// * (long)Math.pow(k,n-i);
			//int mul = 0;
			//ans = n;
			//double nm = x/(double)y;
			int count = 0;
			//debug(nm);
			while(x>=y*k)
			{
				//debug(x,y);
				y = y*k;
				count++;
				
			}
			ans = n-count;
		}
		System.out.println((long)Math.max(0,ans));
		
	}
	//void bs(long a, long b)

	boolean input() throws IOException
	{
		k = nl();
		b = nl();
		n = nl();
		a = nl();
		
		return true;
	}


}


