using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
 
class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        long yosan = long.Parse(Reader.ReadLine()) / 1000;
        int ninzu = int.Parse(Reader.ReadLine());
        long hitori = yosan / ninzu;
        long amari = yosan % ninzu;
        
        this.CreatePrimeNumberList(ninzu);
        
        long ans = 1;
        if(amari > 0) {
            Dictionary<long, long> total = new Dictionary<long, long>();
            for(int i=0; i<amari; i++) {
                Dictionary<long, long> tmpDic = this.GetSoinsu(ninzu-i);
                List<long> keyList = new List<long>(tmpDic.Keys);
                keyList.ForEach((a)=>{
                if(total.ContainsKey(a)) {
                    total[a]+=tmpDic[a];
                } else
                {
                    total.Add(a, tmpDic[a]);
                }
                });
            }
            Dictionary<long, long> ordTotal = new Dictionary<long, long>();
            for(long i=2; i<=amari; i++) {
               Dictionary<long, long> tmp = this.GetSoinsu(i);
               foreach (long key in tmp.Keys)
               {
                   if(ordTotal.ContainsKey(key)) {
                       ordTotal[key]+=tmp[key];
                   } else
                   {
                       ordTotal.Add(key, tmp[key]);
                   }
               }
            }
            List<long> keyList2 = new List<long>(ordTotal.Keys);
            keyList2.ForEach((a)=>{
                total[a] -= ordTotal[a]; 
            });
            
            foreach (long key in total.Keys)
            {
                for(int i=0; i<total[key]; i++) {
                    ans *= key;
                    ans = ans % 1000000000;
                }
            }
        }
        Console.WriteLine(ans);
     }
     private Dictionary<long, long> GetSoinsu(long num) {
         Dictionary<long, long> dic = new Dictionary<long, long>();
         long current = num;
         foreach (int prime in this.PrimeNumberList)
         {
             while (current % prime == 0)
             {
                 if(!dic.ContainsKey(prime)) {
                     dic.Add(prime, 0);
                 }
                 dic[prime]++;
                 current = current / prime;
                 if(current == 1) {
                     break;
                 }
             }
             if(current == 1) {
                 break;
             }
         }
         return dic;
     }
     
     private List<int> PrimeNumberList = new List<int>();
     private void CreatePrimeNumberList(int num) {
         bool[] flag = new bool[num+1];
         List<int> primeNumbers = new List<int>();
         for(int i=2; i<=num; i++) {
             if(!flag[i]) {
                 primeNumbers.Add(i);
                 for(int j=1; j<=num/i; j++) {
                     flag[i*j] = true;
                 }
             }
         }
         this.PrimeNumberList = primeNumbers;
     }
    

    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"


24500
9


 
";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        public static int[] GetInt(char delimiter = ' ', bool trim = false)
        {
            string inptStr = ReadLine();
            if (trim)
            {
                inptStr = inptStr.Trim();
            }
            string[] inpt = inptStr.Split(delimiter);
            int[] ret = new int[inpt.Length];
            for (int i = 0; i < inpt.Length; i++)
            {
                ret[i] = int.Parse(inpt[i]);
            }
            return ret;
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}