# Original solution
import sys
stdin = sys.stdin

def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from bisect import bisect_right

# nの逆元のリスト
def inv_mod(n:int, mod:int) -> list:
    inv = [0,1]
    for i in range(2,n+1):
        inv.append(mod - ((mod//i)*inv[mod%i]) % mod)
    return inv
       
# nの階乗のリスト
def fact(n:int, mod:int) -> list:
    fac = [1,1]
    res = 1
    for i in range(2,n+1):
        res = res*i%mod
        fac.append(res)
    return fac

# nの階乗の逆元のリスト
def fact_inv(n:int, inv:list, mod:int) -> list:
    facInv = [1,1]
    for i in range(2,n+1):
        facInv.append(facInv[i-1]*inv[i] % mod)
    return facInv
        

from collections import Counter

n,m = li()

MOD = 10**9+7

# 二項係数の準備
inv = inv_mod(n,MOD)
fac = fact(n,MOD)
facInv = fact_inv(n,inv,MOD)


# Mの素因数リストを作る

def cd(n:int):
    m = 2
    cds = set([n])
    while m*m <= n:
        if n%m == 0:
            cds.add(m)
            cds.add(n//m)
            
        m += 1

    return sorted(list(cds))
    
cds = cd(m)

memo = []

def dfs(m: int, cds: list, res:int,st:list):
    if res == 1:
        memo.append(st)
        
    else:
        idx = bisect_right(cds,st[-1])
        for cdi in cds[:idx]:
            if cdi > st[-1]:
                pass
            else:
                if res%cdi == 0:
                    dfs(m,cds,res//cdi,st+[cdi])
                

# 辞書順にmを作れるオリジナルなセットを作る
for cdi in cds:
    dfs(m,cds,m//cdi,[cdi])


ans = 0
for memoi in memo:
    cnt = Counter(memoi)
    cnt_v = [ci for ci in list(cnt.values()) if ci > 1]
    temp = fac[n]
    if len(memoi) <= n:
        for cnt_vi in cnt_v:
            temp = (temp*facInv[cnt_vi]) % MOD
        temp = (temp*facInv[n-len(memoi)]) % MOD
    
    ans = (ans+temp) % MOD
        
if m==1 or n==1:
    print((1))
else:
    print((ans%MOD))

# Optimized solution
import sys
stdin = sys.stdin

def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import Counter

# nの逆元のリスト
def inv_mod(n:int, mod:int) -> list:
    inv = [0,1]
    for i in range(2,n+1):
        inv.append(mod - ((mod//i)*inv[mod%i]) % mod)
    return inv
       
# nの階乗のリスト
def fact(n:int, mod:int) -> list:
    fac = [1,1]
    res = 1
    for i in range(2,n+1):
        res = res*i%mod
        fac.append(res)
    return fac

# nの階乗の逆元のリスト
def fact_inv(n:int, inv:list, mod:int) -> list:
    facInv = [1,1]
    for i in range(2,n+1):
        facInv.append(facInv[i-1]*inv[i] % mod)
    return facInv
        
# 二項係数
def nCr(n:int, r:int, mod:int, fac:list, facInv:list) -> int:
    if not (0<=r and r<=n):
        return 0
    
    return ((fac[n]*facInv[r]) % mod) * facInv[n-r] % mod

def factorize(n: int):
    d = Counter()
    m= 2
    
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
            
        m += 1
        
    if n > 1:
        d[n] += 1
        
    return d


n,m = li()

MOD = 10**9+7

# 二項係数の準備
inv = inv_mod(n+100,MOD)
fac = fact(n+100,MOD)
facInv = fact_inv(n+100,inv,MOD)


primes = factorize(m)
ans = 1

if n == 1 or m == 1:
    print(ans)
else:
    for pi in list(primes.values()):
        ans = ans * nCr(n+pi-1, pi, MOD, fac, facInv) % MOD
    print(ans)