Little Sofia is in fourth grade. Today in the geometry lesson she learned about segments and squares. On the way home, she decided to draw $$$n$$$ squares in the snow with a side length of $$$1$$$. For simplicity, we assume that Sofia lives on a plane and can draw only segments of length $$$1$$$, parallel to the coordinate axes, with vertices at integer points.In order to draw a segment, Sofia proceeds as follows. If she wants to draw a vertical segment with the coordinates of the ends $$$(x, y)$$$ and $$$(x, y+1)$$$. Then Sofia looks if there is already a drawn segment with the coordinates of the ends $$$(x', y)$$$ and $$$(x', y+1)$$$ for some $$$x'$$$. If such a segment exists, then Sofia quickly draws a new segment, using the old one as a guideline. If there is no such segment, then Sofia has to take a ruler and measure a new segment for a long time. Same thing happens when Sofia wants to draw a horizontal segment, but only now she checks for the existence of a segment with the same coordinates $$$x$$$, $$$x+1$$$ and the differing coordinate $$$y$$$.For example, if Sofia needs to draw one square, she will have to draw two segments using a ruler:   After that, she can draw the remaining two segments, using the first two as a guide:   If Sofia needs to draw two squares, she will have to draw three segments using a ruler:   After that, she can draw the remaining four segments, using the first three as a guide:   Sofia is in a hurry, so she wants to minimize the number of segments that she will have to draw with a ruler without a guide. Help her find this minimum number.

The only line of input contains a single integer $$$n$$$ ($$$1 \le n \le 10^{9}$$$), the number of squares that Sofia wants to draw.

Print single integer, the minimum number of segments that Sofia will have to draw with a ruler without a guide in order to draw $$$n$$$ squares in the manner described above.

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

namespace Codeforces
{

    /*

string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            string tt = Console.ReadLine();
            int[] a = tt.Split(' ').Select(q => Convert.ToInt32(q)).ToArray();
            int[] k = Enumerable.Repeat(0, n).ToArray();
            Array.Sort<int>(a,
                    new Comparison<int>(
                            (i1, i2) => i2.CompareTo(i1)
                    ));
 */

 /*

 string r = Console.ReadLine();
            int n = int.Parse(r);

            string t = Console.ReadLine();
            int[] a = t.Split(' ').Select(q => Convert.ToInt32(q)).ToArray();
  */
    class B
    {
        private static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int n = int.Parse(input);
            int res = 0;
            int k = (int)Math.Sqrt(n);
            int t = k * k;
            if (n - t > k)
                res = (k + 1) * 2;
            else if (t == n)
                res = k * 2;
            else
                res = k * 2 + 1;
            Console.WriteLine(res);
        }
    }
}

using System;

namespace CSharp
{
    class _1099B
    {
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());

            int x = (int)Math.Ceiling(Math.Sqrt(n));
            int y = (int)Math.Ceiling((double)n / x);

            Console.WriteLine(x + y);
        }
    }
}

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

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());

			int min = Int32.MaxValue;

			for (int i = 1; i <= (int) Math.Sqrt(n) + 1; i++)
			{
				int root2 = (int)Math.Ceiling(n / (double) i);

				//Console.WriteLine(i + " * " + root2);
				min = Math.Min(min, i + root2);
			}

			Console.WriteLine(min);
		}
	}
}

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

namespace Test
{
    class IOHelper : IDisposable
    {
        StreamReader reader;
        StreamWriter writer;

        public IOHelper(string inputFile, string outputFile, Encoding encoding)
        {
            StreamReader iReader;
            StreamWriter oWriter;
            if (inputFile == null)
                iReader = new StreamReader(Console.OpenStandardInput(), encoding);
            else
                iReader = new StreamReader(inputFile, encoding);

            if (outputFile == null)
                oWriter = new StreamWriter(Console.OpenStandardOutput(), encoding);
            else
                oWriter = new StreamWriter(outputFile, false, encoding);

            reader = iReader;
            writer = oWriter;

            curLine = new string[] { };
            curTokenIdx = 0;
        }

        string[] curLine;
        int curTokenIdx;

        char[] whiteSpaces = new char[] { ' ', '\t', '\r', '\n' };

        public 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++];
        }

        public int ReadNextInt()
        {
            return int.Parse(ReadNextToken());
        }

        public double ReadNextDouble()
        {
            var nextToken = ReadNextToken();
            var result = 0.0;
            nextToken = nextToken.Replace(".", System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator);
            result = double.Parse(nextToken);
            return result;
        }

        public void Write(string stringToWrite)
        {
            writer.Write(stringToWrite);
        }

        public void WriteLine(string stringToWrite)
        {
            writer.WriteLine(stringToWrite);
        }

        public void WriteLine(double valueToWrite)
        {
            long intPart = (long)valueToWrite;
            double fracPart = valueToWrite - intPart;
            var fracPartStr = fracPart.ToString("F8");
            if (fracPartStr.Length > 1)
                fracPartStr = fracPartStr.Substring(2);
            var strToWrite = string.Format("{0}.{1}", intPart, fracPartStr);
            writer.WriteLine(strToWrite);
        }

        public void Dispose()
        {
            try
            {
                if (reader != null)
                {
                    reader.Dispose();
                }
                if (writer != null)
                {
                    writer.Dispose();
                }
            }
            catch { };
        }

        public void Flush()
        {
            if (writer != null)
            {
                writer.Flush();
            }
        }
    }

    class Program
    {
        protected IOHelper ioHelper;

        int n;

        public void Solve()
        {
            n = ioHelper.ReadNextInt();
            int sqrn = (int)Math.Sqrt(n);

            int a = 1;
            int b = 1;
            while(a*b < n)
            {
                if (a < b)
                    a++;
                else
                    b++;
            }

            int res = a + b;
            ioHelper.WriteLine(res.ToString());
            ioHelper.Flush();

            //Console.ReadKey();
        }

        public Program(string inputFile, string outputFile)
        {
            ioHelper = new IOHelper(inputFile, outputFile, Encoding.Default);
            Solve();
            ioHelper.Dispose();
        }

        static void Main(string[] args)
        {
            Program myProgram = new Program(null, null);
        }
    }
}

using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		long N = long.Parse(Console.ReadLine());
		long ans = -1;
		for(long i=1;i<=1000000;i++){
			if(i*i>=N){
				ans = i*2;
				break;
			} else if(i*(i+1)>=N){
				ans = i*2+1;
				break;
			}
		}
		Console.WriteLine(ans);
	}
}

using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            if (n == 1)
            {
                Console.WriteLine(2);
                return;
            }

            if (n == 2)
            {
                Console.WriteLine(3);
                return;
            }

            var i = 1;
            for (; i*i < n; i += 1) ;

            var power = i * i;

            if (power - i >= n)
            {
                Console.WriteLine(i*2 - 1);
                return;
            }
            else
            {
                Console.WriteLine(i*2);
                return;
            }
        }
    }
}

using System;

class _1099B
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());

		double sqrt = Math.Sqrt(n);
		int sqrtInt = (int)sqrt;
		Console.WriteLine((sqrtInt << 1) + (sqrt == sqrtInt ? 0 : sqrt - sqrtInt < 0.5 ? 1 : 2));
	}
}

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

namespace Squares_and_Segments
{
    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)
        {
            writer.WriteLine(Solve(args));
            writer.Flush();
        }

        private static long Solve(string[] args)
        {
            int n = Next();

            for (long i = (long) Math.Sqrt(n) - 1;; i++)
            {
                if (i*(i - 1) >= n)
                {
                    return i + i - 1;
                }
                if (i*i >= n)
                {
                    return 2*i;
                }
            }
        }

        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;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;

namespace ReadString
{
    class Program
    {

        static bool[] Erastofen(long count)
        {
            long counter = 2;
            bool[] EN = new bool[count];

            for (counter = 2; counter < count; counter++)
            {
                EN[counter] = true;
            }

            long z = 2;
            long e = 0;
            while (e == 0)
            {
                for (counter = z + z; counter < count; counter = count + z)
                {
                    EN[counter] = false;
                }

                for (counter = z + 1; counter < count; counter++)
                {
                    if (counter == (count - 1))
                    {
                        e = 1;
                        break;
                    }
                    if (EN[counter] == true)
                    {
                        z = counter;
                        break;
                    }

                }
            }
            return EN;
        }
        static long? BinarySearch(long[] a, int x)
        {
            if ((a.Length == 0) || (x < a[0]) || (x > a[a.Length - 1]))
                return null;

            int first = 0;

            int last = a.Length;

            while (first < last)
            {
                int mid = first + (last - first) / 2;//данный способ нахождения середины позволяет избежать переполнения при больших числах

                if (x <= a[mid])
                    last = mid;
                else
                    first = mid + 1;
            }
            if (a[last] == x)
                return last;
            else
                return null;
        }

        public static string Reverse(string s)
        {
            char[] charArray = s.ToCharArray();
            Array.Reverse(charArray);
            return new string(charArray);
        }

        static int[] ReadIntArrayLine()
        {
            char[] sep = { ' ' };
            return Console.ReadLine().Split(sep, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();
        }

        static long FindNok(long first, long second)
        {
            return first * second / FindNod(first, second);
        }

        static long FindNod(long first, long second)
        {
            while (true)
            {
                if (first == 0) return second;
                var temp = first;
                first = second % first;
                second = temp;
            }
        }
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine(Math.Ceiling(Math.Sqrt(n) * 2));

            //   long? number = BinarySearch(numbers, 5);// ? тип Nullable, значение всегда меньше на 1, так как массив старует с нуля

            //  bool[] primeNumber = Erastofen(50);//простые числа, решетом эрастофена

            // string s = Reverse("123456789");//поворот строки
            // string s1 = s1.Replace(" ", string.Empty));//удаление проблеов из строки, можно удалть любой элемент  заменой символа

        }
    }
}

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

namespace Yuhao
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int sqr = (int)Math.Sqrt(n);
            if (sqr * sqr < n) sqr++;
            int X;
            X = 2 * sqr;
            if (sqr * (sqr - 1) >= n)
                X--;

            Console.WriteLine(X);

   //   Console.ReadKey();

        }
    }
}

/*
csc -debug B.cs && mono --debug B.exe <<< "
*/

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

public class HelloWorld {
    public static void SolveCodeForces() {
        var n = cin.NextLong();

        var a = (long)Math.Floor(Math.Sqrt((double)n));

        if ((a+1) * (a+1) == n) a = a+1;

        var rem = n - a*a;
        var b = rem / a;
        if (b * a < rem) b++;

        // System.Console.WriteLine(new {n, a, b, rem});

        System.Console.WriteLine(a + a + b);
    }

    static Scanner cin = new Scanner();
    static StringBuilder cout = new StringBuilder();

    static public void Main () {
        SolveCodeForces();
        // System.Console.Write(cout.ToString());
    }
}

public static class Helpers {
    public static T[] CreateArray<T>(int length, Func<int, T> itemCreate) {
        var result = new T[length];
        for (var i = 0; i < result.Length; i++)
            result[i] = itemCreate(i);
        return result;
    }

    public static IEnumerable<int> IndicesWhere<T>(this IEnumerable<T> seq, Func<T, bool> cond) {
        var i = 0;
        foreach (var item in seq) {
            if (cond(item)) yield return i;
            i++;
        }
    }
}

public class Scanner
{
    private string[] line = new string[0];
    private int index = 0;

    public string Next() {
        if (line.Length <= index) {
            line = Console.ReadLine().Split(' ');
            index = 0;
        }
        var res = line[index];
        index++;
        return res;
    }

    public int NextInt() {
        return int.Parse(Next());
    }

    public long NextLong() {
        return long.Parse(Next());
    }

    public ulong NextUlong() {
        return ulong.Parse(Next());
    }

    public string[] Array() {
        line = Console.ReadLine().Split(' ');
        index = line.Length;
        return line;
    }

    public int[] IntArray(int emptyPrefixLen = 0) {
        var array = Array();
        var result = new int[emptyPrefixLen + array.Length];
        for (int i = 0; i < array.Length; i++)
            result[emptyPrefixLen + i] = int.Parse(array[i]);
        return result;
    }

    public long[] LongArray() {
        var array = Array();
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = long.Parse(array[i]);
        return result;
    }

    public ulong[] UlongArray() {
        var array = Array();
        var result = new ulong[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = ulong.Parse(array[i]);
        return result;
    }
}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            var side = Math.Sqrt(n);
            var ans = 0;
            if (side % 1 == 0) ans = (int)side * 2;
            else
            {
                var rem = n - (int)side * (int)side;
                if (rem <= (int)side) ans = (int)side * 2 + 1;
                else ans = (int)side * 2 + 2;
            }

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

/* Date: 31.01.2019 * Time: 21:45 */
//

/*
�	fflush(stdout) � ����� C++;
�	System.out.flush() � Java;
�	stdout.flush() � Python;
�	flush(output) � Pascal;

*/

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

class Example
{
	public static void Main (string[] args)
	{
# if ( ! ONLINE_JUDGE )
		StreamReader sr = new StreamReader ("C:\\TRR\\2019\\Task\\07 Codeforces\\036\\B.TXT");
		StreamWriter sw = new StreamWriter ("C:\\TRR\\2019\\Task\\07 Codeforces\\036\\B.OUT");
# endif

		NumberFormatInfo nfi = NumberFormatInfo.InvariantInfo;

		int n;

# if ( ONLINE_JUDGE )
		n = int.Parse (Console.ReadLine ());
# else
		n = int.Parse (sr.ReadLine ());
		sw.WriteLine ("*** n = " + n);
# endif

		int m = 1;
		for ( int i=0; ; i++ )
			if ( n <= i*(i+1) )
			{
				m = i + i + 1;
				break;
			}
			else if ( (i+1)*(i+1) >= n )
			{
				m = i + i + 2;
				break;
			}

# if ( ONLINE_JUDGE )
		Console.WriteLine (m);
# else
		sw.WriteLine (m);
		sw.Close ();
# endif

	}
}

using System;
using System.Collections.Generic;
using System.IO;

namespace prB {
    class Program {
#if ONLINE_JUDGE
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), System.Text.Encoding.ASCII, 1024 * 10);
#else
        private static readonly StreamWriter writer = new StreamWriter(@"..\..\output");
        private static readonly StreamReader reader = new StreamReader(@"..\..\input");
#endif

        static void Main(string[] args) {
            int n = NextInt();
            int a = (int) Math.Ceiling(Math.Sqrt(n));
            int b = (n + a - 1) / a;
            writer.Write(a + b);
            writer.Flush();
#if !ONLINE_JUDGE
            writer.Close();
#endif
        }
        private static int NextInt() {
            int c;
            int res = 0;
            do {
                c = reader.Read();
                if(c == -1)
                    return res;
            } while(c != '-' && (c < '0' || c > '9'));
            int sign = 1;
            if(c == '-') {
                sign = -1;
                c = reader.Read();
            }
            res = c - '0';
            while(true) {
                c = reader.Read();
                if(c < '0' || c > '9')
                    return res * sign;
                res *= 10;
                res += c - '0';
            }
        }
        private static long NextLong() {
            int c;
            long res = 0;
            do {
                c = reader.Read();
                if(c == -1)
                    return res;
            } while(c != '-' && (c < '0' || c > '9'));
            int sign = 1;
            if(c == '-') {
                sign = -1;
                c = reader.Read();
            }
            res = c - '0';
            while(true) {
                c = reader.Read();
                if(c < '0' || c > '9')
                    return res * sign;
                res *= 10;
                res += c - '0';
            }
        }
    }
}

using System;
using System.Collections;
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();
            int n = Convert.ToInt32(temp);
            int x = (int)Math.Floor(Math.Sqrt((double)n));
            int y = x;
            int i = 0;
            while (y * x < n)
            {
                if (i % 2 == 0)
                {
                    x++;
                }
                else
                {
                    y++;
                }
                i = 1 - i;
            }
            Console.WriteLine(x + y);
        }
    }
}

using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text.RegularExpressions;
using System.Text;
using System;

class SolutionCF
{
    static void Main(string[] args)
    {
        var n = long.Parse(Console.ReadLine());
        var sqrt = (long)Math.Sqrt(n);

        var r = sqrt;
        var c = sqrt;

        if (r * c < n)
            r++;
        if (r * c < n)
            c++;

        Console.WriteLine(r + c);
    }

}

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

namespace CodeForces
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = Int64.Parse(Console.ReadLine());
            //var a = Array.ConvertAll(Console.ReadLine().Split(' '), Int64.Parse);
            var a = (long) Math.Floor(Math.Sqrt(n));
            var diff = n - a * a;
            if (diff == 0)
            {
                Console.WriteLine(a*2);
            }
            else if (diff <= a)
            {
                Console.WriteLine(a*2 + 1);
            }
            else
            {
                Console.WriteLine(a*2 + 2);
            }
        }
    }
}

using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            if (n == 1)
            {
                Console.WriteLine(2);
                return;
            }

            if (n == 2)
            {
                Console.WriteLine(3);
                return;
            }

            var i = 1;
            for (; Math.Pow(2, i) < n; i += 1) ;

            var power = Math.Pow(2, i);

            if (power - i >= n)
            {
                Console.WriteLine(i*2 - 1);
                return;
            }
            else
            {
                Console.WriteLine(i*2);
                return;
            }
        }
    }
}

using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            if (n == 1)
            {
                Console.WriteLine(2);
                return;
            }

            var i = 1;
            for (; Math.Pow(2, i) < n; i += 1) ;

            var power = Math.Pow(2, i);

            if (power - i >= n)
            {
                Console.WriteLine(i*2 - 1);
                return;
            }
            else
            {
                Console.WriteLine(i*2);
                return;
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.IO;

namespace prB {
    class Program {
#if ONLINE_JUDGE
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), System.Text.Encoding.ASCII, 1024 * 10);
#else
        private static readonly StreamWriter writer = new StreamWriter(@"..\..\output");
        private static readonly StreamReader reader = new StreamReader(@"..\..\input");
#endif

        static void Main(string[] args) {
            int n = NextInt();
            int a = (int) Math.Ceiling(Math.Sqrt(n));
            int b = (int) Math.Ceiling(n / (float) a);
            writer.Write(a + b);
            writer.Flush();
#if !ONLINE_JUDGE
            writer.Close();
#endif
        }
        private static int NextInt() {
            int c;
            int res = 0;
            do {
                c = reader.Read();
                if(c == -1)
                    return res;
            } while(c != '-' && (c < '0' || c > '9'));
            int sign = 1;
            if(c == '-') {
                sign = -1;
                c = reader.Read();
            }
            res = c - '0';
            while(true) {
                c = reader.Read();
                if(c < '0' || c > '9')
                    return res * sign;
                res *= 10;
                res += c - '0';
            }
        }
        private static long NextLong() {
            int c;
            long res = 0;
            do {
                c = reader.Read();
                if(c == -1)
                    return res;
            } while(c != '-' && (c < '0' || c > '9'));
            int sign = 1;
            if(c == '-') {
                sign = -1;
                c = reader.Read();
            }
            res = c - '0';
            while(true) {
                c = reader.Read();
                if(c < '0' || c > '9')
                    return res * sign;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.For example, let's say that Vitaly's favourite digits are 1 and 3, then number 12 isn't good and numbers 13 or 311 are. Also, number 111 is excellent and number 11 isn't. Now Vitaly is wondering, how many excellent numbers of length exactly n are there. As this number can be rather large, he asks you to count the remainder after dividing it by 1000000007 (109 + 7).A number's length is the number of digits in its decimal representation without leading zeroes.

The first line contains three integers: a, b, n (1 ≤ a < b ≤ 9, 1 ≤ n ≤ 106).

Print a single integer — the answer to the problem modulo 1000000007 (109 + 7).

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

namespace Codeforces
{
    internal static class Program
    {
        private const string test = "C2";

        private static void Solve()
        {
            int a, b, n;
            Read(out a, out b, out n);
            var mod = 1000000007;
            var fact = new long[n+1];
            fact[0] = 1;
            for (int i = 1; i <= n; i++)
            {
                fact[i] = fact[i-1]*i;
                fact[i] %= mod;
            }
            var res = 0L;
            for (int aCount= 0; aCount <= n; aCount++)
            {
                var bCount = n - aCount;
                if (IsGood(aCount*a + bCount*b, a, b))
                {
                    var denominator = fact[aCount]*fact[bCount];
                    denominator %= mod;
                    var temp = fact[n]* BinPow(denominator, mod-2,mod);
                    var tempint = (int)(temp%mod);
                    res += tempint;
                    res %= mod;
                }
            }
            WriteLine(res);
        }

        private static long BinPow(long a, int pow, int mod)
        {
            if (pow == 0)
                return 1;

            if (pow%2 == 1)
                return (BinPow(a, pow - 1, mod)*a) %mod;

            var b = BinPow(a, pow/2, mod);
            b %= mod;
            var res = b*b;
            res %= mod;
            return res;
        }

        private static bool IsGood(int n, int a, int b)
        {
            var res = (n!=0);
            while (n > 0)
            {
                var end = n%10;
                n /= 10;
                res &= (end == a || end == b);
            }
            return res;
        }

        private static void Main()
        {
            if (Debugger.IsAttached)
            {
                Console.SetIn(new StreamReader(String.Format(@"..\..\..\..\Tests\{0}.in", test)));
            }

            Solve();

            if (Debugger.IsAttached)
            {
                Console.In.Close();
                Console.SetIn(new StreamReader(Console.OpenStandardInput()));
                Console.ReadLine();
            }
        }

        #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 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;
using System.Text;

namespace CodeForces
{
    internal class Program
    {
        private const long Divisor = 1000000007;

        public static void Main()
        {
            Solve3();
        }

        public static void Solve3()
        {
            var ns = Console.ReadLine().Split(new[] {' '}).Select(int.Parse).ToArray();
            var a = ns[0];
            var b = ns[1];
            var n = ns[2];

            var divs = new int[n + 1];
            for (var i = 0; i <= n; i++) divs[i] = -1;
            for (var i = 2; i < n; i++)
            {
                for (var k = i*2; k <= n; k += i)
                    divs[k] = i;
            }

            var result = 0L;
            for (var na = 0; na <= n; na++)
            {
                var nb = n - na;
                var acc = nb*b + na*a;

                var isWonderful = true;
                while (acc > 0)
                {
                    var d = acc%10;
                    if (d != a && d != b)
                    {
                        isWonderful = false;
                        break;
                    }
                    acc = acc/10;
                }
                if (!isWonderful) continue;

                var muls = new int[n + 1];
                for (var i = n; i > na; i--) muls[i]++;
                for (var i = 2; i <= nb; i++) muls[i]--;

                var combs = 1L;
                for (var i = n; i > 1 ; i--)
                {
                    if (divs[i] == -1)
                    {
                        for (var j = 0; j < muls[i]; j++) combs = (combs * i) % Divisor;
                    }
                    else
                    {
                        var d = divs[i];
                        muls[d] += muls[i];
                        muls[i/d] += muls[i];
                    }
                }
                result = (result + combs)%Divisor;
            }
            Console.WriteLine(result);
        }

        public static void Solve1()
        {
            int.Parse(Console.ReadLine());

            var arr1 = new List<int>();
            var arr2 = new List<int>();
            var arr3 = new List<int>();

            var numbers = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var negatives = new List<int>();
            foreach (var n in numbers)
            {
                if (n == 0)
                    arr3.Add(n);
                else if (n > 0)
                    arr2.Add(n);
                else negatives.Add(n);
            }

            arr1.Add(negatives[0]);
            if (arr2.Count == 0)
            {
                arr2.Add(negatives[1]);
                arr2.Add(negatives[2]);
                for (var i = 3; i < negatives.Count; i++)
                    arr3.Add(negatives[i]);
            }
            else
            {
                for (var i = 1; i < negatives.Count; i++)
                    arr3.Add(negatives[i]);

            }

            Console.Write("{0} ", arr1.Count);
            Console.WriteLine(string.Join(" ", arr1.Select(l => l.ToString()).ToArray()));
            Console.Write("{0} ", arr2.Count);
            Console.WriteLine(string.Join(" ", arr2.Select(l => l.ToString()).ToArray()));
            Console.Write("{0} ", arr3.Count);
            Console.WriteLine(string.Join(" ", arr3.Select(l => l.ToString()).ToArray()));
        }
    }
}

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

namespace CodeForces
{
    class R181_Div2_C
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int n = int.Parse(s[2]);

            List<int> ind = new List<int>();
            for (int i = 0; i <= n; i++)
            {
                int sum = a * i + b * (n - i);
                string sumS = sum.ToString();
                bool good = true;
                for (int j = 0; j < sumS.Length; j++)
                {
                    int d = sumS[j] - '0';
                    if (d != a && d != b)
                    {
                        good = false;
                        break;
                    }
                }
                if (good)
                    ind.Add(i);
            }

            GenerateFactorials();

            long ans = 0;
            for (int i = 0; i < ind.Count; i++)
            {
                ans += nCk(n, ind[i]);
                ans = ans % MOD;
            }

            Console.WriteLine(ans);
        }

        static long MOD = 1000000007;

        static long AddMod(long x, long y)
        {
            return (x + y) % MOD;
        }
        static long MulMod(long x, long y)
        {
            return (x * y) % MOD;
        }
        static long GCDex(long a, long b, ref long nx, ref long ny)
        {
            if (b == 0)
            {
                nx = 1;
                ny = 0;
                return a;
            }
            long x = 0, y = 0;
            long d = GCDex(b, a % b, ref x, ref y);
            nx = y;
            ny = x - (a / b) * y;
            return d;
        }
        static long ModInv(long a)
        {
            long f = 0, g = 0;
            if (GCDex(a, MOD, ref f, ref g) != 1)  //MOD must be prime
                throw new System.ArgumentException("No Inverse");
            f %= MOD;
            f += MOD;
            f %= MOD;
            if (MulMod(a, f) != 1)
                throw new System.ArgumentException("No Inverse");
            return f;
        }
        static long DivMod(long a, long b)
        {
            return MulMod(a, ModInv(b));
        }

        static long[] facts = new long[1000001];
        static void GenerateFactorials()
        {
            facts[0] = 1;
            for (int i = 1; i < 1000001; i++)
                facts[i] = MulMod(facts[i - 1], i);
        }

        static long nCk(long n, long k)
        {
            if (n - k < 0)
                throw new System.ArgumentException("Invalid parms");
            long nCOMBk = DivMod(DivMod(facts[n], facts[k]), facts[n - k]);
            return nCOMBk;
        }
    }
}

#define Online

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

delegate double F(double x);
delegate decimal Fdec(decimal x);
namespace CF
{
    class Program
    {

        static void Main(string[] args)
        {

            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

#if FileIO
        StreamReader sr = new StreamReader("input.txt");
        StreamWriter sw = new StreamWriter("output.txt");
        Console.SetIn(sr);
        Console.SetOut(sw);
#endif

            int a, b, n;
            string[] input = ReadArray();
            a = int.Parse(input[0]);
            b = int.Parse(input[1]);
            n = int.Parse(input[2]);
            const int t = 10;
            const int mod = 1000 * 1000 * 1000 + 7;
            long ans = 0;
            long[] fact = new long[n + 1];
            for (int i = 0; i <= n; i++)
            {
                fact[i] = 1;
            }
            for (long i = 1; i <= n; i++)
            {
                fact[i] = (fact[i - 1] * i) % mod;
            }

            for (int i = 0; i <= n; i++)
            {
                int cur = i * a + b * (n - i);
                do
                {
                    int rem = cur % t;
                    if (rem != a && rem != b)
                        break;
                    cur /= 10;
                }
                while (cur != 0);
                if (cur == 0)
                {
                    long inv = MyMath.BinPow((fact[n - i] * fact[i]) % mod, mod - 2, mod);
                    ans = (ans + (inv * fact[n]) % mod) % mod;
                }
            }
            Console.WriteLine(ans);

#if Online
            Console.ReadLine();
#endif

#if FileIO
        sr.Close();
        sw.Close();
#endif
        }

        static string[] ReadArray()
        {
            return Console.ReadLine().Split(' ');
        }

        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
    }

    public static class MyMath
    {
        public static long BinPow(long a, long n, long mod)
        {
            long res = 1;
            while (n > 0)
            {
                if ((n & 1) == 1)
                {
                    res = (res * a) % mod;
                }
                a = (a * a) % mod;
                n >>= 1;
            }
            return res;
        }
    }

    public class SegmentTree
    {
        int[] v_min;
        int[] v_max;
        int[] mas;
        public void BuildTree(int[] a)
        {
            int n = a.Length - 1;
            int z = 0;
            while (n >= 2)
            {
                z++;
                n >>= 1;
            }
            n = 1 << (z + 1);
            v_min = new int[n << 1];
            v_max = new int[n << 1];
            mas = new int[n << 1];
            for (int i = n; i < n + a.Length; i++)
                v_min[i] = a[i - n];
            for (int i = n + a.Length; i < v_min.Length; i++)
                v_min[i] = int.MaxValue;
            for (int i = n - 1; i > 0; i--)
                v_min[i] = Math.Min(v_min[(i << 1)], v_min[(i << 1) + 1]);

            for (int i = n; i < n + a.Length; i++)
                v_max[i] = a[i - n];
            for (int i = n + a.Length; i < v_max.Length; i++)
                v_max[i] = int.MinValue;
            for (int i = n - 1; i > 0; i--)
                v_max[i] = Math.Max(v_max[(i << 1)], v_max[(i << 1) + 1]);

        }
        //nil
        public int RMQ_MIN(int l, int r)
        {
            int ans = int.MaxValue;
            l += v_min.Length >> 1;
            r += v_min.Length >> 1;
            const int o = 1;
            while (l <= r)
            {
                if ((l & 1) == o)
                    ans = Math.Min(ans, v_min[l]);
                if (!((r & 1) == 0))
                    ans = Math.Min(ans, v_min[r]);
                l = (l + 1) >> 1;
                r = (r - 1) >> 1;
            }
            return ans;
        }

        public int RMQ_MAX(int l, int r)
        {
            int ans = int.MinValue;
            l += v_max.Length >> 1;
            r += v_max.Length >> 1;
            const int o = 1;
            while (l <= r)
            {
                if ((l & 1) == o)
                    ans = Math.Max(ans, v_max[l]);
                if (!((r & 1) == 0))
                    ans = Math.Max(ans, v_max[r]);
                l = (l + 1) >> 1;
                r = (r - 1) >> 1;
            }
            return ans;
        }

        public void Put(int l, int r, int op)
        {
            l += mas.Length >> 1;
            r += mas.Length >> 1;
            while (l <= r)
            {
                if (l % 2 != 0)
                    mas[l] = op;
                if (r % 2 == 0)
                    mas[r] = op;
                l = (l + 1) >> 1;
                r = (r - 1) >> 1;
            }
        }

        public int Get(int x)
        {
            x += mas.Length >> 1;
            int ans = int.MinValue;
            while (x > 0)
            {
                ans = Math.Max(mas[x], ans);
                x >>= 1;
            }
            return ans;
        }

        public void Update(int i, int x)
        {
            i += v_min.Length >> 1;
            v_min[i] = x;
            v_max[i] = x;
            i >>= 1;
            while (i > 0)
            {
                v_min[i] = Math.Min(v_min[(i << 1)], v_min[(i << 1) + 1]);
                v_max[i] = Math.Max(v_max[(i << 1)], v_max[(i << 1) + 1]);
                i >>= 1;
            }
        }
    }
    class Edge
    {
        public int a;
        public int b;
        public int w;

        public Edge(int a, int b, int w)
        {
            this.a = a;
            this.b = b;
            this.w = w;
        }
    }
    class Graph
    {
        public List<List<int>> g = new List<List<int>>();
        public List<Edge> e = new List<Edge>();
        public Stack<int> s;
        public List<bool> u;
        public List<int> d; //длина
        public List<int> p; //путь
        public Queue<int> q;
        public List<List<int>> temp;
        public int n;

        public Graph(int n)
        {
            temp = new List<List<int>>();
            for (int i = 0; i <= n; i++)
            {
                g.Add(new List<int>());
            }

            u = new List<bool>();

            for (int i = 0; i <= n; i++)
                u.Add(true);
            this.n = n;
        }

        public void DFS(int v)
        {
            s = new Stack<int>();
            temp.Add(new List<int>());
            s.Push(v);
            u[v] = false;
            int cur;
            bool all;
            while (s.Count != 0)
            {
                cur = s.Peek();

                all = true;
                for (int i = 0; i < g[cur].Count; i++)
                {
                    if (u[g[cur][i]])
                    {
                        all = false;
                        u[g[cur][i]] = false;
                        s.Push(g[cur][i]);
                    }
                }
                if (all)
                {
                    temp[temp.Count - 1].Add(s.Pop());
                }
            }
        }

        public void BFS(params int[] v)
        {
            q = new Queue<int>();
            u = new List<bool>();
            d = new List<int>();
            p = new List<int>();

            for (int i = 0; i <= n; i++)
            {
                u.Add(true);
                d.Add(0);
                p.Add(0);
            }

            q.Enqueue(v[0]);
            u[v[0]] = false;
            int cur;

            while (q.Count != 0)
            {
                cur = q.Dequeue();
                for (int i = 0; i < g[cur].Count; i++)
                    if (u[g[cur][i]])
                    {
                        q.Enqueue(g[cur][i]);
                        u[g[cur][i]] = false;
                        p[g[cur][i]] = cur;
                        d[g[cur][i]] = d[cur] + 1;
                    }
            }

            int from = v[1];
            string path = from + "";
            while (p[from] != 0)
            {
                path = p[from] + " " + path;
                from = p[from];
            }
            Console.WriteLine(d[v[1]] + " : " + path);
        }

        public void FordBellman(params int[] v)
        {
            d = new List<int>();
            p = new List<int>();
            for (int i = 0; i <= n; i++)
            {
                d.Add(int.MaxValue);
                p.Add(0);
            }
            d[v[0]] = 0;

            for (int i = 0; i < n - 1; i++)
            {
                for (int j = 0; j < e.Count; j++)
                {
                    if (d[e[j].a] != int.MaxValue)
                    {
                        if (d[e[j].a] + e[j].w < d[e[j].b])
                        {
                            d[e[j].b] = d[e[j].a] + e[j].w;
                            p[e[j].b] = e[j].a;
                        }
                    }
                }
            }

            int from = v[1];

            if (d[from] == int.MaxValue)
            {
                Console.WriteLine("Can't find the minimal path");
                return;
            }

            string ans = from + "";
            while (p[from] != 0)
            {
                ans = p[from] + " " + ans;
                from = p[from];
            }

            Console.WriteLine(d[v[1]] + " : " + ans);
        }
    }
    static class ArrayUtils
    {
        public static int BinarySearch(int[] a, int val)
        {
            int left = 0;
            int right = a.Length - 1;
            int mid;

            while (left < right)
            {
                mid = left + ((right - left) >> 1);
                if (val <= a[mid])
                {
                    right = mid;
                }
                else
                {
                    left = mid + 1;
                }
            }

            if (a[left] == val)
                return left;
            else
                return -1;
        }

        public static double Bisection(F f, double left, double right, double eps)
        {
            double mid;
            while (right - left > eps)
            {
                mid = left + ((right - left) / 2d);
                if (Math.Sign(f(mid)) != Math.Sign(f(left)))
                    right = mid;
                else
                    left = mid;
            }
            return (left + right) / 2d;
        }

        public static decimal TernarySearchDec(Fdec f, decimal eps, decimal l, decimal r, bool isMax)
        {
            decimal m1, m2;
            while (r - l > eps)
            {
                m1 = l + (r - l) / 3m;
                m2 = r - (r - l) / 3m;
                if (f(m1) < f(m2))
                    if (isMax)
                        l = m1;
                    else
                        r = m2;
                else
                    if (isMax)
                        r = m2;
                    else
                        l = m1;
            }
            return r;
        }

        public static double TernarySearch(F f, double eps, double l, double r, bool isMax)
        {
            double m1, m2;
            while (r - l > eps)
            {
                m1 = l + (r - l) / 3d;
                m2 = r - (r - l) / 3d;
                if (f(m1) < f(m2))
                    if (isMax)
                        l = m1;
                    else
                        r = m2;
                else
                    if (isMax)
                        r = m2;
                    else
                        l = m1;
            }
            return r;
        }

        public static void Merge(int[] A, int p, int q, int r, int[] L, int[] R)
        {
            for (int i = p; i <= q; i++)
                L[i] = A[i];
            for (int i = q + 1; i <= r; i++)
                R[i] = A[i];

            for (int k = p, i = p, j = q + 1; k <= r; k++)
            {
                if (i > q)
                {
                    for (; k <= r; k++, j++)
                        A[k] = R[j];
                    return;
                }
                if (j > r)
                {
                    for (; k <= r; k++, i++)
                        A[k] = L[i];
                    return;
                }
                if (L[i] <= R[j])
                {
                    A[k] = L[i];
                    i++;
                }
                else
                {
                    A[k] = R[j];
                    j++;
                }
            }
        }

        public static void Merge_Sort(int[] A, int p, int r, int[] L, int[] R)
        {
            if (!(p < r)) return;
            int q = p + ((r - p) >> 1);
            Merge_Sort(A, p, q, L, R);
            Merge_Sort(A, q + 1, r, L, R);
            Merge(A, p, q, r, L, R);
        }

        static void Shake(int[] a)
        {
            Random rnd = new Random(Environment.TickCount);
            int temp, b, c;
            for (int i = 0; i < a.Length; i++)
            {
                b = rnd.Next(0, a.Length);
                c = rnd.Next(0, a.Length);
                temp = a[b];
                a[b] = a[c];
                a[c] = temp;
            }
        }
    }
}

using System;
using System.Diagnostics.Contracts;
using System.Globalization;
using System.IO;
using System.Linq;

namespace Codeforces.R300
{
    public static class C
    {
        const int MOD = 1000000007;

        public static void Main()
        {
            using (var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Solve(Console.In, sw);
            }
        }

        public static void Solve(TextReader tr, TextWriter tw)
        {
            Contract.Requires(tr != null);
            Contract.Requires(tw != null);

            var info = CultureInfo.CurrentCulture;
            var abn = tr.ReadLine().Split().Select(x => int.Parse(x, info)).ToArray();

            var res = Calc(abn[0], abn[1], abn[2]);

            tw.WriteLine(res);
        }

        private static int Calc(int a, int b, int n)
        {
            var res = 0L;

            var combination = new long[n + 1];
            combination[0] = 1;
            for (int i = 1; i <= n; ++i)
            {
                combination[i] = combination[i - 1] * ModDiv(n - i + 1, i, MOD) % MOD;
            }

            for (int i = 0; i <= n; ++i)
            {
                var sum = a * (n - i) + b * i;
                if (IsGood(a, b, sum))
                {
                    res = (res + combination[i]) % MOD;
                }
            }

            return (int)res;
        }

        public static int Combination(int n, int r)
        {
            var res = 1L;
            for (int i = 0; i < r; ++i)
            {
                res = res * (n - i) % MOD;
            }
            for (int i = 0; i < r; ++i)
            {
                res = ModDiv(res, r - i, MOD);
            }
            return (int)res % MOD;
        }

        public static long ModDiv(long res, int v, int mod)
        {
            return res * ModPow(v, mod - 2, mod) % mod;
        }

        public static long ModPow(long x, int n, int mod)
        {
            var res = 1L;
            for (; n > 0; n >>= 1)
            {
                if ((n & 1) == 1)
                {
                    res = res * x % mod;
                }
                x = x * x % mod;
            }
            return res;
        }

        public static bool IsGood(int a, int b, int n)
        {
            for (; n > 0; n /= 10)
            {
                var lastDigit = n % 10;

                if (lastDigit != a && lastDigit != b)
                {
                    return false;
                }
            }
            return true;
        }

        public static int SumDigits(int n)
        {
            var res = 0;

            for (; n > 0; n /= 10)
            {
                res += n % 10;
            }

            return res;
        }
    }
}

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

namespace Beautiful_Numbers
{
    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 int mod = 1000000007;

        private static int[] fact;

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

            InitFact(n);

            long sum = 0;
            for (int i = 0; i <= n; i++)
            {
                int d = a*i + b*(n - i);
                bool ok = true;
                while (d > 0)
                {
                    int dd = d%10;
                    if (dd != a && dd != b)
                    {
                        ok = false;
                        break;
                    }
                    d /= 10;
                }
                if (!ok)
                    continue;

                sum = (sum + GetCFact(n, i))%mod;
            }

            writer.WriteLine(sum);
            writer.Flush();
        }

        private static void InitFact(int n)
        {
            fact = new int[n + 1];
            fact[0] = 1;

            for (long i = 1; i < fact.Length; i++)
            {
                fact[i] = (int) ((fact[i - 1]*i)%mod);
            }
        }

        private static long GetCFact(int n, int k)
        {
            return (((fact[n]*Pow(fact[k], mod - 2))%mod)*Pow(fact[n - k], mod - 2))%mod;
        }

        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 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.IO;
using System.Text;

namespace Beautiful_Numbers
{
    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 int mod = 1000000007;

        private static long[] fact;
        private static long[] fact1;

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

            InitFact(n);

            long sum = 0;
            for (int i = 0; i <= n; i++)
            {
                int d = a*i + b*(n - i);
                bool ok = true;
                while (d > 0)
                {
                    int dd = d%10;
                    if (dd != a && dd != b)
                    {
                        ok = false;
                        break;
                    }
                    d /= 10;
                }
                if (!ok)
                    continue;

                sum = (sum + GetCFact(n, i))%mod;
            }

            writer.WriteLine(sum);
            writer.Flush();
        }

        private static void InitFact(int n)
        {
            fact = new long[n + 1];
            fact1 = new long[n + 1];

            fact[0] = 1;
            fact1[0] = 1;

            for (int i = 1; i < fact.Length; i++)
            {
                fact[i] = (fact[i - 1]*i)%mod;
                fact1[i] = Pow(fact[i], mod - 2);
            }
        }

        private static long GetCFact(int n, int k)
        {
            return (((fact[n]*fact1[k])%mod)*fact1[n - k])%mod;
        }

        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 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.IO;
using System.Text;

namespace Beautiful_Numbers
{
    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 int mod = 1000000007;

        private static long[] fact;
        private static long[] fact1;

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

            InitFact(n);

            long sum = 0;
            for (int i = 0; i <= n; i++)
            {
                int d = a*i + b*(n - i);
                bool ok = true;
                while (d > 0)
                {
                    int dd = d%10;
                    if (dd != a && dd != b)
                    {
                        ok = false;
                        break;
                    }
                    d /= 10;
                }
                if (!ok)
                    continue;

                sum = (sum + GetCFact(n, i))%mod;
            }

            writer.WriteLine(sum);
            writer.Flush();
        }

        private static void InitFact(int n)
        {
            fact = new long[n + 1];
            //fact1 = new long[n + 1];

            fact[0] = 1;
            //fact1[0] = 1;

            for (int i = 1; i < fact.Length; i++)
            {
                fact[i] = (fact[i - 1]*i)%mod;
                //fact1[i] = Pow(fact[i], mod - 2);
            }
        }

        private static long GetCFact(int n, int k)
        {
            return (((fact[n]*Pow(fact[k], mod - 2))%mod)*Pow(fact[n - k], mod - 2))%mod;
        }

        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 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;
using System.Threading.Tasks;
using System.IO;
using System.Numerics;

class Program
{
    static TextReader reader;
    static TextWriter writer;
    static Program()
    {
#if ONLINE_JUDGE
        reader = Console.In;
        writer = Console.Out;
#else
        reader = new StreamReader("input.txt");
        writer = new StreamWriter("output.txt");
#endif
    }
    static long gcd(long a, long b)
    {
        if (a < b)
        {
            long t = a;
            a = b;
            b = t;
        }
        return (b > 0) ? gcd(b, a % b) : a;
    }
    /*static BigInteger C(int k, int n)
    {
        BigInteger c = 1;
        if (k < n / 2)
            k = n - k;
        for (int i = k + 1; i <= n; ++i)
            c *= i;
        for (int i = 2; i <= n - k; ++i)
            c /= i;
        return c;
    }*/
    static void _235A()
    {
        long n = long.Parse(reader.ReadLine()), ans = n * (n - 1);
        if (n < 3)
            ans = n;
        else if (n % 2 == 1)
            ans *= n - 2;
        else
        {
            long t = (n - 2) / 2;
            for (long i = n - 3; i > (n - 2) / 2; --i)
            {
                long g = gcd(n, i);
                if (g == 1)
                    t = Math.Max(t, i);
            }
            ans *= t;
        }
        writer.Write(Math.Max(ans,(n-1)*(n-2)*(n-3)));
    }
    static void _106C()
    {
        string[] s = reader.ReadLine().Split();
        int n = int.Parse(s[0]), m = int.Parse(s[1]), c0 = int.Parse(s[2]), d0 = int.Parse(s[3]);
        int[] a = new int[m + 1], b = new int[m + 1], c = new int[m + 1], d = new int[m + 1];
        for (int i = 1; i <= m; ++i)
        {
            s = reader.ReadLine().Split();
            a[i] = int.Parse(s[0]);
            b[i] = int.Parse(s[1]);
            c[i] = int.Parse(s[2]);
            d[i] = int.Parse(s[3]);
        }
        int[] dp_d = new int[n + 1], dp_c = new int[n + 1];
        dp_d[0] = dp_c[0] = 0;
        int[,] dp_b = new int[n + 1, m + 1];
        for (int i = 1; i <= n; ++i)
        {
            if (c0 == i)
            {
                dp_d[i] = d0;
                dp_c[i] = i;
            }
            for (int j = 1; j <= m; ++j)
            {
                if (c[j] == i)
                {
                    if (dp_d[i] < d[j] && b[j] <= a[j])
                    {
                        dp_d[i] = d[j];
                        dp_c[i] = i;
                        dp_b[i, j] = b[j];
                    }
                    else if (dp_d[i] == d[j])
                    {
                        // ???
                    }
                }
            }
            // what about leftovers???
            for (int j = 1; j <= i / 2; ++j)
            {
                if (dp_d[j] + dp_d[i - j] > dp_d[i])
                {
                    bool ok = true;
                    for (int k = 1; k <= m && ok; ++k)
                    {
                        if (dp_b[j, k] + dp_b[i - j, k] > a[k])
                            ok = false;
                    }
                    if (ok)
                    {
                        dp_d[i] = dp_d[j] + dp_d[i - j];
                        dp_c[i] = dp_c[j] + dp_c[i - j];
                        for (int k = 1; k <= m; ++k)
                            dp_b[i,k] = dp_b[j, k] + dp_b[i - j, k];
                    }
                }
            }
            if (c0 <= i)
                if (d0 + dp_d[i - c0] > dp_d[i])
                {
                    dp_d[i] = d0 + dp_d[i - c0];
                    dp_c[i] = c0 + dp_c[i - c0];
                }
            if (dp_d[i] < dp_d[i - 1])
            {
                dp_d[i] = dp_d[i - 1];
                dp_c[i] = dp_c[i - 1];
                for (int j = 1; j <= m; ++j)
                    dp_b[i, j] = dp_b[i - 1, j];
            }
        }
        writer.Write(dp_d[n]);
    }
    static long pow(long a, long x, long mod)
    {
        long res = 1;
        while (x > 0)
        {
            if ((x & 1) != 0)
            {
                res = (res * a) % mod;
                --x;
            }
            else
            {
                a = (a * a) % mod;
                x >>= 1;
            }
        }
        return res;
    }
    static void _300C()
    {
        string[] s = reader.ReadLine().Split();
        long a = long.Parse(s[0]), b = long.Parse(s[1]), n = long.Parse(s[2]);
        if (a > b)
        {
            long t = a;
            a = b;
            b = t;
        }
        long[] fact = new long[n + 1];
        fact[0] = fact[1] = 1;
        long mod = 1000000007;
        for (long i = 2; i <= n; ++i)
            fact[i] = fact[i - 1] * i % mod;
        long an = n, bn = 0;
        long ans = 0;
        while (an >= 0)
        {
            long num = an * a + bn * b;
            bool ok = true;
            for (long p = 10; ok && p <= 10000000; p *= 10)
            {
                long t = num % p / (p / 10);
                if (t != a && t != b && (t != 0 || p <= num))
                    ok = false;
            }
            if (ok)
            {
                long c = (((fact[n] * pow(fact[an], mod - 2, mod)) % mod) * pow(fact[bn], mod - 2, mod)) % mod;
                ans += c;
                ans %= mod;
            }
            --an;
            ++bn;
        }
        writer.Write(ans);
    }
    static void Main(string[] args)
    {
        //_235A();
        //_106C();
        _300C();
        reader.Close();
        writer.Close();
    }
}

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

namespace CodeForces
{
    class Program
    {
        const int MOD = 1000000007;
        static long[] fac = new long[1000010];
        static long mod_pow(long num, long pow, long mod)
        {
            long  ret = 1;
            while (pow>0)
             {
                if (pow%2>0)
                {
                   ret = (ret*num)%mod;
                }
                pow>>=1;
                num = (num*num)%mod;
            }
            return ret;
        }
        static void precalc()
        {
            fac[0] = 1;
            for (int i = 1; i <= 1000000; i++)
            {
                fac[i] = i * fac[i - 1];
                fac[i] %= MOD;
            }
        }
        static long mod_inv(long num, long mod)
        {
             return mod_pow(num, mod-2, mod);
        }
        // (A/B) mod M = (A mod M) * mod_inv(B mod M, M)
        static long C(int n, int k)
        {
            long up = fac[n];
            long down = fac[k] * fac[n - k] % MOD;
            return up * mod_inv(down, MOD);
        }
        static long solve(int a, int b, int i, int n)
        {
            if ((i - a * n) % (b-a) > 0) return 0;
            int y = (i - a * n) / (b-a);
            if (y < 0) return 0;
            if (y > n) return 0;
            return C(n, y);
        }
        static void Main(string[] args)
        {
            precalc();
            int a, b, n;
            string[] s = Console.ReadLine().Split();
            a = int.Parse(s[0]);
            b = int.Parse(s[1]);
            n = int.Parse(s[2]);
            long ans=0;
            for (int i = 1; i <= 9*n; i++)
            {
                bool good = true;
                int j = i;
                int numofc = 0;
                while (j > 0)
                {
                    numofc++;
                    int last = j % 10;
                    j /= 10;
                    if (last != a && last != b) {good = false; break;}
                }
                if (!good) continue;
                //Console.WriteLine(i.ToString());
                ans += solve(a, b, i,n);
                ans %= MOD;
            }
            Console.WriteLine(ans.ToString());
            Console.ReadLine();
        }
    }
}

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

namespace CodeForces
{
    class Program
    {
        const int MOD = 1000000007;
        static long[] fac = new long[1000010];
        static long mod_pow(long num, long pow, long mod)
        {
            long  ret = 1;
            while (pow>0)
             {
                if (pow%2>0)
                {
                   ret = (ret*num)%mod;
                }
                pow>>=1;
                num = (num*num)%mod;
            }
            return ret;
        }
        static void precalc()
        {
            fac[0] = 1;
            for (int i = 1; i <= 1000000; i++)
            {
                fac[i] = i * fac[i - 1];
                fac[i] %= MOD;
            }
        }
        static long mod_inv(long num, long mod)
        {
             return mod_pow(num, mod-2, mod);
        }
        // (A/B) mod M = (A mod M) * mod_inv(B mod M, M)
        static long C(int n, int k)
        {
            long up = fac[n];
            long down = fac[k] * fac[n - k] % MOD;
            return up * mod_inv(down, MOD);
        }
        static long solve(int a, int b, int i, int n)
        {
            if ((i - a * n) % (b-a) > 0) return 0;
            int y = (i - a * n) / (b-a);
            if (y < 0) return 0;
            if (y > n) return 0;
            return C(n, y);
        }
        static void Main(string[] args)
        {
            precalc();
            int a, b, n;
            string[] s = Console.ReadLine().Split();
            a = int.Parse(s[0]);
            b = int.Parse(s[1]);
            n = int.Parse(s[2]);
            long ans=0;
            for (int i = 1; i <= 9*n; i++)
            {
                bool good = true;
                int j = i;
                int numofc = 0;
                while (j > 0)
                {
                    numofc++;
                    int last = j % 10;
                    j /= 10;
                    if (last != a && last != b) {good = false; break;}
                }
                if (!good) continue;
                //Console.WriteLine(i.ToString());
                ans += solve(a, b, i,n);
                ans %= MOD;
            }
            Console.WriteLine(ans.ToString());
        }
    }
}

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

namespace Codeforces_CS
{
    class Class1
    {
        static void Main(string[] args)
        {
            new Class1().run();
        }

        void run()
        {
            InputReader cin = new InputReader(Console.OpenStandardInput());
            int a = cin.int32();
            int b = cin.int32();
            int n = cin.int32();

            long MOD = ((long)1e9) + 7;
            __modFact = new long[n + 1];
            for (int i = 0; i <= n; i++) __modFact[i] = -1;
            for (int i = 0; i <= n; i += 1000) __modFact[i] = modFact(i, MOD);

            long ways = 0;
            for (int i = 0; i <= n; i++)
            {
                long sum = (i * 1L * a) + ((n - i) * 1L * b);
                if (isGood(sum, a, b))
                    ways += modComb(n, i, MOD);
                ways %= MOD;
            }

            Console.WriteLine(ways);
        }

        bool isGood(long x, int a, int b)
        {
            if (x == 0) return false;
            while (x > 0)
            {
                int r = (int)(x % 10L);
                if (r != a && r != b)
                    return false;
                x /= 10;
            }
            return true;
        }

        long modPow(long b, long e, long MOD)
        {
            if (e == 0) return 1;
            if (e == 1) return b % MOD;
            long temp = modPow(b, e / 2, MOD);
            temp = (temp * temp) % MOD;
            if (e % 2 == 1)
                temp = (temp * (b % MOD)) % MOD;
            return temp;
        }

        long modInv(long b, long MOD)
        {
            return modPow(b, MOD - 2, MOD);
        }

        long modComb(long n, long r, long MOD)
        {
            return (modFact(n, MOD) * modInv(modFact(n - r, MOD) * modFact(r, MOD), MOD)) % MOD;
        }

        long[] __modFact;

        long modFact(long n, long MOD)
        {
            if (n == 0) return 1;
            if (__modFact[n] != -1) return __modFact[n];
            return __modFact[n] = ((n % MOD) * (modFact(n - 1, MOD) % MOD)) % MOD;
        }
    }

    class InputReader
    {
        Stream inputStream;
        const int bufferSize = 1 << 16;
        int bytesRead;
        int currentBufferTop;
        byte[] buffer;

        public InputReader(Stream _inputStream)
        {
            this.inputStream = _inputStream;
            bytesRead = 0;
            currentBufferTop = 0;
            buffer = new byte[bufferSize];
        }

        public byte peekChar()
        {
            if (currentBufferTop < bytesRead)
            {
                return this.buffer[this.currentBufferTop];
            }
            else
            {
                if (!this.refill())
                {
                    throw new Exception("Error in reading input or reached EOF");
                }
                else
                {
                    return peekChar();
                }
            }
        }

        public byte readChar()
        {
            if (currentBufferTop < bytesRead)
            {
                return this.buffer[this.currentBufferTop++];
            }
            else
            {
                if (!this.refill())
                {
                    throw new Exception("Error in reading input or reached EOF");
                }
                else
                {
                    return readChar();
                }
            }
        }

        public bool refill()
        {
            currentBufferTop = 0;
            bytesRead = inputStream.Read(buffer, 0, bufferSize);
            return bytesRead > 0;
        }

        public int int32()
        {
            return (int) int64();
        }

        public long int64()
        {
            byte temp = peekChar();
            while (temp != '-' && (temp < '0' || temp > '9'))
            {
                readChar();
                temp = peekChar();
            }
            int sign = 1;
            if (temp == '-') sign = -1;
            if (temp == '-') readChar();
            long readValue = 0;
            temp = peekChar();
            while (temp >= '0' && temp <= '9')
            {
                readValue *= 10;
                readValue += (int)(temp - '0');
                readChar();
                try
                {
                    temp = peekChar();
                }
                catch (Exception e)
                {
                    break;
                }
            }
            return readValue * sign;
        }

        public string token()
        {
            byte temp = peekChar();
            while (isSpace(temp))
            {
                readChar();
                temp = peekChar();
            }

            StringBuilder sb = new StringBuilder();
            try
            {
                temp = peekChar();
                while (!isSpace(temp))
                {
                    readChar();
                    sb.Append((char)temp);
                    temp = peekChar();

                }
            }
            catch (Exception e) { }
            return sb.ToString();
        }

        public string line()
        {
            StringBuilder sb = new StringBuilder();
            try
            {
                byte temp;
                do
                {
                    temp = peekChar();
                    sb.Append(temp);
                    readChar();
                } while (temp != '\n');
            }
            catch (Exception e) { }
            return sb.ToString();
        }

        private bool isSpace(byte t)
        {
            if (t == ' ') return true;
            if (t == '\t') return true;
            if (t == '\r') return true;
            if (t == '\n') return true;
            if (t == '\f') return true;
            return false;
        }
    }
}

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

class Program
{
    static TextReader reader;
    static TextWriter writer;
    static Program()
    {
#if ONLINE_JUDGE
        reader = Console.In;
        writer = Console.Out;
#else
        reader = new StreamReader("input.txt");
        writer = new StreamWriter("output.txt");
#endif
    }
    static long gcd(long a, long b)
    {
        if (a < b)
        {
            long t = a;
            a = b;
            b = t;
        }
        return (b > 0) ? gcd(b, a % b) : a;
    }
    /*static BigInteger C(int k, int n)
    {
        BigInteger c = 1;
        if (k < n / 2)
            k = n - k;
        for (int i = k + 1; i <= n; ++i)
            c *= i;
        for (int i = 2; i <= n - k; ++i)
            c /= i;
        return c;
    }*/
    static void _235A()
    {
        long n = long.Parse(reader.ReadLine()), ans = n * (n - 1);
        if (n < 3)
            ans = n;
        else if (n % 2 == 1)
            ans *= n - 2;
        else
        {
            long t = (n - 2) / 2;
            for (long i = n - 3; i > (n - 2) / 2; --i)
            {
                long g = gcd(n, i);
                if (g == 1)
                    t = Math.Max(t, i);
            }
            ans *= t;
        }
        writer.Write(Math.Max(ans,(n-1)*(n-2)*(n-3)));
    }
    static void _106C()
    {
        string[] s = reader.ReadLine().Split();
        int n = int.Parse(s[0]), m = int.Parse(s[1]), c0 = int.Parse(s[2]), d0 = int.Parse(s[3]);
        int[] a = new int[m + 1], b = new int[m + 1], c = new int[m + 1], d = new int[m + 1];
        for (int i = 1; i <= m; ++i)
        {
            s = reader.ReadLine().Split();
            a[i] = int.Parse(s[0]);
            b[i] = int.Parse(s[1]);
            c[i] = int.Parse(s[2]);
            d[i] = int.Parse(s[3]);
        }
        int[] dp_d = new int[n + 1], dp_c = new int[n + 1];
        dp_d[0] = dp_c[0] = 0;
        int[,] dp_b = new int[n + 1, m + 1];
        for (int i = 1; i <= n; ++i)
        {
            if (c0 == i)
            {
                dp_d[i] = d0;
                dp_c[i] = i;
            }
            for (int j = 1; j <= m; ++j)
            {
                if (c[j] == i)
                {
                    if (dp_d[i] < d[j] && b[j] <= a[j])
                    {
                        dp_d[i] = d[j];
                        dp_c[i] = i;
                        dp_b[i, j] = b[j];
                    }
                    else if (dp_d[i] == d[j])
                    {
                        // ???
                    }
                }
            }
            // what about leftovers???
            for (int j = 1; j <= i / 2; ++j)
            {
                if (dp_d[j] + dp_d[i - j] > dp_d[i])
                {
                    bool ok = true;
                    for (int k = 1; k <= m && ok; ++k)
                    {
                        if (dp_b[j, k] + dp_b[i - j, k] > a[k])
                            ok = false;
                    }
                    if (ok)
                    {
                        dp_d[i] = dp_d[j] + dp_d[i - j];
                        dp_c[i] = dp_c[j] + dp_c[i - j];
                        for (int k = 1; k <= m; ++k)
                            dp_b[i,k] = dp_b[j, k] + dp_b[i - j, k];
                    }
                }
            }
            if (c0 <= i)
                if (d0 + dp_d[i - c0] > dp_d[i])
                {
                    dp_d[i] = d0 + dp_d[i - c0];
                    dp_c[i] = c0 + dp_c[i - c0];
                }
            if (dp_d[i] < dp_d[i - 1])
            {
                dp_d[i] = dp_d[i - 1];
                dp_c[i] = dp_c[i - 1];
                for (int j = 1; j <= m; ++j)
                    dp_b[i, j] = dp_b[i - 1, j];
            }
        }
        writer.Write(dp_d[n]);
    }
    static long pow(long a, long x, long mod)
    {
        long res = 1;
        while (x > 0)
        {
            if ((x & 1) != 0)
            {
                res = (res * a) % mod;
                --x;
            }
            else
            {
                a = (a * a) % mod;
                x >>= 1;
            }
        }
        return res;
    }
    static void _300C()
    {
        string[] s = reader.ReadLine().Split();
        long a = long.Parse(s[0]), b = long.Parse(s[1]), n = long.Parse(s[2]);
        if (a > b)
        {
            long t = a;
            a = b;
            b = t;
        }
        long[] fact = new long[n + 1];
        fact[0] = fact[1] = 1;
        long mod = 1000000007;
        for (long i = 2; i <= n; ++i)
            fact[i] = fact[i - 1] * i % mod;
        long an = n, bn = 0;
        long ans = 0;
        while (an > 0)
        {
            long num = an * a + bn * b;
            bool ok = true;
            for (long p = 10; ok && p <= 10000000; p *= 10)
            {
                long t = num % p / (p / 10);
                if (t != a && t != b && (t != 0 || p <= num))
                    ok = false;
            }
            if (ok)
            {
                long c = (((fact[n] * pow(fact[an], mod - 2, mod)) % mod) * pow(fact[bn], mod - 2, mod)) % mod;
                ans += c;
                ans %= mod;
            }
            --an;
            ++bn;
        }
        writer.Write(ans);
    }
    static void Main(string[] args)
    {
        //_235A();
        //_106C();
        _300C();
        reader.Close();
        writer.Close();
    }
}

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

namespace Codeforces_CS
{
    class Class1
    {
        static void Main(string[] args)
        {
            new Class1().run();
        }

        void run()
        {
            InputReader cin = new InputReader(Console.OpenStandardInput());
            int a = cin.int32();
            int b = cin.int32();
            int n = cin.int32();

            long MOD = ((long)1e9) + 7;
            __modFact = new long[n + 1];
            for (int i = 0; i <= n; i++) __modFact[i] = -1;
            for (int i = 0; i <= n; i += 1000) __modFact[i] = modFact(i, MOD);

            long ways = 0;
            for (int i = 0; i <= n; i++)
            {
                long sum = (i * 1L * a) + ((n - i) * 1L * b);
                if (isGood(sum, a, b))
                    ways += modComb(n, i, MOD);
            }

            Console.WriteLine(ways);
        }

        bool isGood(long x, int a, int b)
        {
            if (x == 0) return false;
            while (x > 0)
            {
                int r = (int)(x % 10L);
                if (r != a && r != b)
                    return false;
                x /= 10;
            }
            return true;
        }

        long modPow(long b, long e, long MOD)
        {
            if (e == 0) return 1;
            if (e == 1) return b % MOD;
            long temp = modPow(b, e / 2, MOD);
            temp = (temp * temp) % MOD;
            if (e % 2 == 1)
                temp = (temp * (b % MOD)) % MOD;
            return temp;
        }

        long modInv(long b, long MOD)
        {
            return modPow(b, MOD - 2, MOD);
        }

        long modComb(long n, long r, long MOD)
        {
            return (modFact(n, MOD) * modInv(modFact(n - r, MOD) * modFact(r, MOD), MOD)) % MOD;
        }

        long[] __modFact;

        long modFact(long n, long MOD)
        {
            if (n == 0) return 1;
            if (__modFact[n] != -1) return __modFact[n];
            return __modFact[n] = ((n % MOD) * (modFact(n - 1, MOD) % MOD)) % MOD;
        }
    }

    class InputReader
    {
        Stream inputStream;
        const int bufferSize = 1 << 16;
        int bytesRead;
        int currentBufferTop;
        byte[] buffer;

        public InputReader(Stream _inputStream)
        {
            this.inputStream = _inputStream;
            bytesRead = 0;
            currentBufferTop = 0;
            buffer = new byte[bufferSize];
        }

        public byte peekChar()
        {
            if (currentBufferTop < bytesRead)
            {
                return this.buffer[this.currentBufferTop];
            }
            else
            {
                if (!this.refill())
                {
                    throw new Exception("Error in reading input or reached EOF");
                }
                else
                {
                    return peekChar();
                }
            }
        }

        public byte readChar()
        {
            if (currentBufferTop < bytesRead)
            {
                return this.buffer[this.currentBufferTop++];
            }
            else
            {
                if (!this.refill())
                {
                    throw new Exception("Error in reading input or reached EOF");
                }
                else
                {
                    return readChar();
                }
            }
        }

        public bool refill()
        {
            currentBufferTop = 0;
            bytesRead = inputStream.Read(buffer, 0, bufferSize);
            return bytesRead > 0;
        }

        public int int32()
        {
            return (int) int64();
        }

        public long int64()
        {
            byte temp = peekChar();
            while (temp != '-' && (temp < '0' || temp > '9'))
            {
                readChar();
                temp = peekChar();
            }
            int sign = 1;
            if (temp == '-') sign = -1;
            if (temp == '-') readChar();
            long readValue = 0;
            temp = peekChar();
            while (temp >= '0' && temp <= '9')
            {
                readValue *= 10;
                readValue += (int)(temp - '0');
                readChar();
                try
                {
                    temp = peekChar();
                }
                catch (Exception e)
                {
                    break;
                }
            }
            return readValue * sign;
        }

        public string token()
        {
            byte temp = peekChar();
            while (isSpace(temp))
            {
                readChar();
                temp = peekChar();
            }

            StringBuilder sb = new StringBuilder();
            try
            {
                temp = peekChar();
                while (!isSpace(temp))
                {
                    readChar();
                    sb.Append((char)temp);
                    temp = peekChar();

                }
            }
            catch (Exception e) { }
            return sb.ToString();
        }

        public string line()
        {
            StringBuilder sb = new StringBuilder();
            try
            {
                byte temp;
                do
                {
                    temp = peekChar();
                    sb.Append(temp);
                    readChar();
                } while (temp != '\n');
            }
            catch (Exception e) { }
            return sb.ToString();
        }

        private bool isSpace(byte t)
        {
            if (t == ' ') return true;
            if (t == '\t') return true;
            if (t == '\r') return true;
            if (t == '\n') return true;
            if (t == '\f') return true;
            return false;
        }
    }
}