import java.util.Arrays; import java.util.LinkedList; import java.util.Scanner; public class Main { public static int solve(int X, int Y){ if(X == Y){ return 0; }else if(Y == 0){ // (X, 0) -> (X, X) return 1; }else if(X == 0){ // (0, Y) -> (Y, 0) return 1 + solve(Y, 0); }else if(Math.abs(X) != Math.abs(Y)){ return -1; }else{ return solve(X + Y, X - Y); } } public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int X = sc.nextInt(); final int Y = sc.nextInt(); System.out.println(solve(X, Y)); } }