import java.util.*;

public class Main{
    public static void main(String[] args){
	Scanner a = new Scanner(System.in);
	int x = a.nextInt();
	int y = a.nextInt();
	int n = x;
	if(x < y){
	    x = y;
	    y = n;
	}
	while(y != 0){
	    n = y;
	    y = x%y;
	    x = n;;
	}
	System.out.println(x);
    }
}
 import java.util.*; util.* java public class Main{
    public static void main(String[] args){
	Scanner a = new Scanner(System.in);
	int x = a.nextInt();
	int y = a.nextInt();
	int n = x;
	if(x < y){
	    x = y;
	    y = n;
	}
	while(y != 0){
	    n = y;
	    y = x%y;
	    x = n;;
	}
	System.out.println(x);
    }
} Main public static void main(String[] args){
	Scanner a = new Scanner(System.in);
	int x = a.nextInt();
	int y = a.nextInt();
	int n = x;
	if(x < y){
	    x = y;
	    y = n;
	}
	while(y != 0){
	    n = y;
	    y = x%y;
	    x = n;;
	}
	System.out.println(x);
    } main {
	Scanner a = new Scanner(System.in);
	int x = a.nextInt();
	int y = a.nextInt();
	int n = x;
	if(x < y){
	    x = y;
	    y = n;
	}
	while(y != 0){
	    n = y;
	    y = x%y;
	    x = n;;
	}
	System.out.println(x);
    } Scanner a = new Scanner(System.in); a new Scanner(System.in) int x = a.nextInt(); x a.nextInt() a.nextInt a int y = a.nextInt(); y a.nextInt() a.nextInt a int n = x; n x if(x < y){
	    x = y;
	    y = n;
	} x < y x y {
	    x = y;
	    y = n;
	} x = y x y y = n y n while(y != 0){
	    n = y;
	    y = x%y;
	    x = n;;
	} y != 0 y 0 {
	    n = y;
	    y = x%y;
	    x = n;;
	} n = y n y y = x%y y x%y x y x = n x n System.out.println(x) System.out.println System.out System System.out x String[] args args public class Main{
    public static void main(String[] args){
	Scanner a = new Scanner(System.in);
	int x = a.nextInt();
	int y = a.nextInt();
	int n = x;
	if(x < y){
	    x = y;
	    y = n;
	}
	while(y != 0){
	    n = y;
	    y = x%y;
	    x = n;;
	}
	System.out.println(x);
    }
} public class Main{
    public static void main(String[] args){
	Scanner a = new Scanner(System.in);
	int x = a.nextInt();
	int y = a.nextInt();
	int n = x;
	if(x < y){
	    x = y;
	    y = n;
	}
	while(y != 0){
	    n = y;
	    y = x%y;
	    x = n;;
	}
	System.out.println(x);
    }
} Main
import java.util.*;

public class Main{
    public static void main(String[] args){
	Scanner a = new Scanner(System.in);
	int x = a.nextInt();
	int y = a.nextInt();
	int n = x;
	if(x < y){
	    x = y;
	    y = n;
	}
	while(y != 0){
	    n = y;
	    y = x%y;
	    x = n;;
	}
	System.out.println(x);
    }
}

