import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner kb = new Scanner(System.in);
String a = kb.next();
String b = kb.next();
int count = 1;
while(!a.equals(b)) {
if(Integer.parseInt(a)>Integer.parseInt(b)) {
break;
}
char last = b.charAt(b.length()-1);
if(last == '1') {
b = b.substring(0, b.length()-1);
count++;
}else if(Integer.parseInt(b)%2 ==0) {
int pro = Integer.parseInt(b)/2;
b = String.valueOf(pro);
count++;
}else {
break;
}
}
if(!a.equals(b)) {
System.out.println("-1");
}else {
System.out.println(count);
}
}
}
'공부기록 > 백준' 카테고리의 다른 글
[백준] 10716번 숫자 카드 2 (0) | 2024.02.07 |
---|---|
[백준] 1010번 다리 놓기 (1) | 2024.02.07 |
[백준] 1439번 뒤집기 (0) | 2024.02.05 |
[백준] 1541번 잃어버린 괄호 (0) | 2024.02.05 |
[백준] 12931번 두 배 더하기 (0) | 2024.02.05 |