14 #ABC120B. [ABC120B] K-th Common Divisor

[ABC120B] K-th Common Divisor

Score : 200200 points

Problem Statement

You are given positive integers AA and BB.

Find the KK-th largest positive integer that divides both AA and BB.

The input guarantees that there exists such a number.

Constraints

  • All values in input are integers.
  • 1A,B1001 \leq A, B \leq 100
  • The KK-th largest positive integer that divides both AA and BB exists.
  • K1K \geq 1

Input

Input is given from Standard Input in the following format:

AA BB KK

Output

Print the KK-th largest positive integer that divides both AA and BB.

8 12 2
2

Three positive integers divides both 88 and 1212: 1,21, 2 and 44. Among them, the second largest is 22.

100 50 4
5
1 1 1
1