import java.util.*

object MainKt {
	@JvmStatic
	fun main(args: Array<String>) {
		val scanner = Scanner(System.`in`)
		val a = scanner.nextInt()
		val b = scanner.nextInt()
		val k = scanner.nextInt()

		var ans = 1
		var n=0
		for (i in 100 downTo 1) {
			if (a%i==0 && b%i==0) {
				n++
				if (n==k) {
					ans = i
					break
				}
			}
		}
		println(ans)

	}
}