import java.util.Arrays; import java.util.Scanner; public class Main { @SuppressWarnings("resource") public static void main(String args[]) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); dp = new int[n + 1]; Arrays.fill(dp, 100000000); dp[1] = 1; dfs(1,n); if(dp[n]==100000000) { System.out.println(-1); return; } System.out.println(dp[n]); } static int dp[]; private static void dfs(int i,int n) { if(i==n) { return; } int cnt=cntOnes(i); if (i + cnt <= n) { if(dp[i]+1= 1) { if(dp[i]+1 0; i /= 2) { if (i % 2 == 1) cnt++; } return cnt; } }