#include using namespace std; using ll = long long; using ull = unsigned long long; #define rep(i,a) for(int i=0;i<(a);i++) #define MOD 1000000007 const ll MA=1000000000000000000; int main(){ ll n; cin>>n; set st; ll x=1; while(x<=MA/2){ x*=2; st.insert(x); } ll ans=-1; decltype(st)::iterator it; for(ll i=3;i<=n/2;i++){ it=st.find(i); if(it!=st.end()) continue; it=st.find(n-i); if(it!=st.end()) continue; ans=i; break; } if(ans==-1) cout<<-1<