• + 0 comments

    if name == 'main': n = int(input().strip())

    n_bin = bin(n)
    n_bin = bin(n)
    max_consecutive = 0
    count_consecutive1 = 0
    count_consecutive0 = 0
    for i in n_bin:
        if i == '1':
            count_consecutive1 += 1
            if count_consecutive1 > max_consecutive:
                max_consecutive = count_consecutive1
        elif i == '0':
            count_consecutive1 = 0
            count_consecutive0 += 1
            if count_consecutive0 > max_consecutive:
                max_consecutive = count_consecutive0
        else:
            count_consecutive1 = 0
            count_consecutive0 = 0
    
    print(max_consecutive)