program main
    implicit none
    integer,pointer:: an(:),bn(:)
    integer(8):: a,b,i,j,ans
    read*, a,b
    allocate(an(1),bn(1))
    call calc_pn(a,an)
    call calc_pn(b,bn)
    ! print*, an
    ! print*, bn
    j=1
    ans = 1
    do i =1,size(an)
        if (an(i) == 0)cycle
        do while(bn(j) < an(i))
            j = j + 1
        end do
        if (bn(j) == an(i)) ans=ans+1
    end do

    print*, ans

contains
subroutine calc_pn(num,pn_list)
    integer, pointer:: pn_list(:)
    integer(8):: num
    integer:: p,i
    p = 0
    do i = 2, int(sqrt(real(num)))
        if (mod(num,i)/=0) cycle
        p = p + 1
        if (p > size(pn_list)) call append(pn_list)
        pn_list(p) = i
        do while(mod(num,i) == 0)
            num= num/i
        end do
    end do
    if (num == 1)return
    p = p + 1
    if (p > size(pn_list)) call append(pn_list)
    pn_list(p) = int(num)
    
    
end subroutine 



subroutine append(arr) 
    integer, pointer:: arr(:)
    integer, pointer:: tmp(:)
    integer:: size_
    size_ = size(arr)
    allocate(tmp(size_))
    tmp(1:size_) = arr(1:size_)
    deallocate(arr)
    allocate(arr(2*size_))
    arr(1:size_) = tmp(1:size_)
    arr(size_+1:2*size_) = 0
    deallocate(tmp)
    return
end subroutine


end program