#!/bin/python3

import math
import os
import random
import re
import sys

def binary(n):
    converted = bin(n)
    counter = 0
    total = []
    for i in range(2,len(converted)):
        if converted[i] == '1':
            counter += 1    
        else:
            total.append(counter)
            counter = 0
    total.append(counter)
    return max(total)
if __name__ == '__main__':
    n = int(input())

print(binary(n))
