import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.*;


public class C
{
	BufferedReader in;
	PrintStream out;
	StringTokenizer tok;
	public C() throws NumberFormatException, IOException
	{
		in = new BufferedReader(new InputStreamReader(System.in));
		//in = new BufferedReader(new FileReader("in.txt"));
		out = System.out;
		run();
	}
	void run() throws NumberFormatException, IOException
	{
		long k = nextInt(),b= nextInt(),n= nextInt(),t= nextInt();
		int w = 0;
		long h = 1;
		while(t >= h)
		{
			h = h*k + b;
			w++;
		}
		w--;
		if(n-w<=0)out.println(0);
		else out.println(n- w);
	}
	public static void main(String[] args) throws NumberFormatException, IOException 
	{
		new C();
	}
	String nextToken() throws IOException
	{
		if(tok ==null || !tok.hasMoreTokens()) tok = new StringTokenizer(in.readLine());
		return tok.nextToken();
	}
	int nextInt() throws NumberFormatException, IOException
	{
		return Integer.parseInt(nextToken());
	}
	long nextLong() throws NumberFormatException, IOException
	{
		return Long.parseLong(nextToken());
	}
	double nextDouble() throws NumberFormatException, IOException
	{
		return Double.parseDouble(nextToken());
	}
}
