题目描述
Problem Description
joisino's next job is to assist a designer. Currently, a design for an emblem is being created. The emblem is made through the following steps:
- First, prepare a rectangle of size $ H $ (height) × $ W $ (width).
- At this time, the bottom-left corner is denoted as coordinate $ (0,0) $, and a position that is $ x $ units to the right and $ y $ units up from there is represented as coordinate $ (x,y) $.
- Start drawing a line from coordinate $ (0,0) $ towards coordinate $ (K,H) $ ($ 1 ≦ K < W, K $ is an integer).
- Continue the following actions:
- If the line hits a corner, the design ends there.
- If the line hits an edge that is not a corner, it reflects such that the angle of incidence equals the angle of reflection.
For example, when $ H=3, W=5, K=2 $, the design looks like the figure below. Here, the red lines are the drawn lines, and the dark green lines are only for clarity of the rectangle's size and are not part of the design.

The beauty of the design thus created is equal to the number of intersection points of the lines inside the rectangle. For example, in the figure above, there are $ 2 $ intersection points of the red lines, so the beauty is $ 2 $. The designer has considered candidates for $ H, W, K $, but wants to know the beauty of the design beforehand without actually drawing it. joisino's task is to create a program that, given $ H, W, K $, calculates the beauty of the design based on them.
Input Format
The input is given from the standard input in the following format:
$ H $ $ W $ $ K $
- The first line contains integers representing the size of the rectangle $ H (2 ≦ H ≦ 10^9), W (2 ≦ W ≦ 10^9) $ and the direction of the line $ K (1 ≦ K < W) $.
Output Format
Output the beauty of the design created based on the given $ H, W, K $ in one line.
Sample Input and Output
Sample Input #1
3 5 2
Sample Output #1
2
Sample Input #2
7 6 5
Sample Output #2
10
Sample Input #3
1000000000 1000000000 999999999
Sample Output #3
499999998500000001
Notes/Hints
Sample Explanation 1
This input corresponds to the figure in the problem statement.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分