def countBits(value):
 assert (0 <= value)
 count = 1
 bits = 1
 while ((1 << bits) <= value):
  count += bits
  value >>= bits
  bits <<= 1
 while (2 <= value):
  if (bits != 1):
   bits >>= 1
  else:
   bits -= 1
  while ((1 << bits) <= value):
   count += bits
   value >>= bits
 return count

def countBits ( value ) : assert ( 0 <= value ) count = 1 bits = 1 while ( ( 1 << bits ) <= value ) : count += bits value >>= bits bits <<= 1 while ( 2 <= value ) : if ( bits != 1 ) : bits >>= 1 else : bits -= 1 while ( ( 1 << bits ) <= value ) : count += bits value >>= bits return count
count number of bits needed to store a integer number .