#include int NextPoworOfTwo(unsigned int val) { unsigned int mask = 0x80000000; if(val & mask) return 0; val <<= 1; while(!(val & mask)) { mask >>= 1; } return mask; } int BitCount(unsigned int val) { int count = 0; while(val) { count += val & 1; val >>= 1; } return count; } int main() { int ret; int n; std::cin >> n; int n2 = (BitCount(n) == 1)? n:NextPoworOfTwo(n); ret = n2 - n; while(n2 > 1) { n2 /= 2; ret++; } std::cout << ret << std::endl; return 0; }