void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  
  long n; rd(n);
  foreach(m; 0..100005){
    if((n&m)!=m){
      writeln(m);
      return;
    }
  }
  
  assert(true);
  
}

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));
  }
}