function Main(input) { var N = input; var binN = parseInt(N, 10).toString(2); var arr = binN.split("").map(Number); var pSum = 1; var count = 0; for (var i = 1; i < arr.length; i++) { pSum *= 2; count += 1; } if (N == pSum) { count += 0; } else if((N - pSum) % 2 == 0 || N - pSum == 1) { count += 1; } else { count += 2; } console.log(count); } Main(require("fs").readFileSync("/dev/stdin", "utf8"));