import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Solution to Dividing by Two
 * 
 * @author vanb
 */
public class dividing_vanb
{
    /** Input. */
    private static Scanner sc;
    
    /** Output. */
    private static PrintStream ps;
    
    /**
     * Do it!
     */
    private void doit()
    {
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        int answer = 0;
        
        // If a is larger than b, we've got to divide by 2 until it's smaller (or equal)
        while( a>b )
        {
            // If a is odd, we've got to add 1 to make it even
            if( a%2==1 )
            {
                ++answer;
                ++a;
            }
            
            // Now, divide by 2
            a /= 2;
            ++answer;
        }
        
        // If a<=b, then we've got to add 1 until a=b. 
        // That's adding 1 a total of b-a times.
        answer += b-a;
        
        ps.println( answer );
    }
        
    /**
     * Main.
     * 
     * @param args unused
     * @throws Exception
     */
    public static void main( String[] args ) throws Exception
    {
        sc = new Scanner( System.in );
        ps = System.out;
        
        new dividing_vanb().doit();
    }

}
