#include<iostream>
//#include<algorithm>
using namespace std;
typedef long long ll;
int quick_power_mod(int a,int b,int m)//pow(a,b)%m
{
int result = 1;
int base = a;
while(b>0)
{
if(b&1==1)
result=(result*base)%m;
base=(base*base)%m;
b>>=1;
}
return result;
}
//计算组合数取模
ll comp(ll a,ll b,int p)//composite num C(a,b)%p
{
if(a<b)return 0;
if(a==b)return 1;
if(b>a-b)b=a-b;
int ans=1,ca=1,cb=1;
for(ll i=0;i<b;i++)
{
ca=(ca*(a-i))%p;
cb=(cb*(b-i))%p;
}
ans=(ca*quick_power_mod(cb,p-2,p))%p;
return ans;
}
ll lucas(ll n,ll m,ll p)
{
ll ans=1;
while(n&&m&&ans)
{
ans=(ans*comp(n%p,m%p,p))%p;//also can be recusive
n/=p;
m/=p;
}
return ans;
}
int main()
{
ll m,n;
while(cin>>n>>m)
cout<<lucas(n,m,10007)<<endl;
return 0;
}