In a nation split into three kingdoms—Alice, Bob, and Charlie—each controls a portion of the land.
The total area of this nation is represented by $N$, where $N \ge 6$. The kingdoms hold the following amounts of land in integer units:
Alice has $A$ units, Bob has $B$ units, and Charlie has $C$ units. It is known that $A$, $B$, and $C$ are distinct integers, with $A > B > C > 0$.

Peace can only be maintained if the difference in power between the kingdoms is minimized. This difference is expressed as $D$, where: $$ D = (A - B) + (B - C) $$ Your goal is to write a program that, given the total area $N$, finds the minimum possible value of $D$.

Input

A single integer $N$, representing the total area of the nation.

Output

A single integer $D$, representing the minimum power difference between the three kingdoms.

Constraints

For all test cases: $6 \le N \le 10^9$
Subtask 1 (20%): $6 \le N \le 10$
Subtask 2 (30%): $N$ is divisible by $3$
Subtask 3 (50%): No addtional constraints

Sample Test Cases

Input Output
12 2
When the total area $N$ is $12$, the minimum difference $D$ is $2$, where Alice controls $5$ units, Bob controls $4$ units, and Charlie controls $3$ unit.
Click to copy.

Scoring: Per Subtask
Authored by hclee
Appeared in 2024 Wah Yan Interschool Olympiad in Informatics 🤯🥷⚡🧠🏆