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

public class Solver {

    StringTokenizer st;
    BufferedReader in;
    PrintWriter out;

    public static void main(String[] args) throws NumberFormatException, IOException {
        Solver solver = new Solver();
        solver.open();
        solver.solve();
        solver.close();
    }

    public void open() throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
    }

    public String nextToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

    public int nextInt() throws NumberFormatException, IOException {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws NumberFormatException, IOException {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws NumberFormatException, IOException {
        return Double.parseDouble(nextToken());
    }
    
    long[][] mul(long[][] a,long[][] b){
        int m = a.length;
        int n = a[0].length;
        int q = b[0].length;
        
        long[][] result = new long[m][q];
        
        for(int i=0;i<m;i++)
            for(int j=0;j<q;j++)
                for(int k=0;k<n;k++)
                    result[i][j] +=  a[i][k]*b[k][j];
        
        return result;
    }
    
    long[][] binpow (long[][] a, int n) {
        long[][] result= new long[a.length][a.length];
        
        for(int i=0;i<a.length;i++)
            result[i][i] = 1;
        
        while (n>0)
            if ((n & 1)==1) {
                result = mul(result, a);
                n--;
            }
            else {
                a = mul(a,a);
                n /= 2;
            }
        return result;
    }

    public void solve() throws NumberFormatException, IOException {
        int k = nextInt();
        int b = nextInt();
        int n = nextInt();
        int t = nextInt();
        
        long[][] start = new long[2][1];
        start[0][0] = t;
        start[1][0] = 1;
        
        long[][] muller = new long[2][2];
        muller[0][0] = k;
        muller[0][1] = 0;
        muller[1][0] = b;
        muller[1][1] = 1;
        
        long[][] tmp = binpow(muller, n);
        
        long z = tmp[0][0]+tmp[1][0];
        
        int l = 0;
        int r = n;
        
        while (l<r){
            int c = (r+l)/2;
            long[][] tmp2 = binpow(muller,c);
            long z2 = t*tmp2[0][0]+tmp2[1][0];
            if (z2>=z){
                r = c;
            }else{
                l = c+1;
            }
        }
        out.println(l);
    }

    public void close() {
        out.flush();
        out.close();
    }

}