#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
using namespace std;
typedef long long LL;

const LL MOD=1000000000;

LL mod_comb(LL n, LL m){
    vector<LL> prev(m+1);
    vector<LL> next(m+1);
    prev[0] = 1;
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= m; j++){
            next[j] += prev[j];
            next[j] %= MOD;
        }
        for(int j = 0; j < m; j++){
            next[j+1] += prev[j];
            next[j+1] %= MOD;
        }
        next.swap(prev);
        for(int i = 0; i < next.size(); i++){
            next[i] = 0;
        }
    }
    return prev[m];
}

int main(){
    LL N, M;
    cin >> N >> M;
    LL cnt = (N/1000) % M;
    cout << mod_comb(M, cnt) << endl;
    return 0;
}