#include<stdio.h>

int max(int x,int y,int z)
{
    if(x>=y&&x>=z) return x;
    if(y>=x&&y>=z) return y;
    if(z>=x&&z>=y) return z;
    return 0;
}

int max_cross_subarray(int arr[],int low,int mid,int high)
{
    int i,j;
    for(i=mid; i>=low; i--)
    {
        if(arr[i] == 0) break;
    }
    i = i + 1;
    for(j=mid+1;j<=high;j++)
    {
        if(arr[j] == 0) break;
    }
    j = j-1;
    return j-i +1;
}

int max_subarray(int arr[],int low,int high)
{
    int mid;
    int left,right,crossLr;
    if(high == low)
    {
        if(arr[low] == 1)
            return 1;
        else return 0;
    }else {
        mid = (low + high)/2;
        left = max_subarray(arr, low, mid);
        right = max_subarray(arr, mid+1, high);
        crossLr = max_cross_subarray(arr, low, mid, high);
        return max(left, right, crossLr);
    }
}

int main()
{
    int arr[32] = {0};
    int num;
    int i;
    while(EOF != scanf("%d",&num))
    {
        arr[31] = num&1;
        for(i=30;i>=0;i--)
        {
            num = num>>1;
            arr[i]=num&1;
        }
        printf("%d\n",max_subarray(arr, 0, 31));
    }
    
    return 0;
}