import java.math.BigInteger;
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(ans);
            return;
        }
        long A = b+t*(k-1), B = b+(k-1);
        for (int i = 0; i <= n; i++) {
            if (BigInteger.valueOf(k).pow((int)n-i).multiply(BigInteger.valueOf(B)).compareTo(BigInteger.valueOf(A)) <= 0) {
                System.out.println(i);
                return;
            }
        }
    }
}
