

import java.io.*;
public class Main {

    public static void main(String[] args) throws IOException  {

        // ?¨??????\??????????????????????????????
        int c;
        int keta = 0;
        // int hairetsu_keta[] = new int[4]; hairetsu_keta[0] = 0;hairetsu_keta[1] = 0;hairetsu_keta[2] = 0;hairetsu_keta[3] = 0;
        int hairetsu_keta[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // ???????????¨???????????¨????????£????????????
        int j = 0;
        int deru = 0;
        // int hairetsu[] = new int[4]; hairetsu[0] = 0; hairetsu[1] = 0; hairetsu[2] = 0; hairetsu[3] = 0;
        int hairetsu[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};//??? ????????¨???????????¨????????£???????????????????????????????????°????¢??????? ?????????20???
        int hairetsu_fugou[] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};//?¬???????????????¨??????????????¨????????? ???????¬???????????????????????????\???
        int i= 0;
        while ((c = System.in.read()) != -1  )
        {
            // System.out.println(c);
            if ( c > 47 && c < 58) // suuji ga kita
               {
                hairetsu[i] = c-48;
                i++;
                keta++;

                // System.out.println("Qurege_no_kazu_keta_hantaikara:" + Qurage_no_kazu);
               }
            if ( c == 45) // minus ga kita
               {
                hairetsu_fugou[j] = -1;
               }

            if ( c == 10) // return ga kita
            {
                hairetsu_keta[j] = keta;
                deru++; //return ga  kitara while wo deru
                j++;
            }
            if ( c == 32) //space ga kita
            {

                hairetsu_keta[j] = keta;
                keta = 0;//space ga kitara tsugi no moji no tame keta ha sokomade
                j++;
            }
            if (deru > 0)
            {
                break;
                }
        }
           // ?¨??????\?????????????????????????????????????????????

        // ??°??????????????\??????
        //int hairetsu_suuchi[] = new int[4]; hairetsu_suuchi[0] = 0; hairetsu_suuchi[1] = 0; hairetsu_suuchi[2] = 0; hairetsu_suuchi[3] = 0;
        int hairetsu_suuchi[] = {0,0,0,0,0,0,0,0,0,0};//???????????¨????????? ??¨????????£????????????
        int k = 0;
        int m = 0;
        int n = 0;


        while( n < (j + 1))
        {
        while(j > 0 && hairetsu_keta[n] > 0 )
        {
            hairetsu_suuchi[k] = hairetsu_suuchi[k]*10 + hairetsu[m];
            hairetsu_keta[n] = hairetsu_keta[n] - 1;
            m++;
        }
        if (hairetsu_keta[n] == 0)
        {
            if(hairetsu_fugou[n] == -1)
            {
                hairetsu_suuchi[k] = hairetsu_suuchi[k]*(-1);

            }
            n++;
            k++;
        }
        }

        //??°??????????????\???????????????
        /*
          for (int p = 0; p < k - 1 ; p++)

        {
        System.out.println("???????????°??????" + hairetsu_suuchi[p]);
        }

        */
        int x = hairetsu_suuchi[0];
        int y = hairetsu_suuchi[1];
        int z;
        while(x != 0)
        {
        if( y > x )
        {
           z = y;
           y = x;
           x = z;
        }
        x = x%y;
        }
        
        	System.out.println(y);

    }

} import java.io.*; io.* java public class Main {

    public static void main(String[] args) throws IOException  {

        // ?¨??????\??????????????????????????????
        int c;
        int keta = 0;
        // int hairetsu_keta[] = new int[4]; hairetsu_keta[0] = 0;hairetsu_keta[1] = 0;hairetsu_keta[2] = 0;hairetsu_keta[3] = 0;
        int hairetsu_keta[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // ???????????¨???????????¨????????£????????????
        int j = 0;
        int deru = 0;
        // int hairetsu[] = new int[4]; hairetsu[0] = 0; hairetsu[1] = 0; hairetsu[2] = 0; hairetsu[3] = 0;
        int hairetsu[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};//??? ????????¨???????????¨????????£???????????????????????????????????°????¢??????? ?????????20???
        int hairetsu_fugou[] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};//?¬???????????????¨??????????????¨????????? ???????¬???????????????????????????\???
        int i= 0;
        while ((c = System.in.read()) != -1  )
        {
            // System.out.println(c);
            if ( c > 47 && c < 58) // suuji ga kita
               {
                hairetsu[i] = c-48;
                i++;
                keta++;

                // System.out.println("Qurege_no_kazu_keta_hantaikara:" + Qurage_no_kazu);
               }
            if ( c == 45) // minus ga kita
               {
                hairetsu_fugou[j] = -1;
               }

            if ( c == 10) // return ga kita
            {
                hairetsu_keta[j] = keta;
                deru++; //return ga  kitara while wo deru
                j++;
            }
            if ( c == 32) //space ga kita
            {

                hairetsu_keta[j] = keta;
                keta = 0;//space ga kitara tsugi no moji no tame keta ha sokomade
                j++;
            }
            if (deru > 0)
            {
                break;
                }
        }
           // ?¨??????\?????????????????????????????????????????????

        // ??°??????????????\??????
        //int hairetsu_suuchi[] = new int[4]; hairetsu_suuchi[0] = 0; hairetsu_suuchi[1] = 0; hairetsu_suuchi[2] = 0; hairetsu_suuchi[3] = 0;
        int hairetsu_suuchi[] = {0,0,0,0,0,0,0,0,0,0};//???????????¨????????? ??¨????????£????????????
        int k = 0;
        int m = 0;
        int n = 0;


        while( n < (j + 1))
        {
        while(j > 0 && hairetsu_keta[n] > 0 )
        {
            hairetsu_suuchi[k] = hairetsu_suuchi[k]*10 + hairetsu[m];
            hairetsu_keta[n] = hairetsu_keta[n] - 1;
            m++;
        }
        if (hairetsu_keta[n] == 0)
        {
            if(hairetsu_fugou[n] == -1)
            {
                hairetsu_suuchi[k] = hairetsu_suuchi[k]*(-1);

            }
            n++;
            k++;
        }
        }

        //??°??????????????\???????????????
        /*
          for (int p = 0; p < k - 1 ; p++)

        {
        System.out.println("???????????°??????" + hairetsu_suuchi[p]);
        }

        */
        int x = hairetsu_suuchi[0];
        int y = hairetsu_suuchi[1];
        int z;
        while(x != 0)
        {
        if( y > x )
        {
           z = y;
           y = x;
           x = z;
        }
        x = x%y;
        }
        
        	System.out.println(y);

    }

} Main public static void main(String[] args) throws IOException  {

        // ?¨??????\??????????????????????????????
        int c;
        int keta = 0;
        // int hairetsu_keta[] = new int[4]; hairetsu_keta[0] = 0;hairetsu_keta[1] = 0;hairetsu_keta[2] = 0;hairetsu_keta[3] = 0;
        int hairetsu_keta[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // ???????????¨???????????¨????????£????????????
        int j = 0;
        int deru = 0;
        // int hairetsu[] = new int[4]; hairetsu[0] = 0; hairetsu[1] = 0; hairetsu[2] = 0; hairetsu[3] = 0;
        int hairetsu[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};//??? ????????¨???????????¨????????£???????????????????????????????????°????¢??????? ?????????20???
        int hairetsu_fugou[] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};//?¬???????????????¨??????????????¨????????? ???????¬???????????????????????????\???
        int i= 0;
        while ((c = System.in.read()) != -1  )
        {
            // System.out.println(c);
            if ( c > 47 && c < 58) // suuji ga kita
               {
                hairetsu[i] = c-48;
                i++;
                keta++;

                // System.out.println("Qurege_no_kazu_keta_hantaikara:" + Qurage_no_kazu);
               }
            if ( c == 45) // minus ga kita
               {
                hairetsu_fugou[j] = -1;
               }

            if ( c == 10) // return ga kita
            {
                hairetsu_keta[j] = keta;
                deru++; //return ga  kitara while wo deru
                j++;
            }
            if ( c == 32) //space ga kita
            {

                hairetsu_keta[j] = keta;
                keta = 0;//space ga kitara tsugi no moji no tame keta ha sokomade
                j++;
            }
            if (deru > 0)
            {
                break;
                }
        }
           // ?¨??????\?????????????????????????????????????????????

        // ??°??????????????\??????
        //int hairetsu_suuchi[] = new int[4]; hairetsu_suuchi[0] = 0; hairetsu_suuchi[1] = 0; hairetsu_suuchi[2] = 0; hairetsu_suuchi[3] = 0;
        int hairetsu_suuchi[] = {0,0,0,0,0,0,0,0,0,0};//???????????¨????????? ??¨????????£????????????
        int k = 0;
        int m = 0;
        int n = 0;


        while( n < (j + 1))
        {
        while(j > 0 && hairetsu_keta[n] > 0 )
        {
            hairetsu_suuchi[k] = hairetsu_suuchi[k]*10 + hairetsu[m];
            hairetsu_keta[n] = hairetsu_keta[n] - 1;
            m++;
        }
        if (hairetsu_keta[n] == 0)
        {
            if(hairetsu_fugou[n] == -1)
            {
                hairetsu_suuchi[k] = hairetsu_suuchi[k]*(-1);

            }
            n++;
            k++;
        }
        }

        //??°??????????????\???????????????
        /*
          for (int p = 0; p < k - 1 ; p++)

        {
        System.out.println("???????????°??????" + hairetsu_suuchi[p]);
        }

        */
        int x = hairetsu_suuchi[0];
        int y = hairetsu_suuchi[1];
        int z;
        while(x != 0)
        {
        if( y > x )
        {
           z = y;
           y = x;
           x = z;
        }
        x = x%y;
        }
        
        	System.out.println(y);

    } main {

        // ?¨??????\??????????????????????????????
        int c;
        int keta = 0;
        // int hairetsu_keta[] = new int[4]; hairetsu_keta[0] = 0;hairetsu_keta[1] = 0;hairetsu_keta[2] = 0;hairetsu_keta[3] = 0;
        int hairetsu_keta[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // ???????????¨???????????¨????????£????????????
        int j = 0;
        int deru = 0;
        // int hairetsu[] = new int[4]; hairetsu[0] = 0; hairetsu[1] = 0; hairetsu[2] = 0; hairetsu[3] = 0;
        int hairetsu[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};//??? ????????¨???????????¨????????£???????????????????????????????????°????¢??????? ?????????20???
        int hairetsu_fugou[] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};//?¬???????????????¨??????????????¨????????? ???????¬???????????????????????????\???
        int i= 0;
        while ((c = System.in.read()) != -1  )
        {
            // System.out.println(c);
            if ( c > 47 && c < 58) // suuji ga kita
               {
                hairetsu[i] = c-48;
                i++;
                keta++;

                // System.out.println("Qurege_no_kazu_keta_hantaikara:" + Qurage_no_kazu);
               }
            if ( c == 45) // minus ga kita
               {
                hairetsu_fugou[j] = -1;
               }

            if ( c == 10) // return ga kita
            {
                hairetsu_keta[j] = keta;
                deru++; //return ga  kitara while wo deru
                j++;
            }
            if ( c == 32) //space ga kita
            {

                hairetsu_keta[j] = keta;
                keta = 0;//space ga kitara tsugi no moji no tame keta ha sokomade
                j++;
            }
            if (deru > 0)
            {
                break;
                }
        }
           // ?¨??????\?????????????????????????????????????????????

        // ??°??????????????\??????
        //int hairetsu_suuchi[] = new int[4]; hairetsu_suuchi[0] = 0; hairetsu_suuchi[1] = 0; hairetsu_suuchi[2] = 0; hairetsu_suuchi[3] = 0;
        int hairetsu_suuchi[] = {0,0,0,0,0,0,0,0,0,0};//???????????¨????????? ??¨????????£????????????
        int k = 0;
        int m = 0;
        int n = 0;


        while( n < (j + 1))
        {
        while(j > 0 && hairetsu_keta[n] > 0 )
        {
            hairetsu_suuchi[k] = hairetsu_suuchi[k]*10 + hairetsu[m];
            hairetsu_keta[n] = hairetsu_keta[n] - 1;
            m++;
        }
        if (hairetsu_keta[n] == 0)
        {
            if(hairetsu_fugou[n] == -1)
            {
                hairetsu_suuchi[k] = hairetsu_suuchi[k]*(-1);

            }
            n++;
            k++;
        }
        }

        //??°??????????????\???????????????
        /*
          for (int p = 0; p < k - 1 ; p++)

        {
        System.out.println("???????????°??????" + hairetsu_suuchi[p]);
        }

        */
        int x = hairetsu_suuchi[0];
        int y = hairetsu_suuchi[1];
        int z;
        while(x != 0)
        {
        if( y > x )
        {
           z = y;
           y = x;
           x = z;
        }
        x = x%y;
        }
        
        	System.out.println(y);

    } int c; c int keta = 0; keta 0 int hairetsu_keta[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; hairetsu_keta {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 int j = 0; j 0 int deru = 0; deru 0 int hairetsu[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; hairetsu {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 int hairetsu_fugou[] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; hairetsu_fugou {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1} 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 int i= 0; i 0 while ((c = System.in.read()) != -1  )
        {
            // System.out.println(c);
            if ( c > 47 && c < 58) // suuji ga kita
               {
                hairetsu[i] = c-48;
                i++;
                keta++;

                // System.out.println("Qurege_no_kazu_keta_hantaikara:" + Qurage_no_kazu);
               }
            if ( c == 45) // minus ga kita
               {
                hairetsu_fugou[j] = -1;
               }

            if ( c == 10) // return ga kita
            {
                hairetsu_keta[j] = keta;
                deru++; //return ga  kitara while wo deru
                j++;
            }
            if ( c == 32) //space ga kita
            {

                hairetsu_keta[j] = keta;
                keta = 0;//space ga kitara tsugi no moji no tame keta ha sokomade
                j++;
            }
            if (deru > 0)
            {
                break;
                }
        } (c = System.in.read()) != -1 (c = System.in.read()) c System.in.read() System.in.read System.in System System.in -1 1 {
            // System.out.println(c);
            if ( c > 47 && c < 58) // suuji ga kita
               {
                hairetsu[i] = c-48;
                i++;
                keta++;

                // System.out.println("Qurege_no_kazu_keta_hantaikara:" + Qurage_no_kazu);
               }
            if ( c == 45) // minus ga kita
               {
                hairetsu_fugou[j] = -1;
               }

            if ( c == 10) // return ga kita
            {
                hairetsu_keta[j] = keta;
                deru++; //return ga  kitara while wo deru
                j++;
            }
            if ( c == 32) //space ga kita
            {

                hairetsu_keta[j] = keta;
                keta = 0;//space ga kitara tsugi no moji no tame keta ha sokomade
                j++;
            }
            if (deru > 0)
            {
                break;
                }
        } if ( c > 47 && c < 58) // suuji ga kita
               {
                hairetsu[i] = c-48;
                i++;
                keta++;

                // System.out.println("Qurege_no_kazu_keta_hantaikara:" + Qurage_no_kazu);
               } c > 47 && c < 58 c > 47 c 47 c < 58 c 58 {
                hairetsu[i] = c-48;
                i++;
                keta++;

                // System.out.println("Qurege_no_kazu_keta_hantaikara:" + Qurage_no_kazu);
               } hairetsu[i] = c-48 hairetsu[i] hairetsu i c-48 c 48 i++ i keta++ keta if ( c == 45) // minus ga kita
               {
                hairetsu_fugou[j] = -1;
               } c == 45 c 45 {
                hairetsu_fugou[j] = -1;
               } hairetsu_fugou[j] = -1 hairetsu_fugou[j] hairetsu_fugou j -1 1 if ( c == 10) // return ga kita
            {
                hairetsu_keta[j] = keta;
                deru++; //return ga  kitara while wo deru
                j++;
            } c == 10 c 10 {
                hairetsu_keta[j] = keta;
                deru++; //return ga  kitara while wo deru
                j++;
            } hairetsu_keta[j] = keta hairetsu_keta[j] hairetsu_keta j keta deru++ deru j++ j if ( c == 32) //space ga kita
            {

                hairetsu_keta[j] = keta;
                keta = 0;//space ga kitara tsugi no moji no tame keta ha sokomade
                j++;
            } c == 32 c 32 {

                hairetsu_keta[j] = keta;
                keta = 0;//space ga kitara tsugi no moji no tame keta ha sokomade
                j++;
            } hairetsu_keta[j] = keta hairetsu_keta[j] hairetsu_keta j keta keta = 0 keta 0 j++ j if (deru > 0)
            {
                break;
                } deru > 0 deru 0 {
                break;
                } break; int hairetsu_suuchi[] = {0,0,0,0,0,0,0,0,0,0}; hairetsu_suuchi {0,0,0,0,0,0,0,0,0,0} 0 0 0 0 0 0 0 0 0 0 int k = 0; k 0 int m = 0; m 0 int n = 0; n 0 while( n < (j + 1))
        {
        while(j > 0 && hairetsu_keta[n] > 0 )
        {
            hairetsu_suuchi[k] = hairetsu_suuchi[k]*10 + hairetsu[m];
            hairetsu_keta[n] = hairetsu_keta[n] - 1;
            m++;
        }
        if (hairetsu_keta[n] == 0)
        {
            if(hairetsu_fugou[n] == -1)
            {
                hairetsu_suuchi[k] = hairetsu_suuchi[k]*(-1);

            }
            n++;
            k++;
        }
        } n < (j + 1) n (j + 1) j 1 {
        while(j > 0 && hairetsu_keta[n] > 0 )
        {
            hairetsu_suuchi[k] = hairetsu_suuchi[k]*10 + hairetsu[m];
            hairetsu_keta[n] = hairetsu_keta[n] - 1;
            m++;
        }
        if (hairetsu_keta[n] == 0)
        {
            if(hairetsu_fugou[n] == -1)
            {
                hairetsu_suuchi[k] = hairetsu_suuchi[k]*(-1);

            }
            n++;
            k++;
        }
        } while(j > 0 && hairetsu_keta[n] > 0 )
        {
            hairetsu_suuchi[k] = hairetsu_suuchi[k]*10 + hairetsu[m];
            hairetsu_keta[n] = hairetsu_keta[n] - 1;
            m++;
        } j > 0 && hairetsu_keta[n] > 0 j > 0 j 0 hairetsu_keta[n] > 0 hairetsu_keta[n] hairetsu_keta n 0 {
            hairetsu_suuchi[k] = hairetsu_suuchi[k]*10 + hairetsu[m];
            hairetsu_keta[n] = hairetsu_keta[n] - 1;
            m++;
        } hairetsu_suuchi[k] = hairetsu_suuchi[k]*10 + hairetsu[m] hairetsu_suuchi[k] hairetsu_suuchi k hairetsu_suuchi[k]*10 + hairetsu[m] hairetsu_suuchi[k]*10 hairetsu_suuchi[k] hairetsu_suuchi k 10 hairetsu[m] hairetsu m hairetsu_keta[n] = hairetsu_keta[n] - 1 hairetsu_keta[n] hairetsu_keta n hairetsu_keta[n] - 1 hairetsu_keta[n] hairetsu_keta n 1 m++ m if (hairetsu_keta[n] == 0)
        {
            if(hairetsu_fugou[n] == -1)
            {
                hairetsu_suuchi[k] = hairetsu_suuchi[k]*(-1);

            }
            n++;
            k++;
        } hairetsu_keta[n] == 0 hairetsu_keta[n] hairetsu_keta n 0 {
            if(hairetsu_fugou[n] == -1)
            {
                hairetsu_suuchi[k] = hairetsu_suuchi[k]*(-1);

            }
            n++;
            k++;
        } if(hairetsu_fugou[n] == -1)
            {
                hairetsu_suuchi[k] = hairetsu_suuchi[k]*(-1);

            } hairetsu_fugou[n] == -1 hairetsu_fugou[n] hairetsu_fugou n -1 1 {
                hairetsu_suuchi[k] = hairetsu_suuchi[k]*(-1);

            } hairetsu_suuchi[k] = hairetsu_suuchi[k]*(-1) hairetsu_suuchi[k] hairetsu_suuchi k hairetsu_suuchi[k]*(-1) hairetsu_suuchi[k] hairetsu_suuchi k (-1) 1 n++ n k++ k int x = hairetsu_suuchi[0]; x hairetsu_suuchi[0] hairetsu_suuchi 0 int y = hairetsu_suuchi[1]; y hairetsu_suuchi[1] hairetsu_suuchi 1 int z; z while(x != 0)
        {
        if( y > x )
        {
           z = y;
           y = x;
           x = z;
        }
        x = x%y;
        } x != 0 x 0 {
        if( y > x )
        {
           z = y;
           y = x;
           x = z;
        }
        x = x%y;
        } if( y > x )
        {
           z = y;
           y = x;
           x = z;
        } y > x y x {
           z = y;
           y = x;
           x = z;
        } z = y z y y = x y x x = z x z x = x%y x x%y x y System.out.println(y) System.out.println System.out System System.out y String[] args args public class Main {

    public static void main(String[] args) throws IOException  {

        // ?¨??????\??????????????????????????????
        int c;
        int keta = 0;
        // int hairetsu_keta[] = new int[4]; hairetsu_keta[0] = 0;hairetsu_keta[1] = 0;hairetsu_keta[2] = 0;hairetsu_keta[3] = 0;
        int hairetsu_keta[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // ???????????¨???????????¨????????£????????????
        int j = 0;
        int deru = 0;
        // int hairetsu[] = new int[4]; hairetsu[0] = 0; hairetsu[1] = 0; hairetsu[2] = 0; hairetsu[3] = 0;
        int hairetsu[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};//??? ????????¨???????????¨????????£???????????????????????????????????°????¢??????? ?????????20???
        int hairetsu_fugou[] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};//?¬???????????????¨??????????????¨????????? ???????¬???????????????????????????\???
        int i= 0;
        while ((c = System.in.read()) != -1  )
        {
            // System.out.println(c);
            if ( c > 47 && c < 58) // suuji ga kita
               {
                hairetsu[i] = c-48;
                i++;
                keta++;

                // System.out.println("Qurege_no_kazu_keta_hantaikara:" + Qurage_no_kazu);
               }
            if ( c == 45) // minus ga kita
               {
                hairetsu_fugou[j] = -1;
               }

            if ( c == 10) // return ga kita
            {
                hairetsu_keta[j] = keta;
                deru++; //return ga  kitara while wo deru
                j++;
            }
            if ( c == 32) //space ga kita
            {

                hairetsu_keta[j] = keta;
                keta = 0;//space ga kitara tsugi no moji no tame keta ha sokomade
                j++;
            }
            if (deru > 0)
            {
                break;
                }
        }
           // ?¨??????\?????????????????????????????????????????????

        // ??°??????????????\??????
        //int hairetsu_suuchi[] = new int[4]; hairetsu_suuchi[0] = 0; hairetsu_suuchi[1] = 0; hairetsu_suuchi[2] = 0; hairetsu_suuchi[3] = 0;
        int hairetsu_suuchi[] = {0,0,0,0,0,0,0,0,0,0};//???????????¨????????? ??¨????????£????????????
        int k = 0;
        int m = 0;
        int n = 0;


        while( n < (j + 1))
        {
        while(j > 0 && hairetsu_keta[n] > 0 )
        {
            hairetsu_suuchi[k] = hairetsu_suuchi[k]*10 + hairetsu[m];
            hairetsu_keta[n] = hairetsu_keta[n] - 1;
            m++;
        }
        if (hairetsu_keta[n] == 0)
        {
            if(hairetsu_fugou[n] == -1)
            {
                hairetsu_suuchi[k] = hairetsu_suuchi[k]*(-1);

            }
            n++;
            k++;
        }
        }

        //??°??????????????\???????????????
        /*
          for (int p = 0; p < k - 1 ; p++)

        {
        System.out.println("???????????°??????" + hairetsu_suuchi[p]);
        }

        */
        int x = hairetsu_suuchi[0];
        int y = hairetsu_suuchi[1];
        int z;
        while(x != 0)
        {
        if( y > x )
        {
           z = y;
           y = x;
           x = z;
        }
        x = x%y;
        }
        
        	System.out.println(y);

    }

} public class Main {

    public static void main(String[] args) throws IOException  {

        // ?¨??????\??????????????????????????????
        int c;
        int keta = 0;
        // int hairetsu_keta[] = new int[4]; hairetsu_keta[0] = 0;hairetsu_keta[1] = 0;hairetsu_keta[2] = 0;hairetsu_keta[3] = 0;
        int hairetsu_keta[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // ???????????¨???????????¨????????£????????????
        int j = 0;
        int deru = 0;
        // int hairetsu[] = new int[4]; hairetsu[0] = 0; hairetsu[1] = 0; hairetsu[2] = 0; hairetsu[3] = 0;
        int hairetsu[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};//??? ????????¨???????????¨????????£???????????????????????????????????°????¢??????? ?????????20???
        int hairetsu_fugou[] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};//?¬???????????????¨??????????????¨????????? ???????¬???????????????????????????\???
        int i= 0;
        while ((c = System.in.read()) != -1  )
        {
            // System.out.println(c);
            if ( c > 47 && c < 58) // suuji ga kita
               {
                hairetsu[i] = c-48;
                i++;
                keta++;

                // System.out.println("Qurege_no_kazu_keta_hantaikara:" + Qurage_no_kazu);
               }
            if ( c == 45) // minus ga kita
               {
                hairetsu_fugou[j] = -1;
               }

            if ( c == 10) // return ga kita
            {
                hairetsu_keta[j] = keta;
                deru++; //return ga  kitara while wo deru
                j++;
            }
            if ( c == 32) //space ga kita
            {

                hairetsu_keta[j] = keta;
                keta = 0;//space ga kitara tsugi no moji no tame keta ha sokomade
                j++;
            }
            if (deru > 0)
            {
                break;
                }
        }
           // ?¨??????\?????????????????????????????????????????????

        // ??°??????????????\??????
        //int hairetsu_suuchi[] = new int[4]; hairetsu_suuchi[0] = 0; hairetsu_suuchi[1] = 0; hairetsu_suuchi[2] = 0; hairetsu_suuchi[3] = 0;
        int hairetsu_suuchi[] = {0,0,0,0,0,0,0,0,0,0};//???????????¨????????? ??¨????????£????????????
        int k = 0;
        int m = 0;
        int n = 0;


        while( n < (j + 1))
        {
        while(j > 0 && hairetsu_keta[n] > 0 )
        {
            hairetsu_suuchi[k] = hairetsu_suuchi[k]*10 + hairetsu[m];
            hairetsu_keta[n] = hairetsu_keta[n] - 1;
            m++;
        }
        if (hairetsu_keta[n] == 0)
        {
            if(hairetsu_fugou[n] == -1)
            {
                hairetsu_suuchi[k] = hairetsu_suuchi[k]*(-1);

            }
            n++;
            k++;
        }
        }

        //??°??????????????\???????????????
        /*
          for (int p = 0; p < k - 1 ; p++)

        {
        System.out.println("???????????°??????" + hairetsu_suuchi[p]);
        }

        */
        int x = hairetsu_suuchi[0];
        int y = hairetsu_suuchi[1];
        int z;
        while(x != 0)
        {
        if( y > x )
        {
           z = y;
           y = x;
           x = z;
        }
        x = x%y;
        }
        
        	System.out.println(y);

    }

} Main


import java.io.*;
public class Main {

    public static void main(String[] args) throws IOException  {

        // ?¨??????\??????????????????????????????
        int c;
        int keta = 0;
        // int hairetsu_keta[] = new int[4]; hairetsu_keta[0] = 0;hairetsu_keta[1] = 0;hairetsu_keta[2] = 0;hairetsu_keta[3] = 0;
        int hairetsu_keta[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // ???????????¨???????????¨????????£????????????
        int j = 0;
        int deru = 0;
        // int hairetsu[] = new int[4]; hairetsu[0] = 0; hairetsu[1] = 0; hairetsu[2] = 0; hairetsu[3] = 0;
        int hairetsu[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};//??? ????????¨???????????¨????????£???????????????????????????????????°????¢??????? ?????????20???
        int hairetsu_fugou[] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};//?¬???????????????¨??????????????¨????????? ???????¬???????????????????????????\???
        int i= 0;
        while ((c = System.in.read()) != -1  )
        {
            // System.out.println(c);
            if ( c > 47 && c < 58) // suuji ga kita
               {
                hairetsu[i] = c-48;
                i++;
                keta++;

                // System.out.println("Qurege_no_kazu_keta_hantaikara:" + Qurage_no_kazu);
               }
            if ( c == 45) // minus ga kita
               {
                hairetsu_fugou[j] = -1;
               }

            if ( c == 10) // return ga kita
            {
                hairetsu_keta[j] = keta;
                deru++; //return ga  kitara while wo deru
                j++;
            }
            if ( c == 32) //space ga kita
            {

                hairetsu_keta[j] = keta;
                keta = 0;//space ga kitara tsugi no moji no tame keta ha sokomade
                j++;
            }
            if (deru > 0)
            {
                break;
                }
        }
           // ?¨??????\?????????????????????????????????????????????

        // ??°??????????????\??????
        //int hairetsu_suuchi[] = new int[4]; hairetsu_suuchi[0] = 0; hairetsu_suuchi[1] = 0; hairetsu_suuchi[2] = 0; hairetsu_suuchi[3] = 0;
        int hairetsu_suuchi[] = {0,0,0,0,0,0,0,0,0,0};//???????????¨????????? ??¨????????£????????????
        int k = 0;
        int m = 0;
        int n = 0;


        while( n < (j + 1))
        {
        while(j > 0 && hairetsu_keta[n] > 0 )
        {
            hairetsu_suuchi[k] = hairetsu_suuchi[k]*10 + hairetsu[m];
            hairetsu_keta[n] = hairetsu_keta[n] - 1;
            m++;
        }
        if (hairetsu_keta[n] == 0)
        {
            if(hairetsu_fugou[n] == -1)
            {
                hairetsu_suuchi[k] = hairetsu_suuchi[k]*(-1);

            }
            n++;
            k++;
        }
        }

        //??°??????????????\???????????????
        /*
          for (int p = 0; p < k - 1 ; p++)

        {
        System.out.println("???????????°??????" + hairetsu_suuchi[p]);
        }

        */
        int x = hairetsu_suuchi[0];
        int y = hairetsu_suuchi[1];
        int z;
        while(x != 0)
        {
        if( y > x )
        {
           z = y;
           y = x;
           x = z;
        }
        x = x%y;
        }
        
        	System.out.println(y);

    }

}