using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Schema;

namespace Codeforces
{
    internal static class Program
    {
        private const string Problem = "c";

        private static void Solve()
        {
            int n, k, d;
            Read(out n, out k, out d);
            var mod = 1000000007;
            var dp = new int[n + 1, 2];
            dp[0, 0] = 1;

            for (int i = 1; i <= n; i++)
            {
                var maxJ = Math.Min(k, i);
                for (int j = 1; j <= maxJ; j++)
                {
                    dp[i, 0] += dp[i - j, 0]%mod;
                    dp[i, 0] %= mod;
                    if (j >= d)
                    {
                        dp[i, 1] += dp[i - j, 0]%mod;
                        dp[i, 1] %= mod;
                    }
                    else
                    {
                        dp[i, 1] += dp[i - j, 1] % mod;
                        dp[i, 1] %= mod;
                    }
                }
            }
            WriteLine(dp[n, 1]);
        }

        private static void Main()
        {
            var isDebbuger = Debugger.IsAttached;
            if (isDebbuger)
            {
                var projectPath = Directory.GetParent(Environment.CurrentDirectory).Parent;
                var testsPath = Path.Combine(projectPath != null? projectPath.FullName: "", "tests");
                var files = Directory.GetFiles(testsPath, string.Format("{0}*.in", Problem));

                foreach (var file in files)
                {
                    Console.SetIn(new StreamReader(file));
                    Console.WriteLine(Path.GetFileNameWithoutExtension(file));
                    Solve();

                    Console.WriteLine();

                    Console.In.Close();
                    Console.SetIn(new StreamReader(Console.OpenStandardInput()));
                }

                Console.ReadLine();
            }
            else
                Solve();
        }

        private static int[] SortIndexs<T>(this IEnumerable<T> source) where T : IComparable
        {
            var array = source == null ? new List<T>() : source.ToList();
            var n = array.Count;
            var res = Enumerable.Range(0, n).ToArray();
            Array.Sort(res, (a, b) =>
            {
                var compare = array[a].CompareTo(array[b]);
                return compare == 0 ? a.CompareTo(b) : compare;
            });
            return res;
        }

        #region Reader

        private static string Read()
        {
            return Console.ReadLine();
        }

        private static void Read<T>(out T a1, out T a2)
        {
            var input = ReadArray();
            a1 = (T)Convert.ChangeType(input[0], typeof(T));
            a2 = (T)Convert.ChangeType(input[1], typeof(T));
        }

        private static void Read<T>(out T a1, out T a2, out T a3)
        {
            var input = ReadArray();
            a1 = (T)Convert.ChangeType(input[0], typeof(T));
            a2 = (T)Convert.ChangeType(input[1], typeof(T));
            a3 = (T)Convert.ChangeType(input[2], typeof(T));
        }

        private static void Read<T>(out T a1, out T a2, out T a3, out T a4)
        {
            var input = ReadArray();
            a1 = (T)Convert.ChangeType(input[0], typeof(T));
            a2 = (T)Convert.ChangeType(input[1], typeof(T));
            a3 = (T)Convert.ChangeType(input[2], typeof(T));
            a4 = (T)Convert.ChangeType(input[3], typeof(T));
        }

        private static void Read<T>(out T a1, out T a2, out T a3, out T a4, out T a5)
        {
            var input = ReadArray();
            a1 = (T)Convert.ChangeType(input[0], typeof(T));
            a2 = (T)Convert.ChangeType(input[1], typeof(T));
            a3 = (T)Convert.ChangeType(input[2], typeof(T));
            a4 = (T)Convert.ChangeType(input[3], typeof(T));
            a5 = (T)Convert.ChangeType(input[4], typeof(T));
        }

        private static void Read<T>(out T a1, out T a2, out T a3, out T a4, out T a5, out T a6)
        {
            var input = ReadArray();
            a1 = (T)Convert.ChangeType(input[0], typeof(T));
            a2 = (T)Convert.ChangeType(input[1], typeof(T));
            a3 = (T)Convert.ChangeType(input[2], typeof(T));
            a4 = (T)Convert.ChangeType(input[3], typeof(T));
            a5 = (T)Convert.ChangeType(input[4], typeof(T));
            a6 = (T)Convert.ChangeType(input[5], typeof(T));
        }

        private static int ReadInt()
        {
            return Int32.Parse(Read());
        }

        private static long ReadLong()
        {
            return long.Parse(Read());
        }

        private static double ReadDouble()
        {
            return double.Parse(Read(), CultureInfo.InvariantCulture);
        }

        private static T Read<T>()
        {
            return (T)Convert.ChangeType(Read(), typeof(T));
        }

        private static string[] ReadArray()
        {
            var readLine = Console.ReadLine();
            if (readLine != null)
                return readLine.Split(' ');

            throw new ArgumentException();
        }

        private static List<int> ReadIntArray()
        {
            return ReadArray().Select(Int32.Parse).ToList();
        }

        private static List<long> ReadLongArray()
        {
            return ReadArray().Select(long.Parse).ToList();
        }

        private static List<double> ReadDoubleArray()
        {
            return ReadArray().Select(d => double.Parse(d, CultureInfo.InvariantCulture)).ToList();
        }

        private static List<T> ReadArray<T>()
        {
            return ReadArray().Select(x => (T)Convert.ChangeType(x, typeof(T))).ToList();
        }

        private static void WriteLine(double value)
        {
            Console.WriteLine(value.ToString(CultureInfo.InvariantCulture));
        }

        private static void WriteLine(double value, string stringFormat)
        {
            Console.WriteLine(value.ToString(stringFormat, CultureInfo.InvariantCulture));
        }

        private static void WriteLine<T>(T value)
        {
            Console.WriteLine(value);
        }

        private static void Write(double value)
        {
            Console.Write(value.ToString(CultureInfo.InvariantCulture));
        }

        private static void Write(double value, string stringFormat)
        {
            Console.Write(value.ToString(stringFormat, CultureInfo.InvariantCulture));
        }

        private static void Write<T>(T value)
        {
            Console.Write(value);
        }

        #endregion
    }
}


using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApplication3
{
    internal class Program
    {
        private static void Main()
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var n = input[0];
            var k = input[1];
            var d = input[2];

            Console.WriteLine(Solve(n, k, d, false, new Cache()));
        }

        private static int Solve(int n, int k, int d, bool hasD, Cache cache)
        {
            var key = new Tuple<int, bool>(n, hasD);
            if (cache.ContainsKey(key))
                return cache[key];
            if (n == 0)
                return hasD ? 1 : 0;

            var res = 0;
            for (var i = 1; i <= Math.Min(n, k); i++)
                res = (res + Solve(n - i, k, d, hasD | i >= d, cache))%1000000007;

            return cache[key] = res;
        }

        class Cache : Dictionary<Tuple<int, bool>, int>
        {

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Codeforces_247_2
{
    class Program
    {
        static long[,] cache;
        static long Count(int n, int k)
        {
            long ret = cache[n, k];
            if (ret < 0)
            {
                ret = 0;
                for (int i = 1; i <= k; ++i) {
                    if (n > i) {
                        ret = (ret + Count(n - i, k)) % 1000000007;
                    }
                    else if (n == i) {
                        ret = ret + 1;
                    }
                }
                cache[n, k] = ret;
            }
            return ret;
        }
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]);
            int k = int.Parse(s[1]);
            int d = int.Parse(s[2]);
            cache = new long[n + 1, k + 1];
            for (int i = 0; i <= n; ++i) for (int j = 0; j <= k; ++j) cache[i, j] = -1;
            Console.WriteLine((1000000007 + Count(n, k) - Count(n, d - 1)) % 1000000007);
        }
    }
}


using System;
using System.IO;
using System.Text;

namespace k_Tree
{
    internal class Program
    {
        private const long TTT = 1000000007;

        private static readonly StreamReader reader =
            new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);

        private static readonly StreamWriter writer =
            new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            string[] ss = reader.ReadLine().Split(' ');
            int n = int.Parse(ss[0]);
            int k = int.Parse(ss[1]);
            int d = int.Parse(ss[2]);

            var kgood = new long[n + 1];
            var kbad = new long[n + 1];
            long sum = 0;
            for (int i = 1; i <= k && i <= n; i++)
            {
                if (i >= d)
                {
                    kgood[i] = 1;
                }
                else
                    kbad[i] = 1;
            }
            sum = (sum + kgood[n])%TTT;

            for (int j = 1; j <= n; j++)
            {
                var kgood1 = new long[n + 1];
                var kbad1 = new long[n + 1];

                for (int i = 1; i <= n; i++)
                {
                    for (int l = 1; l <= k; l++)
                    {
                        if (i + l > n)
                            break;

                        kgood1[l + i] += kgood[i];
                        if (l >= d)
                        {
                            kgood1[l + i] += kbad[i];
                        }
                        else
                        {
                            kbad1[l + i] += kbad[i];
                        }
                    }
                }
                sum = (sum + kgood1[n])%TTT;
                for (int i = 1; i <= n; i++)
                {
                    kbad[i] = kbad1[i]%TTT;
                    kgood[i] = kgood1[i]%TTT;
                }
            }

            writer.WriteLine("{0}", sum);
            writer.Flush();
        }
    }
}


using System;

class C431 {
    const int M = 1000000007;

    public static void Main() {
        var line = Console.ReadLine().Split();
        var n = int.Parse(line[0]);
        var k = int.Parse(line[1]);
        var d = int.Parse(line[2]);
        var a = new long[n + 1];
        var b = new long[n + 1];
        a[0] = 1L;
        b[0] = 0L;
        for (int i = 1; i <= n; ++i) {
            var a1 = i - k >= 1 ? a[i - k - 1] : 0L;
            var a2 = i >= d ? a[i - d] : 0L;
            var b2 = i >= d ? b[i - d] : 0L;
            a[i] = (a[i - 1] + (a[i - 1] + M - a1)) % M;
            b[i] = (b[i - 1] + (b[i - 1] + M - b2) + (a2 + M - a1)) % M;
        }
        Console.WriteLine((b[n] + M - b[n - 1]) % M);
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication34
{

    class Program
    {
        static void Main(string[] args)
        {
            int i = 1;
            string[] arr = Console.ReadLine().Split();
            int a = int.Parse(arr[0]);
            int b = int.Parse(arr[1]);
            a = a * 100;
            b = b * 10;
            while (true)
            {

                if (i % 2 != 0)
                {
                    if (a >= 200)
                    {
                        if (b >= 20)
                        {
                            a -= 200;
                            b -= 20;
                        }
                        else
                        {
                            Console.WriteLine("Hanako");return;
                        }
                    }
                    else if (a == 100)
                    {

                        if (b >= 120)
                        {
                            a -= 100;
                            b -= 120;
                        }
                        else
                        {
                            Console.WriteLine("Hanako"); return;
                        }
                    }
                    else if (a < 100)
                    {
                        if (b >= 220)
                            b -= 220;
                        else
                        {
                            Console.WriteLine("Hanako"); return;
                        }
                    }
                }

                if (i % 2 == 0)
                {
                    if (b >= 220)
                    {
                        b -= 220;
                    }
                    else if (b < 220 && b >= 120)
                    {
                        if (a >= 100)
                        {
                            a -= 100;
                            b -= 120;
                        }
                        else
                        {
                            Console.WriteLine("Ciel"); return;
                        }
                    }
                    else if (b >= 20)
                    {
                        if (a >= 200)
                        {
                            a -= 200;
                            b -= 20;
                        }
                        else
                        {
                            Console.WriteLine("Ciel"); return;
                        }
                    }
                    else
                    {
                        Console.WriteLine("Ciel"); return;
                    }
                }
                i++;
            }

        }

    }
 }


using System;
using System.Collections.Generic;
using System.Text;

namespace A.Theatre_Square
{
    class Program
    {

        static void Main(string[] args)
        {
            int[,] step = { { 2, 2 }, { 1, 12 }, { 0, 22 } };
            string[] data = Console.ReadLine().Split(' ');
            int n = Int32.Parse(data[0]);
            int m = Int32.Parse(data[1]);
            bool isEnd = false;
            bool turn = false;
            while (!isEnd)
            {
                if (!turn)
                {
                    for (int i = 0; i < 3; i++)
                    {

                        if (n >= step[i, 0] && m >= step[i, 1])
                        {
                            n -= step[i, 0];
                            m -= step[i, 1];
                            goto next;
                        }

                    }
                    isEnd = true;
                }
                else
                {
                    for (int i = 2; i >=0; i--)
                    {

                        if (n >= step[i, 0] && m >= step[i, 1])
                        {
                            n -= step[i, 0];
                            m -= step[i, 1];
                            goto next;
                        }

                    }
                    isEnd = true;
                }
            next: turn = !turn;
            }

            if (turn)
            {
                Console.WriteLine("Hanako");
            }
            else
            {
                Console.WriteLine("Ciel");
            }
            Console.ReadKey();
        }

    }
}


using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    ReadData re;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        re = new ReadData();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        long H = re.l();
        long W = re.l();
        if(H == 1 || W == 1){
            H = Math.Max(H,W);
            long count = H / 6 * 6;
            if(H % 6 == 4){
                count += 2;
            }
            if(H % 6 == 5){
                count += 4;
            }
            sb.Append(count + "\n");
            return;
        }
        if(H >= 3 && W >= 3){
            sb.Append(H*W/2*2+"\n");
            return;
        }
        if(H != 2){
            W = H;
            H = 2;
        }
        if(W == 2){
            sb.Append("0\n");
            return;
        }
        else if(W == 3){
            sb.Append("4\n");
            return;
        }
        else if(W == 7){
            sb.Append("12\n");
            return;
        }
        sb.Append((W*2)+"\n");
    }
}
class PrimeFactor{
    int[] LowestPrimeFactor;
    public int[] Prime;
    int N;
    public PrimeFactor(int N0){
        N = N0;
        N++;
        LowestPrimeFactor = new int[N];
        List<int> prime = new List<int>();
        for(int i=1;i<N;i++){
            LowestPrimeFactor[i] = i;
        }
        for(int i=2;i<N;i++){
            if(LowestPrimeFactor[i] == i){
                prime.Add(i);
            }
            for(int j=0;j<prime.Count;j++){
                if(prime[j]*i < N && prime[j] <= LowestPrimeFactor[i]){
                    LowestPrimeFactor[prime[j]*i] = prime[j];
                }
                else{
                    break;
                }
            }
        }
        Prime = prime.ToArray();
    }
    public int[] PrimeDivide(int X){
        List<int> ans = new List<int>();
        while(X != 1){
            ans.Add(LowestPrimeFactor[X]);
            X /= LowestPrimeFactor[X];
        }
        return ans.ToArray();
    }
    public int[] PrimeDivide(long X0){
        List<int> ans = new List<int>();
        int X = (int)X0;
        int i=0;
        while(X >= N){
            if(X % Prime[i] == 0){
                ans.Add(Prime[i]);
                X /= Prime[i];
            }
            else{
                i++;
                if(i == Prime.Length){
                    ans.Add(X);
                    X = 1;
                }
            }
        }
        while(X != 1){
            ans.Add(LowestPrimeFactor[X]);
            X /= LowestPrimeFactor[X];
        }
        return ans.ToArray();
    }
    public int[] Divisor(int X){
        List<int> ans = new List<int>();
        ans.Add(1);
        while(X != 1){
            int p = LowestPrimeFactor[X];
            int c = 0;
            while(X % p == 0){
                X /= p;
                c++;
            }
            int l = ans.Count;
            int d = p;
            for(int i=1;i<=c;i++){
                for(int j=0;j<l;j++){
                    ans.Add(d*ans[j]);
                }
                d *= p;
            }
        }
        return ans.ToArray();
    }
    public int[] Divisor(long X0){
        List<int> ans = new List<int>();
        int X = (int)X0;
        ans.Add(1);
        int i=0;
        while(X >= N){
            if(X % Prime[i] == 0){
                int p = Prime[i];
                int c = 0;
                while(X % p == 0){
                    X /= p;
                    c++;
                }
                int l = ans.Count;
                int d = p;
                for(int k=1;k<=c;k++){
                    for(int j=0;j<l;j++){
                        ans.Add(d*ans[j]);
                    }
                    d *= p;
                }
            }
            else{
                i++;
                if(i == Prime.Length){
                    int l = ans.Count;
                    for(int j=0;j<l;j++){
                        ans.Add(X*ans[j]);
                    }
                    X = 1;
                }
            }
        }
        while(X != 1){
            int p = LowestPrimeFactor[X];
            int c = 0;
            while(X % p == 0){
                X /= p;
                c++;
            }
            int l = ans.Count;
            int d = p;
            for(int k=1;k<=c;k++){
                for(int j=0;j<l;j++){
                    ans.Add(d*ans[j]);
                }
                d *= p;
            }
        }
        return ans.ToArray();
    }
    public int Phi(int X){
        int ans = X;
        while(X != 1){
            int p = LowestPrimeFactor[X];
            while(X % p == 0){
                X /= p;
            }
            ans /= p;
            ans *= p-1;
        }
        return ans;
    }
    public int Phi(long X0){
        int ans = (int)X0;
        int X = (int)X0;
        int i=0;
        while(X >= N){
            if(X % Prime[i] == 0){
                int p = Prime[i];
                while(X % p == 0){
                    X /= p;
                }
                ans /= p;
                ans *= p-1;
            }
            else{
                i++;
                if(i == Prime.Length){
                    int p = X;
                    ans /= p;
                    ans *= p-1;
                    X = 1;
                }
            }
        }
        while(X != 1){
            int p = LowestPrimeFactor[X];
            while(X % p == 0){
                X /= p;
            }
            ans /= p;
            ans *= p-1;
        }
        return ans;
    }
}
class ReadData{
    string[] str;
    int counter;
    public ReadData(){
        counter = 0;
    }
    public string s(){
        if(counter == 0){
            str = Console.ReadLine().Split(' ');
            counter = str.Length;
        }
        counter--;
        return str[str.Length-counter-1];
    }
    public int i(){
        return int.Parse(s());
    }
    public long l(){
        return long.Parse(s());
    }
    public double d(){
        return double.Parse(s());
    }
    public int[] ia(int N){
        int[] ans = new int[N];
        for(int j=0;j<N;j++){
            ans[j] = i();
        }
        return ans;
    }
    public int[] ia(){
        str = Console.ReadLine().Split(' ');
        counter = 0;
        int[] ans = new int[str.Length];
        for(int j=0;j<str.Length;j++){
            ans[j] = int.Parse(str[j]);
        }
        return ans;
    }
    public long[] la(int N){
        long[] ans = new long[N];
        for(int j=0;j<N;j++){
            ans[j] = l();
        }
        return ans;
    }
    public long[] la(){
        str = Console.ReadLine().Split(' ');
        counter = 0;
        long[] ans = new long[str.Length];
        for(int j=0;j<str.Length;j++){
            ans[j] = long.Parse(str[j]);
        }
        return ans;
    }
    public double[] da(int N){
        double[] ans = new double[N];
        for(int j=0;j<N;j++){
            ans[j] = d();
        }
        return ans;
    }
    public double[] da(){
        str = Console.ReadLine().Split(' ');
        counter = 0;
        double[] ans = new double[str.Length];
        for(int j=0;j<str.Length;j++){
            ans[j] = double.Parse(str[j]);
        }
        return ans;
    }
    public List<int>[] g(int N,int[] f,int[] t){
        List<int>[] ans = new List<int>[N];
        for(int j=0;j<N;j++){
            ans[j] = new List<int>();
        }
        for(int j=0;j<f.Length;j++){
            ans[f[j]].Add(t[j]);
            ans[t[j]].Add(f[j]);
        }
        return ans;
    }
    public List<int>[] g(int N,int M){
        List<int>[] ans = new List<int>[N];
        for(int j=0;j<N;j++){
            ans[j] = new List<int>();
        }
        for(int j=0;j<M;j++){
            int f = i()-1;
            int t = i()-1;
            ans[f].Add(t);
            ans[t].Add(f);
        }
        return ans;
    }
    public List<int>[] g(){
        int N = i();
        int M = i();
        List<int>[] ans = new List<int>[N];
        for(int j=0;j<N;j++){
            ans[j] = new List<int>();
        }
        for(int j=0;j<M;j++){
            int f = i()-1;
            int t = i()-1;
            ans[f].Add(t);
            ans[t].Add(f);
        }
        return ans;
    }
}
public static class Define{
    public const long mod = 1000000007;
}
public static class Debug{
    public static void Print(double[,,] k){
        for(int i=0;i<k.GetLength(0);i++){
            for(int j=0;j<k.GetLength(1);j++){
                for(int l=0;l<k.GetLength(2);l++){
                    Console.Write(k[i,j,l]+" ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
    public static void Print(double[,] k){
        for(int i=0;i<k.GetLength(0);i++){
            for(int j=0;j<k.GetLength(1);j++){
                Console.Write(k[i,j]+" ");
            }
            Console.WriteLine();
        }
    }
    public static void Print(double[] k){
        for(int i=0;i<k.Length;i++){
            Console.WriteLine(k[i]);
        }
    }
    public static void Print(long[,,] k){
        for(int i=0;i<k.GetLength(0);i++){
            for(int j=0;j<k.GetLength(1);j++){
                for(int l=0;l<k.GetLength(2);l++){
                    Console.Write(k[i,j,l]+" ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
    public static void Print(long[,] k){
        for(int i=0;i<k.GetLength(0);i++){
            for(int j=0;j<k.GetLength(1);j++){
                Console.Write(k[i,j]+" ");
            }
            Console.WriteLine();
        }
    }
    public static void Print(long[] k){
        for(int i=0;i<k.Length;i++){
            Console.WriteLine(k[i]);
        }
    }
    public static void Print(int[,,] k){
        for(int i=0;i<k.GetLength(0);i++){
            for(int j=0;j<k.GetLength(1);j++){
                for(int l=0;l<k.GetLength(2);l++){
                    Console.Write(k[i,j,l]+" ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
    public static void Print(int[,] k){
        for(int i=0;i<k.GetLength(0);i++){
            for(int j=0;j<k.GetLength(1);j++){
                Console.Write(k[i,j]+" ");
            }
            Console.WriteLine();
        }
    }
    public static void Print(int[] k){
        for(int i=0;i<k.Length;i++){
            Console.WriteLine(k[i]);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.IO;
using System.Linq;
using System.Threading;

class Program
{
    string[] all;
    string dna = "ACGT";
    int[, ,] best;
    int[, ,] best2;
    long[, , ,] dp;
    int mod = 1000000009;
    int[, ,] p;
    void solve()
    {
        int n = nextInt();
        int m = nextInt();
        all = new string[m];
        for (int i = 0; i < m; i++)
            all[i] = nextString();
        int maxL = 0;
        for (int i = 0; i < m; i++)
            maxL = Math.Max(maxL, all[i].Length);
        best = new int[m, maxL + 1, 4];
        best2 = new int[m, maxL + 1, 4];

        p = new int[m, maxL + 1, 4];
        for (int i = 0; i < m; i++)
            for (int j = 0; j <= all[i].Length; j++)
                for (int k = 0; k < 4; k++)
                {
                    string cur = all[i].Substring(0, j) + dna[k];
                    for (int bestL = 0; bestL <= cur.Length; bestL++)
                    {
                        for (int r = 0; r < all.Length; r++)
                        {
                            if (all[r].StartsWith(cur.Substring(cur.Length - bestL)))
                            {
                                best[i, j, k] = r;
                                best2[i, j, k] = bestL;
                            }
                            if (all[r] == cur.Substring(cur.Length - bestL))
                                p[i, j, k] = bestL;
                        }
                    }
                }

        dp = new long[n + 1, m, maxL + 1, maxL + 1];
        for (int i = 0; i <= n; i++)
            for (int j = 0; j < m; j++)
                for (int k = 0; k <= maxL; k++)
                    for (int oks = 0; oks <= maxL; oks++)
                        dp[i, j, k, oks] = -1;
        long res = go(n, 0, 0, 0);
        println(res);

    }

    private long go(int rem, int who, int len, int oks)
    {
        if (dp[rem, who, len, oks] != -1)
            return dp[rem, who, len, oks];
        long res = 0;
        if (rem == 0)
        {
            if (oks == len)
                res = 1;

            return dp[rem, who, len, oks] = res;
        }
        for (int i = 0; i < 4; i++)
        {
            int nwho = best[who, len, i];
            int nlen = best2[who, len, i];
            if (p[who, len, i] + oks >= len + 1)
            {
                res += go(rem - 1, nwho, nlen, nlen);
            }
            else
            {
                if (nlen + oks < len + 1)
                    continue;
                res += go(rem - 1, nwho, nlen, oks - (len + 1 - nlen));
            }
            if (res >= mod)
                res -= mod;
        }
        return dp[rem, who, len, oks] = res;
    }

    ////////////
    private void println(int[] ar)
    {
        for (int i = 0; i < ar.Length; i++)
        {
            if (i == ar.Length - 1)
                println(ar[i]);
            else
                print(ar[i] + " ");
        }
    }
    private void println(int[] ar, bool add)
    {
        int A = 0;
        if (add)
            A++;
        for (int i = 0; i < ar.Length; i++)
        {
            if (i == ar.Length - 1)
                println(ar[i] + A);
            else
                print((ar[i] + A) + " ");
        }
    }

    private void println(string Stringst)
    {
        Console.WriteLine(Stringst);
    }
    private void println(char charnum)
    {
        Console.WriteLine(charnum);
    }
    private void println(int Intnum)
    {
        Console.WriteLine(Intnum);
    }
    private void println(long Longnum)
    {
        Console.WriteLine(Longnum);
    }
    private void println(double Doublenum)
    {
        string s = Doublenum.ToString(CultureInfo.InvariantCulture);
        Console.WriteLine(s);
    }

    private void print(string Stringst)
    {
        Console.Write(Stringst);
    }
    private void print(int Intnum)
    {
        Console.Write(Intnum);
    }
    private void print(char charnum)
    {
        Console.Write(charnum);
    }
    private void print(long Longnum)
    {
        Console.Write(Longnum);
    }
    private void print(double Doublenum)
    {
        Console.Write(Doublenum);
    }

    string[] inputLine = new string[0];
    int inputInd = 0;
    string nextLine()
    {
        return Console.ReadLine();
    }
    void readInput()
    {
        if (inputInd != inputLine.Length)
            throw new Exception();
        inputInd = 0;
        inputLine = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        if (inputLine.Length == 0)
            readInput();

    }
    int nextInt()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return int.Parse(inputLine[inputInd++]);
    }
    long nextLong()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return long.Parse(inputLine[inputInd++]);
    }
    double nextDouble()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return double.Parse(inputLine[inputInd++]);
    }
    string nextString()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return inputLine[inputInd++];
    }
    static void Main(string[] args)
    {
        Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
        new Program().solve();
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace ConsoleApp12
{
    class Program
    {
        static int[] SAI(string input, char sep = ' ')
        {
            return input.Split(sep).Select(x => int.Parse(x)).ToArray();
        }

        static int[] SAI(string input, string sep)
        {
            return new Regex(sep).Split(input).Select(x => int.Parse(x)).ToArray();
        }

        static long[] AI(char sep = ' ')
        {
            return Console.ReadLine().Split(sep).Select(x => long.Parse(x)).ToArray();
        }

        static uint[] AI(string sep)
        {
            return new Regex(sep).Split(Console.ReadLine()).Select(x => uint.Parse(x)).ToArray();
        }

        static List<int> LI(char sep = ' ')
        {
            return Console.ReadLine().Split(sep).Select(x => int.Parse(x)).ToList();
        }

        static Int64[] AI64(char sep = ' ')
        {
            return Console.ReadLine().Split(sep).Select(x => Int64.Parse(x)).ToArray();
        }

        static List<Int64> LI64(char sep = ' ')
        {
            return Console.ReadLine().Split(sep).Select(x => Int64.Parse(x)).ToList();
        }

        static void Main(string[] args)
        {
            var a = AI();
            if (a[1] == 1)
            {
                Console.Write(a[0]);
                return;
            }
            long result = 0;
            while (a[0] > 0)
            {
                result = result <<  1;
                ++result;
                a[0] = a[0] >> 1;
            }
            Console.WriteLine(result);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;

namespace CodeforcesTemplate
{
    public static class Permutation
    {
        private static bool Next(ref int[] arr)
        {
            int k, j, l;
            for (j = arr.Length - 2; (j >= 0) && (arr[j] >= arr[j + 1]); j--) { }
            if (j == -1)
            {
                arr = arr.OrderBy(c => c).ToArray();
                return false;
            }
            for (l = arr.Length - 1; (arr[j] >= arr[l]) && (l >= 0); l--) { }
            var tmp = arr[j];
            arr[j] = arr[l];
            arr[l] = tmp;
            for (k = j + 1, l = arr.Length - 1; k < l; k++, l--)
            {
                tmp = arr[k];
                arr[k] = arr[l];
                arr[l] = tmp;
            }
            return true;
        }
        public static IEnumerable<int[]> AllPermutations(int[] arr)
        {
            do yield return arr;
            while (Next(ref arr));
        }
    }

    class Program
    {
        private const string FILENAME = "distance4";

        private const string INPUT = FILENAME + ".in";

        private const string OUTPUT = FILENAME + ".out";

        private static Stopwatch _stopwatch = new Stopwatch();

        private static StreamReader _reader = null;
        private static StreamWriter _writer = null;

        private static string[] _curLine;
        private static int _curTokenIdx;

        private static char[] _whiteSpaces = new char[] { ' ', '\t', '\r', '\n' };

        private static string ReadNextToken()
        {
            if (_curTokenIdx >= _curLine.Length)
            {
                //Read next line
                string line = _reader.ReadLine();
                if (line != null)
                    _curLine = line.Split(_whiteSpaces, StringSplitOptions.RemoveEmptyEntries);
                else
                    _curLine = new string[] { };
                _curTokenIdx = 0;
            }

            if (_curTokenIdx >= _curLine.Length)
                return null;

            return _curLine[_curTokenIdx++];
        }

        private static int ReadNextInt()
        {
            return int.Parse(ReadNextToken());
        }

        private static void RunTimer()
        {
#if (DEBUG)

            _stopwatch.Start();

#endif
        }

        private static void Main(string[] args)
        {

#if (DEBUG)
            double before = GC.GetTotalMemory(false);
#endif

            long[] arr = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

            long n = arr[0];

            long k = arr[1];

            if (k == 1)
            {
                Console.WriteLine(n);
                return;
            }
            long answer = 1;

            while (answer <= n)
            {
                answer <<= 1;
            }

            Console.WriteLine(answer - 1);

#if (DEBUG)
            _stopwatch.Stop();

            double after = GC.GetTotalMemory(false);

            double consumedInMegabytes = (after - before) / (1024 * 1024);

            Console.WriteLine($"Time elapsed: {_stopwatch.Elapsed}");

            Console.WriteLine($"Consumed memory (MB): {consumedInMegabytes}");

            Console.ReadKey();
#endif

        }

        private static int CountLeadZeros(string source)
        {
            int countZero = 0;

            for (int i = source.Length - 1; i >= 0; i--)
            {
                if (source[i] == '0')
                {
                    countZero++;
                }

                else
                {
                    break;
                }

            }

            return countZero;
        }

        private static string ReverseString(string source)
        {
            char[] reverseArray = source.ToCharArray();

            Array.Reverse(reverseArray);

            string reversedString = new string(reverseArray);

            return reversedString;
        }

        private static int[] CopyOfRange(int[] src, int start, int end)
        {
            int len = end - start;
            int[] dest = new int[len];
            Array.Copy(src, start, dest, 0, len);
            return dest;
        }

        private static string StreamReader()
        {

            if (_reader == null)
                _reader = new StreamReader(INPUT);
            string response = _reader.ReadLine();
            if (_reader.EndOfStream)
                _reader.Close();
            return response;

        }

        private static void StreamWriter(string text)
        {

            if (_writer == null)
                _writer = new StreamWriter(OUTPUT);
            _writer.WriteLine(text);

        }

        private static int BFS(int start, int end, int[,] arr)
        {
            Queue<KeyValuePair<int, int>> queue = new Queue<KeyValuePair<int, int>>();
            List<bool> visited = new List<bool>();
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                visited.Add(false);
            }

            queue.Enqueue(new KeyValuePair<int, int>(start, 0));
            KeyValuePair<int, int> node;
            int level = 0;
            bool flag = false;

            while (queue.Count != 0)
            {
                node = queue.Dequeue();
                if (node.Key == end)
                {
                    return node.Value;
                }
                flag = false;
                for (int i = 0; i < arr.GetLength(0); i++)
                {

                    if (arr[node.Key, i] == 1)
                    {
                        if (visited[i] == false)
                        {
                            if (!flag)
                            {
                                level = node.Value + 1;
                                flag = true;
                            }
                            queue.Enqueue(new KeyValuePair<int, int>(i, level));
                            visited[i] = true;
                        }
                    }
                }

            }
            return 0;

        }

        private static void Write(string source)
        {
            File.WriteAllText(OUTPUT, source);
        }

        private static string ReadString()
        {
            return File.ReadAllText(INPUT);
        }

        private static void WriteStringArray(string[] source)
        {
            File.WriteAllLines(OUTPUT, source);
        }

        private static string[] ReadStringArray()
        {
            return File.ReadAllLines(INPUT);
        }

        private static int[] GetIntArray()
        {
            return ReadString().Split(' ').Select(int.Parse).ToArray();
        }

        private static double[] GetDoubleArray()
        {
            return ReadString().Split(' ').Select(double.Parse).ToArray();
        }

        private static int[,] ReadINT2XArray(List<string> lines)
        {
            int[,] arr = new int[lines.Count, lines.Count];

            for (int i = 0; i < lines.Count; i++)
            {
                int[] row = lines[i].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();

                for (int j = 0; j < lines.Count; j++)
                {
                    arr[i, j] = row[j];
                }
            }

            return arr;
        }
    }
}


using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Collections;

using Pair = System.Collections.Generic.KeyValuePair<int, long>;

namespace Task
{
    internal class Program
    {
        int cnt = 0;
        Dictionary<Pair, long> data = new Dictionary<Pair, long>();
        bool[,] was = new bool[100, 100];

        long xfx(int x, int y, long z)
        {
            if (x == -1)
                return 0;
            if (z == 0)
                return 0;
            if (y == 1)
            {
                if (x == 0)
                    return 1;
                return 0;
            }

            var key = new Pair((x << 16) | y, z);

            if (data.ContainsKey(key))
                return data[key];

            long hsize = getSize(y - 1);

            long ans = 0;

            if (z >= hsize)
            {
                long temp1 = xfx(x, y - 1, hsize);
                long temp2 = xfx(x - 1, y - 1, z - hsize);
                ans += temp1 + temp2;
            }
            else
            {
                long temp = xfx(x, y - 1, z);
                ans += temp;
            }

            data[key] = ans;
            return ans;
        }

        long getSize(int y)
        {
            return 1L << (y - 1);
        }

        long get(int x, long z)
        {
            long ans = 0;

            int num = 1;
            while (z > 0)
            {
                long size = getSize(num);
                long temp = xfx(x, num, Math.Min(size, z));

                z -= size;
                ans += temp;

                num++;
            }

            return ans;

        }

        private void Solve()
        {
            long n = io.NextLong();
            long t = io.NextLong();

            long x = 1;
            int p = 0;

            while (x < t)
            {
                x <<= 1;
                p++;
            }

            if (x != t)
            {
                io.Print(0);
                return;
            }

            long ans = get(p, n + 1);
            if (t == 1)
                ans--;
            io.Print(ans);

        }

        #region Program

        private readonly MyIo io;

        public Program(MyIo io)
        {
            this.io = io;
        }

        public static void Main(string[] args)
        {
            using (MyIo io = new MyIo())
            {
                new Program(io).Solve();
            }
        }

        #endregion
    }

    #region MyIo

    internal class MyIo : IDisposable
    {
        private readonly TextReader inputStream;
        private readonly TextWriter outputStream = Console.Out;

        private string[] tokens;
        private int pointer;

        public MyIo()
#if  LOCAL_TEST
            : this(new StreamReader("..\\..\\input.txt"))
#else
            : this(System.Console.In)
#endif
        {

        }

        public MyIo(TextReader inputStream)
        {
            this.inputStream = inputStream;
        }

        public string NextLine()
        {
            try
            {
                return inputStream.ReadLine();
            }
            catch (IOException)
            {
                return null;
            }
        }

        public string NextString()
        {
            try
            {
                while (tokens == null || pointer >= tokens.Length)
                {
                    tokens = NextLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                    pointer = 0;
                }
                return tokens[pointer++];
            }
            catch (IOException)
            {
                return null;
            }
        }

        public int NextInt()
        {
            return Next<int>();
        }

        public long NextLong()
        {
            return Next<long>();
        }

        public T Next<T>()
        {
            return (T)Convert.ChangeType(NextString(), typeof(T));
        }

        public IEnumerable<T> NextSeq<T>(int n)
        {
            for (int i = 0; i < n; i++)
                yield return Next<T>();
        }

        public void Print(string format, params object[] args)
        {
            outputStream.Write(string.Format(CultureInfo.InvariantCulture, format, args));
        }

        public void PrintLine(string format, params object[] args)
        {
            Print(format, args);

            outputStream.WriteLine();
        }

        public void Print(bool o)
        {
            Print(o ? "YES" : "NO");
        }

        public void PrintLine(bool o)
        {
            PrintLine(o ? "YES" : "NO");
        }

        public void Print<T>(T o)
        {
            outputStream.Write(o);
        }

        public void PrintLine<T>(T o)
        {
            outputStream.WriteLine(o);
        }

        public void Close()
        {
            inputStream.Close();
            outputStream.Close();
        }

        void IDisposable.Dispose()
        {
            Close();

#if  LOCAL_TEST
            Console.ReadLine();
#endif
        }
    }

    #endregion
}


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Security.AccessControl;
using System.Threading;

namespace First
{
    class Program
    {
        static void Main(string[] args)
        {

            int n = Convert.ToInt32(Console.ReadLine());
            string[] s = Console.ReadLine().Split(' ');
            int[] days = new int[n];

            for (int i = 0; i < n; i++)
            {
                days[i] = Convert.ToInt32(s[i]);
            }

            List<int> normalYear = new List<int>()
                {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
            List<int> leapYear = new List<int>()
                {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

            List<int> template = new List<int>();

            template.AddRange(normalYear);
            template.AddRange(normalYear);
            template.AddRange(leapYear);
            template.AddRange(normalYear);
            template.AddRange(normalYear);

            for (int i = 0; i < template.Count; i++)
            {
                if (template[i] == days[0])
                {
                    bool ok = true;
                    for (int j = 1; j < n; j++)
                    {
                        if ((i + j) >= template.Count || template[i + j] != days[j])
                        {
                            ok = false;
                            break;
                        }
                    }

                    if (ok)
                    {
                        Console.WriteLine("Yes");
                        return;
                    }
                }
            }

            Console.WriteLine("No");

        }
    }
}


using System;

namespace Olymp
{
    class Program
    {

        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            //int n = 763116;
            if (n == 1) Console.WriteLine(1);
            else if (n == 2) Console.WriteLine(2);
            else{

                Console.WriteLine(Numb(n));
            }
        }

        static public long Numb(int n)
        {
            long max = n * (n - 1) * (n - 2) / GCD(n, n - 2);
            for (int q = 10;  q > 0; q--)
            {
                long t = n * (n - 1) * (n - 2) / GCD(n, n - 2);
                for (long i = n; i > n - 10 && i > 2; i--)
                {
                    for (long j = i - 1; j > i - 11 && j > 1; j--)
                    {
                        for (long k = j - 1; k > i - 12 && k > 0; k--)
                        {
                            if ((i * j * k) / GCD(i, k) > t)
                                t = i * j * k / GCD(i, k);
                        }
                    }
                }
                if (t > max) max = t;
            }
            return max;
        }
        public static long GCD(long a, long b)
        {
            if (b == 0) return a;
            else return GCD(b, a % b);
        }
    }
}


using System;

namespace Olymp
{
    class Program
    {

        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            if (n == 1) Console.WriteLine(1);
            else if (n == 2) Console.WriteLine(2);
            else
                Console.WriteLine(Numb(n));
        }

        static public long Numb(int n)
        {
            long max = n * (n - 1) * (n - 2) / GCD(n, n - 2);
            for (int q = 10;  q > 0; q--)
            {
                long t = n * (n - 1) * (n - 2) / GCD(n, n - 2);
                for (long i = n; i > n - 10 && i > 2; i--)

                    for (long j = i - 1; j > i - 10 && j > 1; j--)

                        for (long k = j - 1; k > i - 11 && k > 0; k--)

                            if ((i * j * k) / GCD(i, k) > t)
                                t = i * j * k / GCD(i, k);

                if (t > max) max = t;
            }
            return max;
        }
        public static long GCD(long a, long b)
        {
            if (b == 0) return a;
            else return GCD(b, a % b);
        }
    }
}


using System;
using System.IO;
using System.Linq;
using System.Text;

namespace Fox_Dividing_Cheese
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            int a = Next();
            int b = Next();

            var divs = new[] {2, 3, 5};
            var na = new int[divs.Length];
            var nb = new int[divs.Length];
            for (int i = 0; i < divs.Length; i++)
            {
                while (a%divs[i] == 0)
                {
                    a /= divs[i];
                    na[i]++;
                }
                while (b%divs[i] == 0)
                {
                    b /= divs[i];
                    nb[i]++;
                }
            }
            if (a == b)
            {
                writer.WriteLine(na.Select((t, i) => Math.Abs(t - nb[i])).Sum());
            }
            else
            {
                writer.WriteLine("-1");
            }

            writer.Flush();
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharp
{
    class _371B
    {
        public static void Main()
        {
            var tokens = Console.ReadLine().Split();

            var a = Operations(int.Parse(tokens[0]));
            var b = Operations(int.Parse(tokens[1]));

            Console.WriteLine(a.Keys.Intersect(b.Keys).Select(key => a[key] + b[key]).DefaultIfEmpty(-1).Min());
        }

        private static Dictionary<int, int> Operations(int n)
        {
            var operations = new Dictionary<int, int> { { n, 0 } };
            var queue = new Queue<int>(new int[] { n });

            while (queue.Any())
            {
                int x = queue.Dequeue();

                if (x % 2 == 0 && !operations.ContainsKey(x / 2))
                {
                    operations.Add(x / 2, operations[x] + 1);
                    queue.Enqueue(x / 2);
                }

                if (x % 3 == 0 && !operations.ContainsKey(x / 3))
                {
                    operations.Add(x / 3, operations[x] + 1);
                    queue.Enqueue(x / 3);
                }

                if (x % 5 == 0 && !operations.ContainsKey(x / 5))
                {
                    operations.Add(x / 5, operations[x] + 1);
                    queue.Enqueue(x / 5);
                }
            }

            return operations;
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.IO;

using static util;
using P = pair<int, int>;

using Binary = System.Func<System.Linq.Expressions.ParameterExpression, System.Linq.Expressions.ParameterExpression,
                           System.Linq.Expressions.BinaryExpression>;
using Unary = System.Func<System.Linq.Expressions.ParameterExpression, System.Linq.Expressions.UnaryExpression>;

class Program
{
    static StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    static Scan sc = new Scan();
    const int M = 1000000007;
    const int M2 = 998244353;
    const long LM = (long)1e18;
    const double eps = 1e-11;
    static readonly int[] dd = { 0, 1, 0, -1, 0 };
    const string dstring = "RDLU";
    static void Main()
    {
        long n;
        int k;
        sc.Multi(out n, out k);
        var lis = new List<pair<long, int>>();
        long m = n;
        for (long i = 2; i * i <= m; i++)
        {
            int c = 0;
            while (m % i == 0) {
                m /= i;
                ++c;
            }
            if (c > 0) {
                lis.Add(make_pair(i, c));
            }
        }
        if (m > 1) {
            lis.Add(make_pair(m, 1));
        }
        long ans = 1;
        var inv = new long[100];
        for (int i = 1; i < 100; i++)
        {
            inv[i] = MyMath.inv(i);
        }
        foreach (var item in lis)
        {
            int c = item.v2;
            var dp = new long[c + 1];
            dp[0] = 1;
            for (int i = 0; i < k; i++)
            {
                var nex = new long[c + 1];
                for (int j = 0; j <= c; j++)
                {
                    for (int l = 0; l <= j; l++)
                    {
                        nex[j] = (nex[j] + dp[l] * inv[c - l + 1]) % M;
                    }
                }
                dp = nex;
            }
            long a = 0;
            long b = 1;
            for (int i = c; i >= 0; i--)
            {
                a = (a + dp[i] * b) % M;
                b = b * (item.v1 % M) % M;
            }
            ans = ans * a % M;
        }
        Prt(ans);
        sw.Flush();
    }

    static void DBG(string a) => Console.WriteLine(a);
    static void DBG<T>(IEnumerable<T> a) => DBG(string.Join(" ", a));
    static void DBG(params object[] a) => DBG(string.Join(" ", a));
    static void Prt(string a) => sw.WriteLine(a);
    static void Prt<T>(IEnumerable<T> a) => Prt(string.Join(" ", a));
    static void Prt(params object[] a) => Prt(string.Join(" ", a));
}
class pair<T, U> : IComparable<pair<T, U>>
{
    public T v1;
    public U v2;
    public pair(T v1, U v2) {
        this.v1 = v1;
        this.v2 = v2;
    }
    public int CompareTo(pair<T, U> a) {
        int c = Comparer<T>.Default.Compare(v1, a.v1);
        return c != 0 ? c : Comparer<U>.Default.Compare(v2, a.v2);
    }
    public override string ToString() => v1 + " " + v2;
    public void Deconstruct(out T a, out U b) {
        a = v1; b = v2;
    }
}
static class util
{
    public static pair<T, T> make_pair<T>(this IList<T> l) => make_pair(l[0], l[1]);
    public static pair<T, U> make_pair<T, U>(T v1, U v2) => new pair<T, U>(v1, v2);
    public static T sq<T>(T a) => Operator<T>.Multiply(a, a);
    public static T Max<T>(params T[] a) => a.Max();
    public static T Min<T>(params T[] a) => a.Min();
    public static bool inside(int i, int j, int h, int w) => i >= 0 && i < h && j >= 0 && j < w;
    public static void swap<T>(ref T a, ref T b) where T : struct { var t = a; a = b; b = t; }
    public static void swap<T>(this IList<T> a, int i, int j) where T : struct { var t = a[i]; a[i] = a[j]; a[j] = t; }
    public static T[] copy<T>(this IList<T> a) {
        var ret = new T[a.Count];
        for (int i = 0; i < a.Count; i++) ret[i] = a[i];
        return ret;
    }
}
static class Operator<T>
{
    static readonly ParameterExpression x = Expression.Parameter(typeof(T), "x");
    static readonly ParameterExpression y = Expression.Parameter(typeof(T), "y");
    public static readonly Func<T, T, T> Add = Lambda(Expression.Add);
    public static readonly Func<T, T, T> Subtract = Lambda(Expression.Subtract);
    public static readonly Func<T, T, T> Multiply = Lambda(Expression.Multiply);
    public static readonly Func<T, T, T> Divide = Lambda(Expression.Divide);
    public static readonly Func<T, T> Plus = Lambda(Expression.UnaryPlus);
    public static readonly Func<T, T> Negate = Lambda(Expression.Negate);
    public static Func<T, T, T> Lambda(Binary op) => Expression.Lambda<Func<T, T, T>>(op(x, y), x, y).Compile();
    public static Func<T, T> Lambda(Unary op) => Expression.Lambda<Func<T, T>>(op(x), x).Compile();
}

class Scan
{
    public int Int => int.Parse(Str);
    public long Long => long.Parse(Str);
    public double Double => double.Parse(Str);
    public string Str => Console.ReadLine().Trim();
    public pair<T, U> Pair<T, U>() where T : IComparable<T> where U : IComparable<U> {
        T a; U b;
        Multi(out a, out b);
        return new pair<T, U>(a, b);
    }
    public P P {
        get {
            int a, b;
            Multi(out a, out b);
            return new P(a, b);
        }
    }
    public int[] IntArr => StrArr.Select(int.Parse).ToArray();
    public long[] LongArr => StrArr.Select(long.Parse).ToArray();
    public double[] DoubleArr => StrArr.Select(double.Parse).ToArray();
    public string[] StrArr => Str.Split(new[]{' '}, StringSplitOptions.RemoveEmptyEntries);
    bool eq<T, U>() => typeof(T).Equals(typeof(U));
    T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
    T cv<T>(string s) => eq<T, int>()    ? ct<T, int>(int.Parse(s))
                       : eq<T, long>()   ? ct<T, long>(long.Parse(s))
                       : eq<T, double>() ? ct<T, double>(double.Parse(s))
                       : eq<T, char>()   ? ct<T, char>(s[0])
                                         : ct<T, string>(s);
    public void Multi<T>(out T a) => a = cv<T>(Str);
    public void Multi<T, U>(out T a, out U b)
    { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); }
    public void Multi<T, U, V>(out T a, out U b, out V c)
    { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); }
    public void Multi<T, U, V, W>(out T a, out U b, out V c, out W d)
    { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); }
    public void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e)
    { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); }
    public void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f)
    { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); f = cv<Y>(ar[5]); }
}

static class MyMath
{
    public static long Mod = 1000000007;
    public static bool isprime(long a) {
        if (a < 2) return false;
        for (long i = 2; i * i <= a; i++) if (a % i == 0) return false;
        return true;
    }
    public static bool[] sieve(int n) {
        var p = new bool[n + 1];
        for (int i = 2; i <= n; i++) p[i] = true;
        for (int i = 2; i * i <= n; i++) if (p[i]) for (int j = i * i; j <= n; j += i) p[j] = false;
        return p;
    }
    public static List<int> getprimes(int n) {
        var prs = new List<int>();
        var p = sieve(n);
        for (int i = 2; i <= n; i++) if (p[i]) prs.Add(i);
        return prs;
    }
    public static long pow(long a, long b) {
        a %= Mod;
        if (a == 0) return 0;
        if (b == 0) return 1;
        var t = pow(a, b / 2);
        if ((b & 1) == 0) return t * t % Mod;
        return t * t % Mod * a % Mod;
    }
    public static long inv(long a) => pow(a, Mod - 2);
    public static long gcd(long a, long b) {
        while (b > 0) { var t = a % b; a = b; b = t; } return a;
    }
    // a x + b y = gcd(a, b)
    public static long extgcd(long a, long b, out long x, out long y) {
        long g = a; x = 1; y = 0;
        if (b > 0) { g = extgcd(b, a % b, out y, out x); y -= a / b * x; }
        return g;
    }
    public static long lcm(long a, long b) => a / gcd(a, b) * b;

    static long[] facts, invs;
    public static void setfacts(int n) {
        facts = new long[n + 1];
        facts[0] = 1;
        for (int i = 1; i <= n; i++) facts[i] = facts[i - 1] * i % Mod;
        invs = new long[n + 1];
        invs[n] = inv(facts[n]);
        for (int i = n; i > 0 ; i--) invs[i - 1] = invs[i] * i % Mod;
    }
    public static long comb(long n, long r) {
        if (n < 0 || r < 0 || r > n) return 0;
        if (facts != null && facts.Length > n) return facts[n] * invs[r] % Mod * invs[n - r] % Mod;
        if (n - r < r) r = n - r;
        long numer = 1, denom = 1;
        for (long i = 0; i < r; i++) {
            numer = numer * ((n - i) % Mod) % Mod;
            denom = denom * ((i + 1) % Mod) % Mod;
        }
        return numer * inv(denom) % Mod;
    }
    public static long[][] getcombs(int n) {
        var ret = new long[n + 1][];
        for (int i = 0; i <= n; i++) {
            ret[i] = new long[i + 1];
            ret[i][0] = ret[i][i] = 1;
            for (int j = 1; j < i; j++) ret[i][j] = (ret[i - 1][j - 1] + ret[i - 1][j]) % Mod;
        }
        return ret;
    }
    // nC0, nC2, ..., nCn
    public static long[] getcomb(int n) {
        var ret = new long[n + 1];
        ret[0] = 1;
        for (int i = 0; i < n; i++) ret[i + 1] = ret[i] * (n - i) % Mod * inv(i + 1) % Mod;
        return ret;
    }
    public static bool nextPermutation<T>(IList<T> p) where T : struct, IComparable<T> {
        for (int i = p.Count - 2; i >= 0; --i) {
            if (p[i].CompareTo(p[i + 1]) < 0) {
                for (int j = p.Count - 1; ; --j) {
                    if (p[j].CompareTo(p[i]) > 0) {
                        p.swap(i, j);
                        for(++i, j = p.Count - 1; i < j; ++i, --j)
                            p.swap(i, j);

                        return true;
                    }
                }
            }
        }
        return false;
    }
    public static bool nextPermutation<T>(IList<T> p, Comparison<T> compare) where T : struct {
        for (int i = p.Count - 2; i >= 0; --i) {
            if (compare(p[i], p[i + 1]) < 0) {
                for (int j = p.Count - 1; ; --j) {
                    if (compare(p[j], p[i]) > 0) {
                        p.swap(i, j);
                        for (++i, j = p.Count - 1; i < j; ++i, --j)
                            p.swap(i, j);

                        return true;
                    }
                }
            }
        }
        return false;
    }
}


using System;
using System.Linq;
using System.Collections.Generic;
using Debug = System.Diagnostics.Debug;
using SB = System.Text.StringBuilder;
using System.Numerics;
using static System.Math;
namespace Program {
    public class Solver {
        Random rnd = new Random(0);
        public void Solve() {
            var n = rl;
            var k = ri;
            solve(n, k);
        }
        void solve(long n, int k) {
            Debug.WriteLine($"{n} {k}");
            var rev = Enumerate(100, x => ModInt.Inverse(x));

            ModInt all = 1;
            for (long p = 2; n != 1; p++) {
                if (p * p > n) {
                    p = n;
                }
                if (n % p != 0) continue;
                var cnt = 0;
                while (n % p == 0) {
                    n /= p;
                    cnt++;
                }
                var dp = new ModInt[cnt + 1];
                dp[cnt] = 1;
                for (int i = 0; i < k; i++) {
                    var next = new ModInt[cnt + 1];
                    for (int j = 0; j < dp.Length; j++)
                        for (int jj = 0; jj <= j; jj++) {
                            next[jj] += dp[j] * rev[j + 1];
                        }
                    dp = next;
                }
                ModInt ans = 0;
                for (long i = 0, v = 1; i < dp.Length; i++, v *= p)
                    ans += v * dp[i];
                all *= ans;

            }
            Console.WriteLine(all);
        }
        const long INF = 1L << 60;
        int ri { get { return sc.Integer(); } }
        long rl { get { return sc.Long(); } }
        double rd { get { return sc.Double(); } }
        string rs { get { return sc.Scan(); } }
        public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());

        static T[] Enumerate<T>(int n, Func<int, T> f) {
            var a = new T[n];
            for (int i = 0; i < n; ++i) a[i] = f(i);
            return a;
        }
        static public void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
    }
}

#region main
static class Ex {
    static public string AsString(this IEnumerable<char> ie) { return new string(ie.ToArray()); }
    static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") {
        return string.Join(st, ie);
    }
    static public void Main() {
        Console.SetOut(new Program.IO.Printer(Console.OpenStandardOutput()) { AutoFlush = false });
        var solver = new Program.Solver();
        solver.Solve();
        Console.Out.Flush();
    }
}
#endregion
#region Ex
namespace Program.IO {
    using System.IO;
    using System.Text;
    using System.Globalization;

    public class Printer: StreamWriter {
        public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
        public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
    }

    public class StreamScanner {
        public StreamScanner(Stream stream) { str = stream; }

        public readonly Stream str;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        public bool isEof = false;
        public bool IsEndOfStream { get { return isEof; } }

        private byte read() {
            if (isEof) return 0;
            if (ptr >= len) {
                ptr = 0;
                if ((len = str.Read(buf, 0, 1024)) <= 0) {
                    isEof = true;
                    return 0;
                }
            }
            return buf[ptr++];
        }

        public char Char() {
            byte b = 0;
            do b = read(); while ((b < 33 || 126 < b) && !isEof);
            return (char)b;
        }
        public string Scan() {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b);
            return sb.ToString();
        }
        public string ScanLine() {
            var sb = new StringBuilder();
            for (var b = Char(); b != '\n' && b != 0; b = (char)read()) if (b != '\r') sb.Append(b);
            return sb.ToString();
        }
        public long Long() { return isEof ? long.MinValue : long.Parse(Scan()); }
        public int Integer() { return isEof ? int.MinValue : int.Parse(Scan()); }
        public double Double() { return isEof ? double.NaN : double.Parse(Scan(), CultureInfo.InvariantCulture); }
    }
}

#endregion

#region sieve O(NloglogN)
static public partial class MathEx {
    static public bool[] Sieve(int p, List<int> primes = null) {
        var isPrime = new bool[p + 1];
        for (int i = 2; i < isPrime.Length; i++) isPrime[i] = true;
        for (int i = 2; i * i <= p; i++)
            if (!isPrime[i]) continue;
            else for (int j = i * i; j <= p; j += i) isPrime[j] = false;
        if (primes != null) for (int i = 0; i <= p; i++) if (isPrime[i]) primes.Add(i);

        return isPrime;
    }
    static public List<int> SieveList(int p) { var ret = new List<int>(); Sieve(p, ret); return ret; }
}
#endregion

#region ModInt
/// <summary>
/// [0,<see cref="Mod"/>) までの値を取るような数
/// </summary>
public struct ModInt {
    /// <summary>
    /// 剰余を取る値．
    /// </summary>
    public const long Mod = (int)1e9 + 7;

    /// <summary>
    /// 実際の数値．
    /// </summary>
    public long num;
    /// <summary>
    /// 値が <paramref name="n"/> であるようなインスタンスを構築します．
    /// </summary>
    /// <param name="n">インスタンスが持つ値</param>
    /// <remarks>パフォーマンスの問題上，コンストラクタ内では剰余を取りません．そのため，<paramref name="n"/> ∈ [0,<see cref="Mod"/>) を満たすような <paramref name="n"/> を渡してください．このコンストラクタは O(1) で実行されます．</remarks>
    public ModInt(long n) { num = n; }
    /// <summary>
    /// このインスタンスの数値を文字列に変換します．
    /// </summary>
    /// <returns>[0,<see cref="Mod"/>) の範囲内の整数を 10 進表記したもの．</returns>
    public override string ToString() { return num.ToString(); }
    public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }
    public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }
    public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }
    public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }

    /// <summary>
    /// 与えられた 2 つの数値からべき剰余を計算します．
    /// </summary>
    /// <param name="v">べき乗の底</param>
    /// <param name="k">べき指数</param>
    /// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
    public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }

    /// <summary>
    /// 与えられた 2 つの数値からべき剰余を計算します．
    /// </summary>
    /// <param name="v">べき乗の底</param>
    /// <param name="k">べき指数</param>
    /// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
    public static ModInt Pow(long v, long k) {
        long ret = 1;
        for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)
            if ((k & 1) == 1) ret = ret * v % Mod;
        return new ModInt(ret);
    }
    /// <summary>
    /// 与えられた数の逆元を計算します．
    /// </summary>
    /// <param name="v">逆元を取る対象となる数</param>
    /// <returns>逆元となるような値</returns>
    /// <remarks>法が素数であることを仮定して，フェルマーの小定理に従って逆元を O(log N) で計算します．</remarks>
    public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }
}
#endregion


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace codeforce
{
    class Program
    {
        static void Main(string[] args)
        {
            string temp = Console.ReadLine();
            string[] splitted = temp.Split(' ');
            int N = Convert.ToInt32(splitted[0]);
            int K = Convert.ToInt32(splitted[1]);
            temp = Console.ReadLine();
            splitted = temp.Split(' ');
            int[] difficultyTask = new int[N];
            for (int i = 0; i < N; i++)
            {
                difficultyTask[i] = Convert.ToInt32(splitted[i]);
            }
            int TasksCanSolve = 0;
            bool[] solved = new bool[N];
            bool progress = true;
            for (int i = 0, j = N - 1; i < N && j >= 0 && !solved[i]
                && !solved[j] && progress;)
            {
                progress = false;
                if (difficultyTask[i] <= K && !solved[i])
                {
                    TasksCanSolve++;
                    solved[i] = true;
                    i++;
                    progress = true;
                }
                if (difficultyTask[j] <= K && !solved[j])
                {
                    TasksCanSolve++;
                    solved[j] = true;
                    j--;
                    progress = true;
                }
            }
            Console.WriteLine(TasksCanSolve);
            //Console.Read();
        }
    }
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            TextReader sr = Console.In;
            string[] s = sr.ReadLine().Split();
            int n = Convert.ToInt32(s[0]);
            int k = Convert.ToInt32(s[1]);
            s = sr.ReadLine().Split();
            int z1 = -1;
            int z2 = -1;
            int c;
            int res;
            for (int i = 0; i < n; i++)
            {
                c = Convert.ToInt32(s[i]);
                if (c > k)
                {
                    if (z1 == -1) z1 = i;
                    else z2 = i;
                }
            }
            if (z1 == -1 && z2 == -1) res = n;
            else if (z2 == -1) res = n - 1;
            else res = n - (z2 - z1 + 1);
            Console.WriteLine(res.ToString());
        }
    }
}


using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		int N = str.Length;
		string ans = "";
		if(N%2==0){
			for(var i=0;i<N/2;i++){
				ans += str.Substring(N/2-1-i,1);
				ans += str.Substring(N/2+i,1);
			}
		} else {
			ans += str.Substring((N-1)/2,1);
			for(var i=1;i<=(N-1)/2;i++){
				ans += str.Substring((N-1)/2+i,1);
				ans += str.Substring((N-1)/2-i,1);
			}
		}
		Console.WriteLine(ans);
	}
}


using System;
using System.Linq;
using System.Reflection;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Text;

namespace AlgoHelper
{
    class Utils
    {
        public static T[] ReadArrayFromString<T>(string s, char separator)
        {
            Type type = typeof(T);

            MethodInfo[] methods = type.GetMethods();

            MethodInfo parseMethod = methods.Where(m => m.Name == "Parse").FirstOrDefault();

            if (parseMethod == null)
            {
                throw new InvalidOperationException($"The type {type} does not contain Parse method");
            }

            T[] result = s.Split(separator).Select(e => parseMethod.Invoke(type, new object[] { e })).Cast<T>().ToArray();

            return result;
        }

        public static void PrintAnArray<T>(T[] array, string separator)
        {
            Console.WriteLine(string.Join(separator, array));
        }
    }

    class AlgorithmUtils
    {
        public static T[] PrefixSumOfArray<T>(T[] array) where T : struct
        {
            T currentSum = default(T);

            T[] prefixSum = new T[array.Length];

            for (int i = 0; i < array.Length; i++)
            {
                currentSum = sumTwoElements(currentSum, array[i]);
                prefixSum[i] = currentSum;
            }

            return prefixSum;
        }

        public static T SumOfElementsInArray<T>(T[] array, int leftIndex, int rightIndex)
        {
            dynamic right = array[rightIndex];
            dynamic left = array[leftIndex];

            return right - left;
        }

        private static T sumTwoElements<T>(T a, T b) where T : struct
        {
            dynamic first = a;
            dynamic second = b;

            return first + second;
        }

        public static void Swap<T>(ref T a, ref T b)
        {
            T temp = a;
            a = b;
            b = temp;
        }
    }

    class Program
    {
        private static List<string> list = new List<string>();

        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            int l;

            if(s.Length % 2 == 0)
            {
                l = s.Length / 2 - 1;
            }
            else
            {
                l = s.Length / 2 ;
            }

            StringBuilder sb = new StringBuilder();

            int index = l;
            int step = 0;
            int k = 0;

            while(index>=0 && index<s.Length)
            {
                step++;
                k++;
                sb.Append(s[index]);
                if (step % 2 != 0) index += k;
                else index-= k;
            }

            Console.WriteLine(sb);

         //   Console.ReadKey();
        }
        public int MaxWidthRamp(int[] A)
        {
            int i = 0;
            int j = A.Length - 1;

            int max = 0;

            while(i<j)
            {
                if(A[i]>A[j])
                {
                    i++;
                }
                else
                {
                    max = Math.Max(max, j - i);
                    break;
                }
            }

            while (i < j)
            {
                if (A[i] > A[j])
                {
                    j--;
                }
                else
                {
                    max = Math.Max(max, j - i);
                    break;
                }
            }

            return max;
        }

        private static int summma(int [] a)
        {
            int sum = 0;

            foreach(int n in a)
            {
                sum += n;
            }

            return sum;
        }

        private static string createString(int n, int k)
        {
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < k; i++)
            {
                sb.Append(char.ConvertFromUtf32(i + 'a'));
            }

            int temp = n - k;
            int j = 0;

            for (int i = 0; i < temp; i++)
            {
                sb.Append(char.ConvertFromUtf32(j + 'a'));

                j++;

                if (j > k)
                {
                    j = 0;
                }
            }

            return sb.ToString();
        }

        public int LargestRectangleArea(int[] heights)
        {
            int[] mins = min(heights);

            int left = 0;
            int right = heights.Length - 1;

            int max = int.MinValue;

            while (left < right)
            {
                int currentArea = Math.Min(heights[left], heights[right]) * (right - left);
                max = Math.Max(max, currentArea);
                Console.WriteLine(left + " " + right + " " + max);
                if (heights[left] < heights[right])
                {
                    left++;
                }
                else
                {
                    right--;
                }

            }
            return max;
        }

        private static int [] min (int [] a)
        {
            int min = a[0];

            int[] ans = new int[a.Length];
            ans[0] = min;

            for (int i = 1; i < a.Length; i++)
            {
                if(a[i]<min)
                {
                    ans[i] = min;
                }
            }

            return ans;
        }

        public static string CustomSortString(string s, string t)
        {
            Dictionary<char, int> dict = new Dictionary<char, int>();

            for(int i = 0; i < s.Length; i++)
            {
                dict[s[i]] = i;
            }

            char[] ans = t.ToCharArray();

            int index = 0;

            for (int i = 0; i < s.Length; i++)
            {
                for (int j = 0; j < t.Length; j++)
                {
                    if(s[i] == t[j])
                    {
                        ans[index++] = t[j];
                    }
                }
            }

            for (int i = 0; i < t.Length; i++)
            {
                if(!dict.ContainsKey(t[i]))
                {
                    ans[index++] = t[i];
                }
            }

            return new string(ans);
        }

        private static void Swap(ref char a, ref char b)
        {
            char temp = a;
            a = b;
            b = temp;
        }

        private static int lowerBound(int[] a, int target)
        {
            int lo = 0;
            int hi = a.Length - 1;

            int ans = -1;

            while (lo <= hi)
            {
                int med = hi - (hi - lo) / 2;

                if (target == a[med])
                {
                    ans = med;
                    hi = med - 1;
                }
                else if (target > a[med])
                {
                    lo = med + 1;
                }
                else
                {
                    hi = med - 1;
                }
            }

            return ans;
        }

        private static int upperBound(int[] a, int target)
        {
            int lo = 0;
            int hi = a.Length - 1;

            int ans = -1;

            while (lo <= hi)
            {
                int med = hi - (hi - lo) / 2;

                if (target == a[med])
                {
                    ans = med;
                    lo = med + 1;
                }
                else if (target > a[med])
                {
                    lo = med + 1;
                }
                else
                {
                    hi = med - 1;
                }
            }

            return ans;
        }

        private static bool isPalindromePermutation(string s)
        {
            int count = 0;

            int[] frequency = characterFrequency(s);

            for (int i = 0; i < frequency.Length; i++)
            {
                if (frequency[i] % 2 != 0) count++;
            }

            return count <= 1;
        }

        private static bool isPermuatation(int[] fa, int[] fb)
        {
            for (int i = 0; i < fa.Length; i++)
            {
                if (fa[i] != fb[i]) return false;
            }

            return true;
        }

        private static bool isAllCharactersUnique(string s)
        {
            char[] c = s.ToCharArray();

            Array.Sort(c);

            for (int i = 0; i < c.Length - 1; i++)
            {
                if (c[i + 1] == c[i]) return false;
            }

            return true;
        }

        private static int[] characterFrequency(string s)
        {
            int[] a = new int[26];

            foreach (char c in s)
            {
                a[c - 'a']++;
            }

            return a;
        }

        private static void permutation(string str)
        {
            permutation(str, "");
        }

        private static void permutation(string str, string prefix)
        {
            if (str.Length == 0) list.Add(prefix);
            else
            {
                for (int i = 0; i < str.Length; i++)
                {
                    string rem = str.Substring(0, i) + str.Substring(i + 1);
                    permutation(rem, prefix + str[i]);
                }
            }
        }

        public static int[] prefixSum(int[] a)
        {
            int[] b = new int[a.Length];
            int sum = 0;
            for (int i = 0; i < a.Length; i++)
            {
                sum += a[i];
                b[i] = sum;
            }

            return b;
        }
        private static string shiftTheString(string s)
        {
            char[] c = s.ToCharArray();

            char first = c[0];

            for (int i = 0; i < c.Length - 1; i++)
            {
                c[i] = c[i + 1];
            }

            c[c.Length - 1] = first;

            return new string(c);
        }

        private static string reverseTheString(string s)
        {
            char[] c = s.ToCharArray();

            for (int i = 0; i < c.Length / 2; i++)
            {
                char temp = c[i];
                c[i] = c[c.Length - 1 - i];
                c[c.Length - 1 - i] = temp;
            }

            return new string(c);
        }

        private static int toDecimal(string s)
        {
            int result = 0;
            int j = 0;

            for (int i = s.Length - 1; i >= 0; i--)
            {
                result += Convert.ToInt32(s[i].ToString()) * (int)(Math.Pow(2, j));
                j++;
            }

            return result;
        }

        private static int gcd(int a, int b)
        {
            return b == 0 ? a : gcd(b, a % b);
        }

        private static bool isPrime(int n)
        {
            if (n < 2) return false;

            for (int i = 2; i * i <= n; i++)
            {
                if (n % i == 0) return false;
            }

            return true;
        }
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
//using System.Numerics;
using System.Text;
using System.Threading;

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    const int MOD = 1000000007;
    const int MAX = 2000000;

    long ModPow(long x, long p)
    {
        long ret = 1;
        while (p > 0)
        {
            if ((p & 1) == 1)
                ret = ret * x % MOD;
            x = x * x % MOD;
            p >>= 1;
        }
        return ret;
    }

    void Solve()
    {
        var fact = new long[MAX * 2];
        fact[0] = 1;
        for (int i = 1; i < 2 * MAX; i++)
            fact[i] = fact[i - 1] * i % MOD;

        int n = ReadInt() + 1;
        long ret = 2 * fact[2 * n - 1] * ModPow(fact[n], MOD - 2) % MOD * ModPow(fact[n - 1], MOD - 2) % MOD - 1;
        if (ret < 0)
            ret += MOD;
        Write(ret);
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        //reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("transform.in");
        //writer = new StreamWriter("transform.out");
#endif
        try
        {
            //            var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            //            thread.Start();
            //            thread.Join();
            new Solver().Solve();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
#if DEBUG
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array)writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }
    #endregion
}


using System;
using System.IO;
using System.Text;

namespace Bots
{
    internal class Program
    {
        private const int mod = 1000000007;
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static long Pow(long a, int k)
        {
            long r = 1;
            while (k > 0)
            {
                if ((k & 1) == 1)
                {
                    r = (r*a)%mod;
                }
                a = (a*a)%mod;
                k >>= 1;
            }
            return r;
        }

        private static void Main(string[] args)
        {
            int n = Next()+1;

            long f = 1;
            for (int i = 2; i <= n; i++)
            {
                f = (f*i)%mod;
            }
            long f2 = f;
            for (int i = n + 1; i <= 2*n; i++)
            {
                f2 = (f2*i)%mod;
            }

            long f1 = Pow(f, mod - 2);

            long res = (((f2*f1)%mod)*f1)%mod;

            writer.WriteLine(res-1);
            writer.Flush();
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace capp
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] data = Array.ConvertAll(Console.ReadLine().Split(' '), x => int.Parse(x));
            int a = (int)Math.Round(Math.Sqrt(data[0] * data[1] / data[2]));
            int b = (int)Math.Round(Math.Sqrt(data[1]*data[2]/data[0]));
            int c = (int)Math.Round(Math.Sqrt(data[2]*data[0]/data[1]));
            Console.WriteLine(4 * (a + b + c));
        }
    }

}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;

namespace codeforces
{
	class Program
	{
		public class User
		{
			public int c;

			public int r;
		}

		public class Point
		{
			public int x;

			public int y;
		}

		public class Comparer : IComparer<User>
		{
			public int Compare(User x, User y)
			{
				if (x.c < y.c || (x.c == y.c && x.r < y.r))
					return -1;
				return 1;
			}
		}

		public static long getGcd(long a, long b)
		{
			if (b == 0)
				return a;
			return getGcd(b, a % b);
		}

		public static void WriteYESNO(bool x, string yes = "YES", string no = "NO")
		{
			if (x)
				Console.WriteLine(yes);
			else
			{
				Console.WriteLine(no);
			}
		}

		public static string getString()
		{
			return Console.ReadLine();
		}

		public static List<int> getList()
		{
			var s = Console.ReadLine();
			return s.Split(' ').Select(int.Parse).ToList();
		}

		public static List<long> getLongList()
		{
			var s = Console.ReadLine();
			return s.Split(' ').Select(long.Parse).ToList();
		}

		public static int Min(int x, int y)
		{
			return Math.Min(x, y);
		}

		public static int Max(int x, int y)
		{
			return Math.Max(x, y);
		}

		public static int Abs(int x)
		{
			return Math.Abs(x);
		}

		public static int getInt()
		{
			var s = Console.ReadLine();
			return int.Parse(s);
		}

		public static long getLong()
		{
			var s = Console.ReadLine();
			return long.Parse(s);
		}

		public static bool Equal(int x, int y, int x1, int y1)
		{
			return x == x1 && y == y1;
		}

		public class Vertex
		{
			public List<int> edges;

			public int ct;

			public bool was;
		}

		private static void Main(string[] args)
		{
/*			var input = new StreamReader("input.txt");
			var output = new StreamWriter("output.txt");*/
			var l = getList();
			Console.WriteLine(4* ((int)Math.Sqrt((l[0] * l[1]) / l[2]) + (int)Math.Sqrt((l[0] * l[2]) / l[1]) + (int)Math.Sqrt((l[2] * l[1]) / l[0])));
			Console.ReadLine();
		}
	}
}


using System;
using System.Linq;
using System.IO;

class Program
{
    private static void Main()
    {
        //InputFromFile();
        long[] nm = ConsoleReadLineAsArrayOfLongs();
        long n = nm[0];
        long m = nm[1];
        long modulo = 1000000000 + 7;

        long x = fastPow((fastPow(2, m, modulo) - 1), n, modulo);

        ConsoleWriteLine("" + x);
    }

    //returns a^pw % mod
    private static long fastPow(long a, long pw, long mod) {
        long res = 1;
        a %= mod;
        while(pw > 0) {
            if((pw & 1) != 0) res = (res*a)%mod;
            a = (a*a)%mod;
            pw >>= 1;
        }
        return res;
    }

    private static long poww(long a, long b, long modulo)
    {
        long x = 1;
        for(int i = 0; i < b; ++i)
        {
            x *= a;
            x %= modulo;
        }
        return x;
    }

    private static void InputFromFile()
    {
        Console.SetIn(File.OpenText("input.txt"));
    }

    private static long[] ConsoleReadLineAsArrayOfLongs()
    {
        return Console.ReadLine().Split(' ').Select(n => Convert.ToInt64(n)).ToArray();
    }

    private static int[] ConsoleReadLineAsArrayOfIntegers()
    {
        return Console.ReadLine().Split(' ').Select(n => Convert.ToInt32(n)).ToArray();
    }

       private static int[] ConsoleReadLineAsArrayOfIntegersReversed()
    {
        return Console.ReadLine().Split(' ').Select(n => Convert.ToInt32(n)).Reverse().ToArray();
    }

    private static long ConsoleReadLineAsLong()
    {
        return Convert.ToInt64(Console.ReadLine());
    }

    private static int ConsoleReadLineAsInteger()
    {
        return Convert.ToInt32(Console.ReadLine());
    }

    private static void ConsoleWriteLine(string line)
    {
        Console.WriteLine(line);
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {

            var nm = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            var n = nm[0];
            var m = nm[1];

            var result = PowerMod(PowerMod(2, m) - 1, n);
            Console.WriteLine(result);
        }

        static long PowerMod(long number, long power)
        {
            long res = 1;

           while(power > 0)
            {
                if((power&1) == 1)
                    res = (res * number) % 1000000007;
                power = power >> 1;
                number = (number * number) % 1000000007;
            }
            return res;
        }
    }
}