import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    PrintWriter out = new PrintWriter(System.out);

    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");

    int a = Integer.parseInt(sl[0]);
    int b = Integer.parseInt(sl[1]);
    int k = Integer.parseInt(sl[2]);

    int z = a + 1;

    while(k > 0)
    {
      z--;
      if(a % z == 0 && b % z == 0)
      {
        k--;
      }
    }

    out.println(z);
    out.flush();
  }

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.PrintWriter; PrintWriter java.io public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    PrintWriter out = new PrintWriter(System.out);

    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");

    int a = Integer.parseInt(sl[0]);
    int b = Integer.parseInt(sl[1]);
    int k = Integer.parseInt(sl[2]);

    int z = a + 1;

    while(k > 0)
    {
      z--;
      if(a % z == 0 && b % z == 0)
      {
        k--;
      }
    }

    out.println(z);
    out.flush();
  }

} Main public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    PrintWriter out = new PrintWriter(System.out);

    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");

    int a = Integer.parseInt(sl[0]);
    int b = Integer.parseInt(sl[1]);
    int k = Integer.parseInt(sl[2]);

    int z = a + 1;

    while(k > 0)
    {
      z--;
      if(a % z == 0 && b % z == 0)
      {
        k--;
      }
    }

    out.println(z);
    out.flush();
  } main {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    PrintWriter out = new PrintWriter(System.out);

    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");

    int a = Integer.parseInt(sl[0]);
    int b = Integer.parseInt(sl[1]);
    int k = Integer.parseInt(sl[2]);

    int z = a + 1;

    while(k > 0)
    {
      z--;
      if(a % z == 0 && b % z == 0)
      {
        k--;
      }
    }

    out.println(z);
    out.flush();
  } BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1); r new BufferedReader(new InputStreamReader(System.in), 1) PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) String s; s String sl[]; sl s = r.readLine() s r.readLine() r.readLine r sl = s.split(" ") sl s.split(" ") s.split s " " int a = Integer.parseInt(sl[0]); a Integer.parseInt(sl[0]) Integer.parseInt Integer sl[0] sl 0 int b = Integer.parseInt(sl[1]); b Integer.parseInt(sl[1]) Integer.parseInt Integer sl[1] sl 1 int k = Integer.parseInt(sl[2]); k Integer.parseInt(sl[2]) Integer.parseInt Integer sl[2] sl 2 int z = a + 1; z a + 1 a 1 while(k > 0)
    {
      z--;
      if(a % z == 0 && b % z == 0)
      {
        k--;
      }
    } k > 0 k 0 {
      z--;
      if(a % z == 0 && b % z == 0)
      {
        k--;
      }
    } z-- z if(a % z == 0 && b % z == 0)
      {
        k--;
      } a % z == 0 && b % z == 0 a % z == 0 a % z a z 0 b % z == 0 b % z b z 0 {
        k--;
      } k-- k out.println(z) out.println out z out.flush() out.flush out String[] args args public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    PrintWriter out = new PrintWriter(System.out);

    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");

    int a = Integer.parseInt(sl[0]);
    int b = Integer.parseInt(sl[1]);
    int k = Integer.parseInt(sl[2]);

    int z = a + 1;

    while(k > 0)
    {
      z--;
      if(a % z == 0 && b % z == 0)
      {
        k--;
      }
    }

    out.println(z);
    out.flush();
  }

} public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    PrintWriter out = new PrintWriter(System.out);

    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");

    int a = Integer.parseInt(sl[0]);
    int b = Integer.parseInt(sl[1]);
    int k = Integer.parseInt(sl[2]);

    int z = a + 1;

    while(k > 0)
    {
      z--;
      if(a % z == 0 && b % z == 0)
      {
        k--;
      }
    }

    out.println(z);
    out.flush();
  }

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    PrintWriter out = new PrintWriter(System.out);

    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");

    int a = Integer.parseInt(sl[0]);
    int b = Integer.parseInt(sl[1]);
    int k = Integer.parseInt(sl[2]);

    int z = a + 1;

    while(k > 0)
    {
      z--;
      if(a % z == 0 && b % z == 0)
      {
        k--;
      }
    }

    out.println(z);
    out.flush();
  }

}