A - Arithmetic Sequence Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 300

問題文

3 項からなる整数列 A = (A_1, A_2, A_3) が与えられます。あなたはこの数列に対して、次の操作を何回でも行うことができます:

  • i\in \{1,2,3\} をひとつ選び、A_i1 を加える。

数列 A を等差数列にするために必要な操作回数の最小値を求めてください。ただし、数列 A = (A_1, A_2, A_3) が等差数列であるとは、A_2 - A_1 = A_3 - A_2 が成り立つことを意味します。

制約

  • 1\leq A_1, A_2, A_3\leq 10^{15}

入力

入力は以下の形式で標準入力から与えられます。

A_1 A_2 A_3

出力

答えを出力してください。


入力例 1

4 8 10

出力例 1

2

i = 1i = 3 に対して 1 回ずつ操作を行うと、等差数列 (5, 8, 11) が得られます。


入力例 2

10 3 4

出力例 2

4

i = 2 に対して 4 回の操作を行うと、等差数列 (10, 7, 4) が得られます。


入力例 3

1 2 3

出力例 3

0

数列 A ははじめから等差数列なので、最小の操作回数は 0 回となります。


入力例 4

1000000000000000 1 1000000000000000

出力例 4

999999999999999

Score : 300 points

Problem Statement

Given is a sequence of three integers A = (A_1, A_2, A_3). On this sequence, you can do the following operation any number of times:

  • choose i\in \{1,2,3\} and add 1 to A_i.

Find the minimum number of operations needed to make A arithmetic. Here, the sequence A = (A_1, A_2, A_3) is arithmetic when A_2 - A_1 = A_3 - A_2 holds.

Constraints

  • 1\leq A_1, A_2, A_3\leq 10^{15}

Input

Input is given from Standard Input in the following format:

A_1 A_2 A_3

Output

Print the answer.


Sample Input 1

4 8 10

Sample Output 1

2

One operation with i = 1 and then one operation with i = 3 yield an arithmetic sequence (5, 8, 11).


Sample Input 2

10 3 4

Sample Output 2

4

Four operations with i = 2 yield an arithmetic sequence (10, 7, 4).


Sample Input 3

1 2 3

Sample Output 3

0

The sequence A is already arithmetic from the beginning, so we need zero operations.


Sample Input 4

1000000000000000 1 1000000000000000

Sample Output 4

999999999999999