#include<iostream> using namespace std; int ans,num,i; int main(){ while(cin>>num&&num){ for(i=1;i*i<num;i*=2){ if(num%i!=0) break; } cout<<i/2<<endl; } return 0; }