import std.stdio;
import std.string;
import std.algorithm;
import std.conv;
 
void main()
{
    int A, B, r, K;
    auto input = readln.split.to!(int[]);
    A = input[0];
    B = input[1];
    K = input[2];
    while(A%B)
    {
        r = A%B;
        A = B;
        B = r;
    }
        writeln(B);
}