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

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

    if (gcd > 1_8) count=count+1_8

    print*,count+1_8

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

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

end function
end program disjoint_set_of_common_divisors