
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class C
{
    public static BufferedReader br;
    public static StringTokenizer inp;
    public static PrintWriter out;
    public static void main(String[] args)  throws IOException
    {

        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        read();
        
        long k = nextInt();
        long b = nextInt();
        long n = nextInt();
        long t = nextInt();
//      if(t==1)
//      {
//          out.println(n);
//      }
//      else
            {
            long kp = 1;
            for(; n>=0&&t-kp>=0; n--)
            {
                t-=b*kp;
                kp*=k;
            }
            out.println(n+1);
        }
//      long z=0;
//      long kp=1;;
//      for(int i = 0 ; i < n ; i++)
//      {
//          z+=kp*b;
//          kp*=k;
//      }
//      z+=kp;
//      long z2;
        
        
        br.close();
        out.close();
    }
    
    public static void read() throws IOException{inp = new StringTokenizer(br.readLine());}
    public static int nextInt(){return Integer.parseInt(inp.nextToken());}
    public static long nextLong(){return Long.parseLong(inp.nextToken());}
    public static double nextDouble(){return Double.parseDouble(inp.nextToken());}
    public static String next(){return inp.nextToken();}
    
}
