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);
}
}
}