void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import core.bitop;

  int n; rd(n);

  int k=1;
  while(k*2<=n) k*=2;

  writeln(max(popcnt(n), popcnt(k-1)));
}


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

