Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/sonlar-diofant-yechimlari

Solutions of a Diophantine equation

Medium 1000 ms 128 MB 53%
Share

You are given positive integers $a$, $b$ and a non-negative integer $c$. How many integer solutions $(x, y)$ with $x \ge 0$, $y \ge 0$ does the equation $a \cdot x + b \cdot y = c$ have?

The solutions of the equation highlighted as lattice points on a line in the coordinate plane

Input

One line with three integers: $a$, $b$ and $c$.

Output

One integer — the number of solutions.

Note

$1 \le a, b \le 10^{9}$
$0 \le c \le 10^{18}$

Examples

Input #1
2 3 12
Output #1
3
Input #2
4 6 7
Output #2
0

Sign in to submit a solution

Signing up is free and takes a minute.