Minimal Popcount

5

3 votes
Mathematics, Approved, Simple-math, Easy-Medium, Mathematics, Mathamatics
Problem

Let pop(n) is number ones n have in binary. For example, pop(11)=pop(10112)=3.

For integer d, define f(d)=minn0pop(n(n+d)).
Here denotes binary XOR.
You are given d in binary, find f(d).

Input Format:
Single line contains binary representation of d without leading zeroes.

Output Format:
One integer in decimal numeral system -- f(d).

Constraints:
1d<2200,000.
50 points
1d<240.

Sample Input
11
Sample Output
2
Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

Here d=112=3.

Contributers:
Editor Image

?