{-# LANGUAGE OverloadedStrings #-}

import qualified Data.ByteString.Char8 as B
import Data.Attoparsec.ByteString.Char8
import qualified Data.List as L

type Input = (Int, Int, Int)

input :: Parser Input
input = (,,)
  <$> decimal <* space
  <*> decimal <* space
  <*> decimal <* endOfLine

main :: IO ()
main = B.interact
  $ B.pack . show . either (error "parse err") solve . parseOnly input

solve :: Input -> Int
solve (a, b, k) = L.head
  $ L.drop (k - 1)
  $ [ i | i <- [100, 99 .. 1], a `mod` i == 0 && b `mod` i == 0 ]