/*
ID: sunits789
LANG: JAVA
TASK: C125
*/
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.InputStream;


public class C125 {
        public static void main(String[] args) {
                InputStream inputStream = System.in;
                OutputStream outputStream = System.out;
                InputReader in = new InputReader(inputStream);
                PrintWriter out = new PrintWriter(outputStream);
                CodeC125 solver = new CodeC125();
                int x=solver.solve(1, in, out);
                out.close();
        }
}

class CodeC125
{
public int solve(int testNumber, InputReader in, PrintWriter out)
{
	int k=in.nextInt();
	int b=in.nextInt();
	int n=in.nextInt();
	int t=in.nextInt();
	long pow[]=new long[100];
	pow[0]=1;
	if(k==1)
	{
		long z=(long)1+(long)n*(long)b;
		z-=(long)t;
		long ans=z/(long)b;
		// out.println(ans);
		if(z%(long)b!=0)
		{
			ans++;
		}
		if(ans>0)
		{
			out.println(ans);
		}
		else
		{
			out.println(0);
		}
		return 0;
	}
	for(int i=1;i<100;i++)
	{
		pow[i]=pow[i-1]*(long)k;
		// out.println(pow[i]);
	}
	int ans=n;
	long sum=0;
	for(int i=0;i<100;i++)
	{
		int m=(n-i);
		ans=m;
		if(i>0)
		{
			sum+=pow[i-1];
		}
		long check=(long)b*sum+pow[i];
		// out.println(check);
		if(check>=(long)t)
		{
			i=100;
			if(check>(long)t)
			{
				ans++;
			}
		}
	}
	if(ans>0)
	{
		out.println(ans);
	}
	else
	{
		out.println(0);
	}
	return 0;
	
}

}






class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }
	public void inputShuffleArrayInt(int arr[])
	{
		int l=arr.length;
		for(int i=0;i<l;i++)
		{
			if(i%2==0)
			{
				arr[i/2]=nextInt();
			}
			else
			{
				arr[l-((i+1)/2)]=nextInt();
			}
		}
	}

    }