import java.io.*; import java.util.*; import java.util.function.*; import java.util.stream.*; public class Main { static final int MOD = 1000000007; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt() + 1; long m = sc.nextLong(); List divs = new ArrayList<>(); for (long i = 1; i * i <= m; i++) { if (m % i == 0) { divs.add(i); if (i * i < m) { divs.add(m / i); } } } int size = divs.size(); long[][][] matrix = new long[20][size][size]; for (int i = 0; i < size; i++) { long current = m / divs.get(i); for (int j = 0; j < size; j++) { if (current % divs.get(j) == 0) { matrix[0][i][j] = 1; } } } for (int i = 1; i < 20; i++) { for (int a = 0; a < size; a++) { for (int b = 0; b < size; b++) { for (int c = 0; c < size; c++) { matrix[i][a][c] += matrix[i - 1][a][b] * matrix[i - 1][b][c] % MOD; matrix[i][a][c] %= MOD; } } } } long[] ans = new long[size]; ans[0] = 1; for (int i = 19; i >= 0; i--) { if (n < (1 << i)) { continue; } n -= (1 << i); long[] next = new long[size]; for (int a = 0; a < size; a++) { for (int b = 0; b