#P1588. Catch the Cow

    ID: 14874 Type: Default 1000ms 256MiB

Catch the Cow

Catch the Cow

FJ has lost his cow and is determined to catch it. Both FJ and his cow are on a straight line with initial positions given by \(x\) and \(y\) respectively, where the cow remains stationary. FJ moves in a peculiar way: in each step, he can either move one step forward (\(x+1\)), move one step backward (\(x-1\)), or jump directly to position \(2 \times x\). Your task is to determine the minimum number of steps required for FJ to catch his cow.

inputFormat

The input consists of a single line containing two integers \(x\) and \(y\), separated by a space.

outputFormat

Output a single integer representing the minimum number of steps required for FJ to catch his cow.

sample

5 17
4