#include <bits/stdc++.h>
using namespace std;
/// Typedef
typedef long long           ll;
typedef vector<int>         vi;
typedef pair<int,int>       pii;

#define pb                  push_back
#define ppb                 pop_back
#define MP                  make_pair
#define ff                  first
#define ss                  second
#define sf                  scanf
#define pf                  printf
#define SQR(x)              ((x)*(x))
#define loop(i, y)          for(int i=0; i<int(y); i++)
#define FOR(i, x, y)        for(int i=int(x); i<int(y); i++)
#define ROF(i, x, y)        for(int i=int(x); i>=int(y); i--)
#define all(c)              c.begin(), c.end()
#define sz(c)               int(c.size())
#define clr(x, y)           memset(x, y, sizeof(x))
#define si(x)               scanf("%d", &x)
#define sii(x, y)           scanf("%d %d", &x, &y)
#define siii(x, y, z)       scanf("%d %d %d", &x, &y, &z)
#define sl(x)               scanf("%lld", &x)
#define sll(x, y)           scanf("%lld %lld", &x, &y)
#define slll(x, y, z)       scanf("%lld %lld %lld", &x, &y, &z)

#ifdef VAMP
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cout << name << " = " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cout.write(names, comma - names) << " = " << arg1 <<" | ";
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif
///******************************************START******************************************


template <class T> inline T bigMod(T p,T e,T M){ ll ret = 1; for(; e > 0; e >>= 1){ if(e & 1) ret = ((ll)ret * p) % M; p = ((ll)p * p) % M; } return (T) ret;}
template <class T> inline T modInv(T a,T M){return bigMod(a,M-2,M);}

/// Constants
#define MAX                 1003
#define MAXN                100005
#define MOD                 1000000007
#define eps                 1e-9
#define INF                 0x3f3f3f3f3f3f3f3f // 4,557,430,888,798,830,399
#define inf                 0x3f3f3f3f // 1,061,109,567
#define PI                  acos(-1.0)  // 3.1415926535897932
#define VT                  int

unordered_map<int, int> mp;
vector<int> divs;
int n, m;
int fact[MAXN], invFact[MAXN];

VT DP[30][MAX][MAX];
bool cc[30][MAX][MAX];

VT solve(int used, int pos, int make){
    if(!make) return (ll)fact[n] * invFact[n - used] % MOD;
    if(pos == sz(divs)) return 0;

    auto &ret = DP[used][pos][make];
    if(cc[used][pos][make]) return ret; cc[used][pos][make] = 1;

    ret = solve(used, pos+1, make);
    int x = divs[make], j = 1;
    while(x % divs[pos] == 0 and used + j <= n){
        ret = (ret + (ll)solve(used + j, pos + 1, mp[x/divs[pos]]) * invFact[j]) % MOD;
        x/=divs[pos];
        j++;
    }
    return ret;
}

int main(){
    #ifdef VAMP
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    sii(n, m);
    if(m == 1 or n == 1){
        printf("1\n");
        exit(0);
    }

    fact[0] = 1;
    FOR(i, 1, MAXN) fact[i] = (1LL * fact[i-1] * i) % MOD;
    invFact[MAXN - 1] = modInv(fact[MAXN - 1], MOD);
    ROF(i, MAXN - 2, 0) invFact[i] = (ll)invFact[i+1] * (i+1) % MOD;

    mp[1] = 0;
    divs.pb(1);
    for(int i = 2; i*i <= m; i++){
        if(m%i) continue;
        mp[i] = sz(divs);
        divs.pb(i);
        if(m/i != i){
            mp[m/i] = sz(divs);
            divs.pb(m/i);
        }
    }
    mp[m] = sz(divs);
    divs.pb(m);
    // for(auto x: divs){
    //     printf("%d ", x);
    // }
    // printf("\n");
    printf("%d\n", solve(0, 1, sz(divs) - 1));

    #ifdef VAMP
        fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif
    return 0;
}

Measured memory_bytes: 91136