#include <iostream>
using namespace std;
int solution(int n) {
int cur = 0;
int max = cur;
while (n > 0 && n % 2 == 0)
{
n /= 2;
}
while (n > 0)
{
if (n % 2 == 1)
{
max = std::max(max, cur);
cur = 0;
}
else
{
cur++;
}
n /= 2;
}
return max;
}
int main() {
cout << solution(1041) << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IHNvbHV0aW9uKGludCBuKSB7CglpbnQgY3VyID0gMDsKCWludCBtYXggID0gY3VyOwoJd2hpbGUgKG4gPiAwICYmIG4gJSAyID09IDApCgl7CgkJbiAvPSAyOwoJfQoKCXdoaWxlIChuID4gMCkKCXsKCQlpZiAobiAlIDIgPT0gMSkKCQl7CgkJCW1heCA9IHN0ZDo6bWF4KG1heCwgY3VyKTsKCQkJY3VyID0gMDsKCQl9CgkJZWxzZQoJCXsKCQkJY3VyKys7CgkJfQoJCW4gLz0gMjsKCX0KCglyZXR1cm4gbWF4Owp9CgppbnQgbWFpbigpIHsKCWNvdXQgPDwgc29sdXRpb24oMTA0MSkgPDwgZW5kbDsKCXJldHVybiAwOwp9