π‘νμ΄λ°©μ
2 μ 162κ° μ£Όμ΄μ‘μ κ²½μ° λ€μμλΆν° μ°μ°μ μμν΄λ³΄λ©΄
162 <= 81 -> 81 <= 8 -> 8 <= 4 -> 4 <= 2
λ€μκ³Ό κ°μ κ²°κ³Όλ₯Ό μ»μ μ μλ€.
public static void main(String[] args) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(bf.readLine());
int a = Integer.parseInt(st.nextToken());
int b = Integer.parseInt(st.nextToken());
boolean stop = true;
int cnt = 0;
while (stop){
if (b%10==1){
b /= 10;
cnt++;
}else if (b%2 == 0){
b /= 2;
cnt++;
}else{
cnt =-1;
stop = false;
}
if (b == a){
stop = false;
cnt++;
}else if (b < a){
cnt =-1;
stop = false;
}
}
System.out.println(cnt);
}