import java.lang.*;
import java.util.Scanner;

public class Solution
{
    public static void main(String args[])
    {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int b = sc.nextInt();
        int n = sc.nextInt();
        int t = sc.nextInt();
        double x,y,z;
        if(k==1)
        {
            z = 1 + n*1.0*b;
            x = (z-t)/b;
        }
        else
        {
            y = ((k-1)*1.0*t+b)*1.0/(k-1+b); 
            x = n - (Math.log(y)/Math.log(k));
        }
        long ans = (x<0)?0:(long)Math.ceil(x);
        System.out.println(ans);
    }
}