#include <stdio.h> int main () { int a=360,b=60; scanf("%d%d",&a,&b); int t; while(b>0){ t=a%b; a=b; b=t; } printf("%d",a); return 0; }