import sys import pypyjit import itertools import heapq import math from collections import deque, defaultdict import bisect input = sys.stdin.readline sys.setrecursionlimit(10 ** 6) pypyjit.set_param('max_unroll_recursion=-1') def index_lt(a, x): 'return largest index s.t. A[i] < x or -1 if it does not exist' return bisect.bisect_left(a, x) - 1 def index_le(a, x): 'return largest index s.t. A[i] <= x or -1 if it does not exist' return bisect.bisect_right(a, x) - 1 def index_gt(a, x): 'return smallest index s.t. A[i] > x or len(a) if it does not exist' return bisect.bisect_right(a, x) def index_ge(a, x): 'return smallest index s.t. A[i] >= x or len(a) if it does not exist' return bisect.bisect_left(a, x) class Matpow: def __init__(self, N, A, p): self.N = N self.A = A self.p = p self.digit = 60 self.doubling = [None] * self.digit self.doubling[0] = A for i in range(1, self.digit): self.doubling[i] = self.mul(self.doubling[i - 1], self.doubling[i - 1]) def pow(self, n): E = [[1 if i == j else 0 for j in range(self.N)] for i in range(self.N)] acc = E for k in range(self.digit): if n & (1 << k): acc = self.mul(acc, self.doubling[k]) return acc def mul(self, A, B): C = [[0 for _ in range(self.N)] for _ in range(self.N)] for i in range(self.N): for j in range(self.N): for k in range(self.N): C[i][j] += A[i][k] * B[k][j] C[i][j] %= self.p return C N, M = map(int, input().split()) mod = 10 ** 9 + 7 n = M factors = defaultdict(int) for i in range(2, M + 1): if i * i > M: break while n % i == 0: factors[i] += 1 n //= i if n > 1: factors[n] += 1 ans = 1 for v in factors.values(): A = [] for i in range(v + 1): a = [1] * (v + 1 - i) + [0] * i A.append(a) An = Matpow(v + 1, A, mod).pow(N - 1) acc = 0 for i in range(v + 1): for j in range(v + 1): acc += An[i][j] ans *= acc ans %= mod print(ans)