import java.util.Scanner; class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); sub s = new sub(); int goal = sc.nextInt(); int num = 1,cnt = 0; boolean[] flug = new boolean [goal]; flug[0] = true; while(num < goal) { int t = s.counter(num); if(t + num > goal) {//ゴールを超える場合 num -= t; }else { num += t; } if(flug[num - 1] == true) {//同じところに2回訪れたら到達不可能 System.out.println(-1); return; }else { flug[num - 1] = true; } cnt++; } System.out.println(cnt + 1); } } class sub{ int counter(int num) { int count = 0; for(int i = num ; i > 0 ; i = i / 2) { if(i % 2 == 1) count++; } return count; } }