program main
  implicit none
  integer(8) i,A,B,ans,d
  integer div(11)
  read(*, *)A,B
  !read(*, *) (L(i), i = 1,N)
  div = (/2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31/)
  ans = 1
  d = div(i)
  do i = 1,11
    d = div(i)
    if (mod(A,d)==0 .and. mod(B,d)==0) then
      ans = ans + 1
    end if
  end do

  write(*, *) ans
end program main
