x=int(input())y=int(input())while x!=y: if x>y: x=x-y else: y=y-xprint(x)
40 24
8
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!