Under construction

Still being built. Things may change

Three Kangaroos

Time limit1sMemory limit128 MB

Summary
Given three sorted integer positions, compute the maximum number of jumps where an outer point can move to any free integer strictly between the other two.
Level

Medium4 of 10

Topics
Math, Greedy, Simulation
Solved
No attempts yet

Problem

Three kangaroos are playing on an integer number line in the desert. They start on three distinct coordinates.

In one move, choose either the leftmost kangaroo or the rightmost kangaroo and make it jump to an empty integer coordinate strictly between the other two kangaroos. Two or more kangaroos may not occupy the same coordinate.

Find the maximum number of moves the kangaroos can make.

Input

The first line contains the initial positions A, B, and C of the three kangaroos, separated by spaces.

0 < A < B < C < 100

Output

Print the maximum number of moves the kangaroos can make.

Examples2

  1. Example 1

    Input
    2 3 5
    
    Expected output
    1
    
  2. Example 2

    Input
    3 5 9
    
    Expected output
    3