#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
 
bool check(ll k)
{
    ll l=2,r=1e9,t;
    while(l<=r){
        ll mid = (l+r)>>1;
        if(mid*(mid-1)<=k) l=mid+1,t=mid;
        else r=mid-1;
    }
    ll w = log2(t);
    return w*12345<t-1;
}
 
int main()
{
    fastio();
    ll L=1,R=1e17,ans;
    while(L<=R){
        ll mid = (L+R)>>1;
        if(check(mid)) ans=mid,R=mid-1;
        else L=mid+1;
    }
    cout<<ans<<endl;
    // Integer partition equations
    // 44043947822
    return 0;
}