/**
 * 
 * <p>
 * Solved - math
 * </p>
 * <p>
 * Created on Jun 22, 2012, 11:55:52 AM
 * </p>
 * @Author Andy Y.F. Huang
 */
public class p199CAboutBacteria {
  private Input in;
  private Output out;

  void solve() {
    in = new Input();
    out = new Output();
    solve(1);
    out.print();
  }

  void solve(int test_number) {
    int k = in.nextInt();
    int b = in.nextInt();
    int n = in.nextInt();
    int t = in.nextInt();
    long cur = 1;
    int cnt = 0;
    while (cur <= t) {
      cnt++;
      cur = k * cur + b;
    }
    out.appendln(Math.max(0, n - cnt + 1));
  }

  public static void main(String[] args) {
    p199CAboutBacteria solver = new p199CAboutBacteria();
    solver.solve();
  }

  static void pln(Object... obj) {
    pf(obj);
    System.out.println();
  }

  static void pf(Object... obj) {
    for (int i = 0; i < obj.length; i++) {
      if (i != 0)
        System.out.print(' ');
      System.out.print(obj[i]);

    }
  }
}

final class Input {
  private java.io.BufferedReader reader;
  private java.util.StringTokenizer tokenizer;
  private final String filename;
  private static final String k_default_filename = "input.txt";

  Input() {
    filename = k_default_filename;
    if (new java.io.File(filename).exists()) {
      try {
        System.setIn(new java.io.FileInputStream(filename));
      }
      catch (java.io.FileNotFoundException e) {
        throw new RuntimeException(e);
      }
    }
    reader = new java.io.BufferedReader(
        new java.io.InputStreamReader(System.in));
    tokenizer = new java.util.StringTokenizer("");
  }

  Input(String filename) {
    this.filename = filename;
    try {
      reader = new java.io.BufferedReader(new java.io.FileReader(this.filename));
    }
    catch (java.io.FileNotFoundException e) {
      throw new RuntimeException(e);
    }
    tokenizer = new java.util.StringTokenizer("");
  }

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

  String nextLine() {
    try {
      return reader.readLine();
    }
    catch (java.io.IOException e) {
      throw new RuntimeException(e);
    }
  }

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

  int nextInt() {
    return Integer.parseInt(next());
  }

  double nextDouble() {
    return Double.parseDouble(next());
  }

}

final class Output {
  private StringBuilder buffer;
  private final String filename;
  private static final String k_default_filename = "output.txt";

  Output(String filename) {
    this.filename = filename;
    try {
      System.setOut(new java.io.PrintStream(new java.io.FileOutputStream(
          this.filename)));
    }
    catch (java.io.FileNotFoundException e) {
      throw new RuntimeException(e);
    }
    buffer = new StringBuilder(1 << 16);
  }

  Output() {
    filename = k_default_filename;
    if (new java.io.File(filename).exists()) {
      try {
        System.setOut(new java.io.PrintStream(new java.io.FileOutputStream(
            filename)));
      }
      catch (java.io.FileNotFoundException e) {
        throw new RuntimeException(e);
      }
    }
    buffer = new StringBuilder(1 << 16);
  }

  void print() {
    System.out.print(buffer.toString());
  }

  void flush() {
    System.out.flush();
  }

  void append(Object... obj) {
    for (int i = 0; i < obj.length; i++) {
      if (i != 0)
        buffer.append(' ');
      buffer.append(obj[i]);
    }
  }

  void appendln(Object... obj) {
    append(obj);
    buffer.append('\n');
  }

}