import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
	    int a = in.nextInt();
	    int b = in.nextInt();
	    int gsd = 1;
	    if (a>b) {
		    while (a%b !=0)
		    {
		    	int aim = b;
		        b=a%aim;
		        a=aim;
			    gsd=b;
		    }
		    System.out.println(gsd);
	    }
	    else if (a<b) {
	    	while (b%a !=0) {
	    		int aim = a;
	    	    a=b%aim;
	    	    b=aim;
			    gsd=a;
	    	}
	    	System.out.println(gsd);
	    }
	    else {
	    	System.out.println(a);
	    }
	    in.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
	    int a = in.nextInt();
	    int b = in.nextInt();
	    int gsd = 1;
	    if (a>b) {
		    while (a%b !=0)
		    {
		    	int aim = b;
		        b=a%aim;
		        a=aim;
			    gsd=b;
		    }
		    System.out.println(gsd);
	    }
	    else if (a<b) {
	    	while (b%a !=0) {
	    		int aim = a;
	    	    a=b%aim;
	    	    b=aim;
			    gsd=a;
	    	}
	    	System.out.println(gsd);
	    }
	    else {
	    	System.out.println(a);
	    }
	    in.close();
	}
} Main public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
	    int a = in.nextInt();
	    int b = in.nextInt();
	    int gsd = 1;
	    if (a>b) {
		    while (a%b !=0)
		    {
		    	int aim = b;
		        b=a%aim;
		        a=aim;
			    gsd=b;
		    }
		    System.out.println(gsd);
	    }
	    else if (a<b) {
	    	while (b%a !=0) {
	    		int aim = a;
	    	    a=b%aim;
	    	    b=aim;
			    gsd=a;
	    	}
	    	System.out.println(gsd);
	    }
	    else {
	    	System.out.println(a);
	    }
	    in.close();
	} main {
		Scanner in = new Scanner(System.in);
	    int a = in.nextInt();
	    int b = in.nextInt();
	    int gsd = 1;
	    if (a>b) {
		    while (a%b !=0)
		    {
		    	int aim = b;
		        b=a%aim;
		        a=aim;
			    gsd=b;
		    }
		    System.out.println(gsd);
	    }
	    else if (a<b) {
	    	while (b%a !=0) {
	    		int aim = a;
	    	    a=b%aim;
	    	    b=aim;
			    gsd=a;
	    	}
	    	System.out.println(gsd);
	    }
	    else {
	    	System.out.println(a);
	    }
	    in.close();
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) int a = in.nextInt(); a in.nextInt() in.nextInt in int b = in.nextInt(); b in.nextInt() in.nextInt in int gsd = 1; gsd 1 if (a>b) {
		    while (a%b !=0)
		    {
		    	int aim = b;
		        b=a%aim;
		        a=aim;
			    gsd=b;
		    }
		    System.out.println(gsd);
	    }
	    else if (a<b) {
	    	while (b%a !=0) {
	    		int aim = a;
	    	    a=b%aim;
	    	    b=aim;
			    gsd=a;
	    	}
	    	System.out.println(gsd);
	    }
	    else {
	    	System.out.println(a);
	    } a>b a b {
		    while (a%b !=0)
		    {
		    	int aim = b;
		        b=a%aim;
		        a=aim;
			    gsd=b;
		    }
		    System.out.println(gsd);
	    } while (a%b !=0)
		    {
		    	int aim = b;
		        b=a%aim;
		        a=aim;
			    gsd=b;
		    } a%b !=0 a%b a b 0 {
		    	int aim = b;
		        b=a%aim;
		        a=aim;
			    gsd=b;
		    } int aim = b; aim b b=a%aim b a%aim a aim a=aim a aim gsd=b gsd b System.out.println(gsd) System.out.println System.out System System.out gsd if (a<b) {
	    	while (b%a !=0) {
	    		int aim = a;
	    	    a=b%aim;
	    	    b=aim;
			    gsd=a;
	    	}
	    	System.out.println(gsd);
	    }
	    else {
	    	System.out.println(a);
	    } a<b a b {
	    	while (b%a !=0) {
	    		int aim = a;
	    	    a=b%aim;
	    	    b=aim;
			    gsd=a;
	    	}
	    	System.out.println(gsd);
	    } while (b%a !=0) {
	    		int aim = a;
	    	    a=b%aim;
	    	    b=aim;
			    gsd=a;
	    	} b%a !=0 b%a b a 0 {
	    		int aim = a;
	    	    a=b%aim;
	    	    b=aim;
			    gsd=a;
	    	} int aim = a; aim a a=b%aim a b%aim b aim b=aim b aim gsd=a gsd a System.out.println(gsd) System.out.println System.out System System.out gsd {
	    	System.out.println(a);
	    } System.out.println(a) System.out.println System.out System System.out a in.close() in.close in String[] args args public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
	    int a = in.nextInt();
	    int b = in.nextInt();
	    int gsd = 1;
	    if (a>b) {
		    while (a%b !=0)
		    {
		    	int aim = b;
		        b=a%aim;
		        a=aim;
			    gsd=b;
		    }
		    System.out.println(gsd);
	    }
	    else if (a<b) {
	    	while (b%a !=0) {
	    		int aim = a;
	    	    a=b%aim;
	    	    b=aim;
			    gsd=a;
	    	}
	    	System.out.println(gsd);
	    }
	    else {
	    	System.out.println(a);
	    }
	    in.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
	    int a = in.nextInt();
	    int b = in.nextInt();
	    int gsd = 1;
	    if (a>b) {
		    while (a%b !=0)
		    {
		    	int aim = b;
		        b=a%aim;
		        a=aim;
			    gsd=b;
		    }
		    System.out.println(gsd);
	    }
	    else if (a<b) {
	    	while (b%a !=0) {
	    		int aim = a;
	    	    a=b%aim;
	    	    b=aim;
			    gsd=a;
	    	}
	    	System.out.println(gsd);
	    }
	    else {
	    	System.out.println(a);
	    }
	    in.close();
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
	    int a = in.nextInt();
	    int b = in.nextInt();
	    int gsd = 1;
	    if (a>b) {
		    while (a%b !=0)
		    {
		    	int aim = b;
		        b=a%aim;
		        a=aim;
			    gsd=b;
		    }
		    System.out.println(gsd);
	    }
	    else if (a<b) {
	    	while (b%a !=0) {
	    		int aim = a;
	    	    a=b%aim;
	    	    b=aim;
			    gsd=a;
	    	}
	    	System.out.println(gsd);
	    }
	    else {
	    	System.out.println(a);
	    }
	    in.close();
	}
}
