#include<bits/stdc++.h> using namespace std; int a; int main(){ while(cin>>a,a){ int t=1; while(a%2==0) a/=2,t*=2; cout<<t<<endl; } return 0; }