Little Elephant and Bits

CodeForces - 258A