import java.util.*; //数字の二進数の1の数を求めるクラス //intは整数型なので、小数点以下は切り捨てられる class Kazu{ int ichi = 0; public int program1(int num){ do{ //numを2で割り切れなかった場合ichiの数を増やしていく if(num%2==1){ ichi = ichi+1; } //numに2で割った後の数を入れる num = num/2; }while(num==0); return ichi; } } class Tasu{ int t_kekka = 0; public int program2(int num,int ichi){ t_kekka = num + ichi; return t_kekka; } } class Hiku{ int h_kekka = 0; public int program3(int num,int ichi){ h_kekka = num - ichi; return h_kekka; } } public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int num = 1; int ichi = 0; int t_kekka = 0; int h_kekka = 0; int flag = 0; int kaisu = 0; do{ kaisu = kaisu + 1; Kazu kz = new Kazu(); ichi = kz.program1(num); Tasu ts = new Tasu(); t_kekka = ts.program2(num,ichi); if(t_kekka==N){ break; }else if(t_kekka>N){ flag = flag + 1; Hiku hk = new Hiku(); h_kekka = hk.program3(num,ichi); num = h_kekka; if(flag==2){ kaisu = -1; } }else if(t_kekka