
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class C {

    public static void main(String[] args) throws IOException {
        BufferedReader buf = new BufferedReader(
                new InputStreamReader(System.in));
        String[] line = buf.readLine().split(" ");
        long k = Integer.parseInt(line[0]);
        long b = Integer.parseInt(line[1]);
        long n = Integer.parseInt(line[2]);
        long t = Integer.parseInt(line[3]);
        long x = 1;
        int count = 0;
        for (int i = 1; i <= n; i++) {
            x = k * x + b;
            if (x <= t)
                count++;
            else
                break;
        }
        System.out.println(n - count);
    }
}
