import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = Integer.valueOf(scan.nextLine().trim());
        int ans = 0;
        int acc = 0;
        int sign = 0;
        while (num != 0) {
            if (num % 2 == 0) {
                if (sign == 1) {
                    sign = 0;
                    ans = Math.max(ans, acc);
                    acc = 0;
                }
            } else {
                if (sign == 0) {
                    sign = 1;
                }
                acc++;
            }
            num /= 2;
        }
        ans = Math.max(ans, acc);
        System.out.println(ans);
    }
}