N=int(input()) k=1 while k<64: a,s,i,k=[1],1,0,k+1 while sk-2 else 0),i+1 if s==N:break print([k,-1][s>N])