import java.io.*;
import java.util.*;

public class Main {
  BufferedReader br;
  long k, b, t, z;
  int n;

  public void go() throws Exception {
    br = new BufferedReader(new InputStreamReader(System.in));
    String[] ss = br.readLine().split(" ");
    k = Long.parseLong(ss[0]);
    b = Long.parseLong(ss[1]);
    n = Integer.parseInt(ss[2]);
    t = Long.parseLong(ss[3]);
    
    z = 1l;
    
    if (t == 1l) {
      System.out.println(n);
      return;
    }

    for (int i = 1; i <= n; i++) {
      z = k * z + b;
      if (z == t) {
        System.out.println(n - i);
        return;
      }
      else if (z > t) {
        System.out.println(n - i + 1);
        return;
      }
    }
    
    System.out.println("0");
  }
  
  public static void main(String[] args) throws Exception {
    new Main().go();
  }
}
