#P6426. Kangaroo Game on Number Line

    ID: 19640 Type: Default 1000ms 256MiB

Kangaroo Game on Number Line

Kangaroo Game on Number Line

There are three kangaroos playing on a number line in a desert. Each kangaroo occupies a distinct integer point. In each move, one of the kangaroos that is not the middle one jumps into a space between the other two kangaroos, ensuring that no two kangaroos ever occupy the same position.

Your task is to maximize the number of moves the kangaroos can make. It can be shown that the maximum number of moves is given by:

moves=max{(ba1),(cb1)}\text{moves} = \max\{(b-a-1),\,(c-b-1)\}

where \(a\), \(b\), \(c\) are the positions of the kangaroos sorted in increasing order.

inputFormat

The input consists of a single line containing three distinct integers separated by spaces, representing the positions of the kangaroos on the number line.

outputFormat

Output a single integer representing the maximum number of moves the kangaroos can make.

sample

2 5 8
2