import java.util.Scanner;

public class C {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long k = sc.nextLong();
        long b = sc.nextLong();
        long n = sc.nextLong();
        long t = sc.nextLong();
        if (k==1) {
            long ans = (n*b-t+1) / b;
            if ((n*b-t+1) % b != 0)
                ans++;
            System.out.println(Math.max(ans, 0));
            return;  
        }
        long A = b+t*(k-1), B = b+k-1;
        long pow_k = 1;
        for (int i = 1; ;i++) {
            pow_k *= k;
            if (pow_k * B > A) { 
                System.out.println(Math.max(0, n-i+1));
                return;
            }
        }
    }
}
