#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include <bits/stdc++.h>
#include <vector>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define int         long long
#define ll          long long
#define ld	    long double
#define pb          push_back
#define pp	    pop_back()
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define mp          make_pair
#define fi           first
#define se           second
#define sz(x)       (ll)x.size()
#define fl(i,a,n)         for(ll i=a;i<n;i++)
#define bl(i,a,n)     for(ll i=n-1;i>=a;i--)
#define GCD(m,n) __gcd(m,n)
#define all(v)    v.begin(),v.end()
signed main()
{ios_base::sync_with_stdio(false);
cin.tie(NULL);
ld k,b,n,c,d,t;
cin>>k>>b>>n>>t;
if(t==1)cout<<(ll)n<<endl;
else if(k>1)
{
	c=n*log10(k)+log10(k-1+b)-log10(k*t-1-b);
	c=c/log10(k);
	ll e=(ll)c;
//	cout<<c<<endl;
	if(e<abs(c))e++;
	e=max(e,(ll)0);
	cout<<e<<endl;
}
else
{
	c=1+n*b-t;
	c=c/b;
	ll e=(ll)c;
	if(e<abs(c))e++;
	e=max(e,(ll)0);
	cout<<e<<endl;
}
return 0;
}