import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskC {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        long k = in.nextLong();
        long b = in.nextLong();
        long n = in.nextLong();
        long t = in.nextLong();
        int answer;
        if (k == 1)
            answer = Math.max(0, (int) (n - (t - 1) / b));
        else {
            double c1 = -(t * (1 - k) - b);
            double c2 = -(1 - k - b);
            double cc = -(Math.log(c2) - Math.log(c1)) / Math.log(k);
            answer = Math.max(0, (int) (n - (int) (cc + 1e-10)));
        }
        out.println(answer);
    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }
}
