#!/usr/bin/perl -w
use strict;
use v5.10;
my ($a, $b) = @ARGV;
($a, $b) = ($b, $a % $b) while $b;
say "$a";