void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  
  long n; rd(n);
  
  long m=1;
  while(m<n){
    if((n&m)!=m){
      writeln(m);
      return;
    }
    m*=2;
  }
  
  writeln(n+1);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}