import java.util.Scanner; import java.util.ArrayList; public class Exercises16{ public static void main (String[] args){ Scanner sc = new Scanner(System.in); int goal = sc.nextInt(); int carol = 1; int bitCount = 0; int count = 1; ArrayList blocks = new ArrayList(); blocks.add(carol); while (carol != goal){ bitCount = 0; int carolPresent = carol; while (carolPresent != 0){ if (carolPresent % 2 == 1){ bitCount++; } carolPresent /= 2; } if (carol + bitCount > goal){ carol -= bitCount; }else{ carol += bitCount; } if (blocks.indexOf(carol) != -1){ System.out.println(-1); return; }else{ blocks.add(carol); } count += 1; } System.out.println(count); } }