import java.util.Scanner;

public class Main {

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