program kadai
implicit none
    integer(8)  ::  a,b
    integer(8)  ::  max
    integer(8)  ::  p
    integer(8)  ::  i
    real(8)  ::sq_re
    integer(8)  ::  sq_in

    read(*,*) a,b
    max=gcd(a,b)

    sq_re=sqrt(real(max,8))
    sq_in=sq_re*1

    p=0
    do i=1,sq_in
        if (mod(max,i)==0) then
            p=p+1

            if (i>1) then
                do while(mod(max,i)==0)
                    max=max/i
                end do
            end if
        end if
    end do

    if(max/=1) then
        p=p+1
    end if

    write(*,*) p


stop
contains

function gcd(a,b) result(ret)
    implicit none
    integer(8),intent(in)  ::  a,b
    integer(8)  ::  l,m,n
    integer(8)  ::  ret
    m=a
    n=b
    do
        l=mod(m,n)
        if (l==0) then
            exit
        end if
        m=n
        n=l
    end do
    ret=n
    return
end function gcd

end program kadai