#include #include #include #include #include using namespace std; typedef long long ll; const int mod=1e9; int main(){ ll n,m; cin>>n>>m; ll a,b; a=n/1000; b=a%m; vector v; for(int i=0; i=m-b; --i){ v[i]=1; } set> s; do{ s.insert(v); } while(next_permutation(v.begin(),v.end())); int c; c=s.size()%mod; cout<