#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;
}