This page is still under construction.

Parts of this page are still being built. What you see may change.

Three Kangaroos 2

Time limit1sMemory limit256 MB

Summary
Three kangaroos on integer points let an outer one jump between the other two, and each test case asks for the largest possible number of jumps.
Level

Easy2 of 10

Topics
Greedy, Math
Solved
No attempts yet

Problem

Three kangaroos play in a desert. The desert holds one number line, and the three kangaroos sit on three different integer coordinates.

In one move, one of the two outer kangaroos jumps to an integer coordinate between the other two kangaroos. Two or more kangaroos can never sit on the same coordinate.

Find the largest number of moves the kangaroos can make.

Input

The input holds several test cases. Each line gives the starting positions AA, BB, CC of the three kangaroos. (0<A<B<C<1000 < A < B < C < 100)

The number of test cases is not given. Read until the end of the input.

Output

For each test case, print the largest number of moves the kangaroos can make, one per line.

Examples2

  1. Example 1

    Input
    2 3 5
    3 5 9
    
    Expected output
    1
    3
    
  2. Example 2

    Input
    1 2 3
    1 98 99
    
    Expected output
    0
    96