#P4132. Puzzle Door: Prime Password

    ID: 17380 Type: Default 1000ms 256MiB

Puzzle Door: Prime Password

Puzzle Door: Prime Password

If you really want to play this game, you must first solve the following puzzle. The first level features a door secured by a password lock. On the door, an unusual equation is inscribed, and legend has it that if you compute the equation correctly, you will obtain the password to open the door.

The equation is given by:

\( \sum_{k=1}^{\frac{p-1}{2}} \left\lfloor \frac{kq}{p} \right\rfloor + \sum_{k=1}^{\frac{q-1}{2}} \left\lfloor \frac{kp}{q} \right\rfloor \)

Here, p and q are two odd prime numbers. Your task is to calculate the value of the expression (which becomes the password) given the input values of p and q.

inputFormat

The input consists of a single line containing two space-separated odd prime numbers, p and q.

outputFormat

Output the computed password as an integer.

sample

3 5
2