#T129. 抓住那头牛

抓住那头牛

Description

A farmer knows the location of a cow and wants to catch it. Both the farmer and the cow are on a number line. The farmer starts at point N (0 ≤ N ≤ 100000), and the cow is located at point K (0 ≤ K ≤ 100000).

The farmer has two ways to move:

  1. Move from X to X-1 or X+1, each move takes one minute.
  2. Move from X to 2*X, each move takes one minute.
    Assume the cow is unaware of the farmer's actions and remains stationary.

What is the minimum time the farmer needs to catch the cow?

Input Format

Two integers, N and K.

Output Format

An integer representing the minimum minutes required for the farmer to catch the cow.

5 17

4