#include int C(int n, int r){ int i, j, tr; int tmp[10010]={0}; long long int sum = 1; if( n < r ){return 0;} for(i=n;i>1;i--){ if( r == i ){break;} if( (n-r) == i ){break;} tmp[i] = i; } tr = n-i; for(i=2;i<=tr;i++){ for(j=n;j>1;j--){ if(tmp[j]%i == 0){ tmp[j] /= i; } } } for(i=1;i<=n;i++){ if(tmp[i] != 0){ sum = (sum*tmp[i])% 1000000000; } } return (int)(sum); } int main(void){ long long int n,m,r; n=24500; m=9; scanf("%I64d", &n); scanf("%I64d", &m); r = (n / 1000) % m; printf("%d\n", C((int)m,(int)r)); return 0; }