International Programming Contest

April 19, 2003, Blagoevgrad, Bulgaria

Sponsored by STEMO  

 

Task B. Parallelepiped

 

A solid parallelepiped with integer lengths of its dimensions is given. We can saw up it using a sharp blade to make a whole plane cut along any one of the three possible dimensions of the parallelepiped. Find the minimal number of cuts necessary to obtain only unit cubes as a final result. During the process of cutting, it is allowed to move some parts, so that when is appropriate, they might be sawn up together by a single cut.

 

Input

Your program B.EXE should read a sequence of lines, each containing three positive integers, separated by a space. These integers are dimensions of a subsequent given parallelepiped. Their values are less than 1018. A digit 0 on a single line denotes the end of the input.

 

Output

For each triple in the input, your program should output on a separate line the required answer.

 

Sample Input

2 2 2

4 1 1

0

 

Sample Output

3

2