import java.util.*; public class T03 { static int opera(int c, int X, int Y) { if (c == 12) return 1000; else if (X == Y) return c; else { return Math.min(opera(c + 1, Y, X), opera(c + 1, X + Y, X - Y)); } } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int X = sc.nextInt(); int Y = sc.nextInt(); int ans = opera(0, X, Y); if (ans == 1000) ans = -1; System.out.println(ans); } }