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

public class Main
	{
	public static void main(String args[]) throws IOException
		{
		Scanner c=new Scanner(System.in);
		long k=c.nextLong();
		long b=c.nextLong();
		long n=c.nextLong();
		long t=c.nextLong();
		boolean gr=false;
		long ini=1;
		for(int i=0;i<n;i++)
			{
			ini=k*ini+b;
			if(ini>t)
				{
				gr=true;
				break;
				}
			}
		if(!gr)
			{
			System.out.println("0");
			return;
			}
		if(k==1)
			{
			long total=1+b*n;
			long required=1+b*n-t;
			if(required%b==0)
				System.out.println(required/b);
			else
				System.out.println(required/b+1);
			}
		else
			{
			int time=0;
			long qty=1;
			while(qty<=t)
				{
				qty=k*qty+b;
				time+=1;
				}
			if(qty==t)
				System.out.println(n-time);
			else
				System.out.println(n-time+1);
			}
		}
	}

//must declare new classes here
