#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <array>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <cstring>
#include <unordered_map>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

constexpr int m = 1000000000;
int comb[10001][10001];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll N, M;
    cin >> N >> M;
    N = N / 1000 % M;

    comb[0][0] = 1;
    for(int i = 1; i <= M; ++i) comb[i][0] = comb[i][i] = 1;
    for(int i = 2; i <= M; ++i){
        for(int j = 1; j < i; ++j){
            comb[i][j] = (comb[i - 1][j - 1] + comb[i - 1][j]) % m;
        }
    }

    cout << comb[M][N] << endl;

    return 0;
}