import java.io.*; import java.util.Arrays; class Main{ public static void main(String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String line=""; int[] dp=new int[10001]; int now=1; int count; Arrays.fill(dp,-1); dp[1]=1; while(true){ count=0; String val2=Integer.toBinaryString(now); for(int i=0;i10000){ break; } dp[now+count]=dp[now]+1; now+=count; } while((line=br.readLine())!=null){ int n=Integer.parseInt(line); System.out.println(dp[n]); } } }