#include #include using namespace std; using mint=atcoder::modint1000000007; using mint1=atcoder::static_modint<1000000006>; int main() { int N,P; cin>>N>>P; mint a=1; mint1 b=1; for(int i=1;i<=N;i++) { a*=mint::raw(i); b*=mint1::raw(i); } a=a.pow(b.val()); mint c=0; while(N>=P)c+=N/=P; cout<<(a*c).val()<