program disjoint_set_of_common_divisors
  implicit none
  integer(8) :: a, b, g, p
  integer :: n, i, j, m = 1
  logical, allocatable :: u(:)
  read(*,*) a, b
  g = gcd(a,b)
  n = ceiling(sqrt(real(g,8)+0.5d0))
  allocate(u(n))
  u = .false.
  u(1) = .true.
  do i = 1, n
    if (u(i)) cycle
    do j = i, n, i
      u(j) = .true.
    end do
    p = int(i,8)
    if (mod(g,p) /= 0_8) cycle
    m = m+1
    do while (mod(g,p) == 0_8)
      g = g/p
    end do
  end do
  if (g /= 1_8) m = m+1
  write(*,'(i0)') m
contains
  integer(8) function gcd(a,b)
    integer(8), intent(in) :: a, b
    integer(8) :: x, y
    x = max(a,b)
    y = min(a,b)
    do while (y > 0_8)
      gcd = y
      y = mod(x,y)
      x = gcd
    end do
  end
end program disjoint_set_of_common_divisors