#include<cstdio>
#include<cstring>
#include<cmath>
typedef __int64 LL;
const double eps=1e-8;

double Fabs(double x){
    return x>0?x:(-x);
}

int main(){
    LL k,b,n,t;
    while(scanf("%I64d%I64d%I64d%I64d",&k,&b,&n,&t)!=EOF){
        LL ans;
        if(k==1){
            ans=n+(1-t)/b;
        }
        else{
            double x=log((1.0-(double)k-(double)b)/((double)t*(1.0-(double)k)-(double)b));
            double y=x/log((double)k);
            LL z=(LL)(y+n);
            ans=z;
        }
        if(ans<0) ans=0;
        printf("%I64d\n",ans);
    }
    return 0;
}