#include #include using namespace std; int combination(int m, int i) { if (i == 0 || i == m) return 1; if (i == 1) return m; return combination(m - 1, i - 1) + combination(m - 1, i); } int main() { int n, m; cin >> n >> m; while (n >= m * 1000) n -= m * 1000; int i = 0; while (n >= 1000) { n -= 1000; i++; } cout << combination(m, min(i, m-i)) << endl; }