program disjoint_set_of_common_divisors
    implicit none
    integer(4):: a, b
    integer(4):: gcd
    integer(4):: i,j,count=0
    logical:: divided

    read*,a,b
    gcd = calc_gcd(a,b)
    
    do i=2, nint(sqrt(dble(gcd)))
        divided=.false.
        do while(mod(gcd,i)==0)
            gcd=gcd/i
            divided=.true.
        end do
        if (divided) count=count+1
    end do

    if (gcd > 1) count=count+1

    print*,count+1

contains
recursive function calc_gcd(a,b) result(ret)
    integer(4)::a,b,ret
    
    if (mod(a,b)==0) then
        ret = b
        return
    end if

    ret = calc_gcd(b,mod(a,b))

end function
end program disjoint_set_of_common_divisors