#include<iostream>
using namespace std;
int NWD(int,int);
int main()
{
cout<<NWD(6,27)<<'\n';
return 0;
}
int NWD(int a,int b)
{
if(a!=b)
{
if(a>b) NWD(a-b,b);
else NWD(a,b-a);
}
else
return a;
}
I2luY2x1ZGU8aW9zdHJlYW0+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmludCBOV0QoaW50LGludCk7CmludCBtYWluKCkKewogICAgY291dDw8TldEKDYsMjcpPDwnXG4nOwogICAgcmV0dXJuIDA7Cn0KaW50IE5XRChpbnQgYSxpbnQgYikKewogICAgaWYoYSE9YikKICAgIHsKICAgICAgICBpZihhPmIpIE5XRChhLWIsYik7CiAgICAgICAgZWxzZSBOV0QoYSxiLWEpOwogICAgfQogICAgZWxzZQogICAgICAgIHJldHVybiBhOwp9