module Factwithmod
  implicit none
  integer(16),allocatable,dimension(:)::Kaijo
  contains
subroutine initiationFactorial(maxnum,mo)
  implicit none
  integer(16)::maxnum
  integer(16)::mo
  integer(16)::i

  allocate(Kaijo(0:maxnum))
  Kaijo(0)=1
  do i=1,maxnum
    Kaijo(i)=mod(Kaijo(i-1)*i,mo)
  end do
end subroutine

function combination(n,k,l)
implicit none
integer(16),intent(in)::n,k,l
integer combination

combination=mod(Kaijo(N)*inv(Kaijo(K),l)*inv(Kaijo(N-K),l),l)

end function

function inv(K,L)
integer(16),intent(in)::k,l
integer(16) l2,y
integer(16) inv
inv=1
l2=l-2
y=k
do
  if(mod(l2,2)==1)inv=mod(inv*y,l)
  y=mod(y*y,l)
  l2=l2/2
  if(l2==0)exit
end do
end function

function permutation(n,k,mo)
implicit none
  integer(16)::n,k
  integer(16)::mo,permutation
  permutation=mod(Kaijo(N)*inv(Kaijo(N-K),mo),mo)
end function
end module
program speedrun
   use Factwithmod
   implicit none
   integer(16)::N,M
   integer(16)::mo=10**9+7
   integer(16)::ANS=1,CNT
   integer(16)::i,j
   read*,N,M
   do i=2,int(sqrt(real(M+1)))
      CNT=0
      if(M==1)exit
      if(mod(M,i)/=0)cycle
      do while(mod(M,i)==0)
         CNT=CNT+1
         M=M/i
      end do
      do j=1,CNT
         ANS=mod(ANS*(CNT+N-j)*inv(j,mo),mo)
      end do
      ANS=mod(ANS,mo)
   end do
   if(M/=1)ANS=ANS*N
   ANS=mod(ANS,mo)
   print"(I0)",ANS
end program speedrun