import sys #sys.setrecursionlimit(n) import heapq import re import bisect import random import math import itertools from collections import defaultdict, deque from copy import deepcopy from decimal import * n = int(input()) m = int(input()) def nCm(n, m): return math.factorial(n) // (math.factorial(m) * (math.factorial(n - m))) s = n s -= n // (m * 1000) * 1000 * 9 ss = s // 1000 if ss > 0: print(nCm(m,ss) % 1000000000) else: print(1)