#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.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.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;

            for (int i = 0; i <= n; ++i)
            {
                var sum = a * (n - i) + b * i;
                if (IsGood(a, b, sum))
                {
                    res = (res + Combination(n, 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 IsExcellent(int a, int b, int n)
        {
            return IsGood(a, b, n) && IsGood(a, b, SumDigits(n));
        }

        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;
        }

        public static int Pow10(int n)
        {
            var res = 1;
            for (int i = 0; i < n; ++i)
            {
                res *= 10;
            }
            return res;
        }
    }
}


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 void _300C()
    {
        string[] s = reader.ReadLine().Split();
        int a = int.Parse(s[0]), b = int.Parse(s[1]), n = int.Parse(s[2]);
        if (a > b)
        {
            int t = a;
            a = b;
            b = t;
        }
        int an = n, bn = 0;
        BigInteger ans = 0;
        while (an > 0)
        {
            int num = an * a + bn * b;
            bool ok = true;
            for (int p = 10; ok && p <= 10000000; p *= 10)
            {
                int t = num % p / (p / 10);
                if (t != a && t != b && (t != 0 || p <= num))
                    ok = false;
            }
            if (ok)
            {
                BigInteger c = C(an, n);
                ans += c;
            }
            --an;
            ++bn;
        }
        ans %= 1000000007;
        writer.Write(ans);
    }
    static void Main(string[] args)
    {
        //_235A();
        //_106C();
        _300C();
        reader.Close();
        writer.Close();
    }
}


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

namespace Pizza_Separation
{
    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 int Solve(string[] args)
        {
            int n = Next();

            var nn = new int[n];
            for (int i = 0; i < n; i++)
            {
                nn[i] = Next();
            }
            int ans = 360;

            for (int i = 0; i < n; i++)
            {
                int sum = 0;
                for (int j = i; j < n; j++)
                {
                    sum += nn[j];
                    ans = Math.Min(ans, Math.Abs(360 - 2*sum));
                }
            }

            return ans;
        }

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

namespace Codeforces.NET
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            int n = int.Parse(line);
            int[] angles = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int min = int.MaxValue;

            for (int i = 0; i < angles.Length; i++)
            {
                for (int j = i; j < angles.Length; j++)
                {
                    int sum1 = 0;
                    for (int k = i; k<=j; k++)
                    {
                        sum1 += angles[k];
                    }

                    int sum2 = 0;
                    for (int k = 0; k < i; k++)
                    {
                        sum2 += angles[k];
                    }

                    for (int k = j+1; k < angles.Length; k++)
                    {
                        sum2 += angles[k];
                    }

                    min = Math.Min(min, Math.Abs(sum1 - sum2));
                }
            }

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


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

class Program
{
	static void Main()
	{
		Console.ReadLine();
		int[] a = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(), sum = new int[a.Length];
		int ans = int.MaxValue;
		sum[0] = a[0];
		for (int i = 1; i < a.Length; i++)
			sum[i] = sum[i - 1] + a[i];
		for (int i = 0; i < a.Length; i++)
			for (int j = i; j < a.Length; j++)
				ans = Math.Min(ans, Math.Abs(sum[a.Length - 1] - 2 * (sum[j] - sum[i])));
		Console.WriteLine(ans);
		Console.ReadLine();
	}
}


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

namespace ConsoleApplication1
{

    class Program
    {

        static TextReader sr;
        static TextWriter sw;
        static Random rnd = new Random();

        enum Direction { Vertical, Horizontal }

        static void Main(string[] args)
        {
            if (File.Exists("input.txt"))
            {
                sr = new StreamReader("input.txt");
                sw = new StreamWriter("output.txt");
            }
            else
            {
                sr = Console.In;
                sw = Console.Out;
            }
            Solve();
            if (File.Exists("input.txt"))
            {
                sr.Close();
                sw.Close();
            }
        }

        static void Solve()
        {
            int max = 360;
            int n = ReadInt();
            var a = ReadArrayInt();
            int answer = 360;
            for (int i = 0; i < n; i++)
            {
                for (int j = i + 1; j < n; j++)
                {
                    int sum = 0;
                    for (int k = i; k < j; k++)
                    {
                        sum += a[k];
                    }
                    answer = Math.Min(answer, Math.Abs(sum * 2 - 360));
                }
            }
            sw.WriteLine(answer);
        }

        static long getManhattan(Pair<long, long> a, Pair<long, long> b)
        {
            return Math.Abs(a.first - b.first) + Math.Abs(a.second - b.second);
        }

        static string[] buffer = new string[0];
        static int counterbuffer = 0;

        static Graph ReadGraph()
        {
            int n = ReadInt();
            int m = ReadInt();
            int[] a = new int[m];
            int[] b = new int[m];
            for (int i = 0; i < m; i++)
            {
                a[i] = ReadInt();
                b[i] = ReadInt();
            }
            return new Graph(n, a, b);
        }

        static Graph<T> ReadGraph<T>(Parser<T> parser)
            where T : IComparable<T>
        {
            int n = ReadInt();
            int m = ReadInt();
            int[] a = new int[m];
            int[] b = new int[m];
            T[] c = new T[m];
            for (int i = 0; i < m; i++)
            {
                a[i] = ReadInt();
                b[i] = ReadInt();
                c[i] = Read<T>(sr, parser);
            }
            return new Graph<T>(n, a, b, c);
        }

        static int[] ReadArrayInt()
        {
            return sr.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        static long[] ReadArrayLong()
        {
            return sr.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        static int[][] ReadMatrixInt(int n, int m)
        {
            int[][] answer = new int[n][];
            for (int i = 0; i < n; i++)
            {
                answer[i] = new int[m];
                for (int j = 0; j < m; j++)
                {
                    answer[i][j] = ReadInt();
                }
            }
            return answer;
        }

        static long[][] ReadMatrixLong(int n, int m)
        {
            long[][] answer = new long[n][];
            for (int i = 0; i < n; i++)
            {
                answer[i] = new long[m];
                for (int j = 0; j < m; j++)
                {
                    answer[i][j] = ReadLong();
                }
            }
            return answer;
        }

        static BigInteger ReadBigInteger()
        {
            return ReadBigInteger(sr);
        }

        static BigInteger ReadBigInteger(TextReader sr)
        {
            return Read<BigInteger>(sr, BigInteger.Parse);
        }

        static int ReadInt()
        {
            return ReadInt(sr);
        }

        static int ReadInt(TextReader sr)
        {
            return Read<int>(sr, int.Parse);
        }

        static long ReadLong()
        {
            return ReadLong(sr);
        }

        static long ReadLong(TextReader sr)
        {
            return Read<long>(sr, long.Parse);
        }

        static double ReadDouble()
        {
            return ReadDouble(sr);
        }

        static double ReadDouble(TextReader sr)
        {
            return Read<double>(sr, double.Parse);
        }

        static string ReadString()
        {
            return ReadString(sr);
        }

        static string ReadString(TextReader sr)
        {
            return Read<string>(sr, x => x);
        }

        static U Read<U>(TextReader sr, Parser<U> parser)
        {
            if (counterbuffer >= buffer.Length)
            {
                buffer = sr.ReadLine().Split(' ').ToArray();
                while (buffer.Length == 0)
                {
                    buffer = sr.ReadLine().Split(' ').ToArray();
                }
                counterbuffer = 0;
            }
            return parser(buffer[counterbuffer++]);
        }
    }

    public delegate U Parser<U>(string str);

    class Graph
    {
        protected int[][] Edges;
        public int this[int val1, int val2]
        {
            get
            {
                return Edges[val1][val2];
            }
            set
            {
                Edges[val1][val2] = value;
            }
        }

        public Graph(int n, int[] a, int[] b)
        {
            generateEdges(n, a, b);
        }

        private void generateEdges(int n, int[] a, int[] b)
        {
            int[] temp = new int[n];
            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] != b[i])
                {
                    temp[a[i] - 1]++;
                    temp[b[i] - 1]++;
                }
                else
                {
                    temp[a[i] - 1]++;
                }
            }
            Edges = new int[n][];
            for (int i = 0; i < n; i++)
            {
                Edges[i] = new int[temp[i]];
            }
            for (int i = 0; i < n; i++)
            {
                temp[i] = 0;
            }
            for (int j = 0; j < a.Length; j++)
            {
                if (a[j] != b[j])
                {
                    Edges[a[j] - 1][temp[a[j] - 1]++] = b[j] - 1;
                    Edges[b[j] - 1][temp[b[j] - 1]++] = a[j] - 1;
                }
                else
                {
                    Edges[a[j] - 1][temp[a[j] - 1]++] = b[j] - 1;
                }
            }
        }

        public override string ToString()
        {
            string answer = "";
            foreach (var i in Edges)
            {
                foreach (var j in i)
                {
                    answer += (j + 1) + " ";
                }
                answer += Environment.NewLine;
            }
            return answer;
        }
    }

    class Graph<T> : Graph
        where T : IComparable<T>
    {
        public T[][] Cost;
        public Graph(int n, int[] a, int[] b, T[] c) : base(n, a, b)
        {
            this.GenerateEdges(n, a, b, c);
        }

        private void GenerateEdges(int n, int[] a, int[] b, T[] c)
        {
            Cost = new T[n][];
            for (int i = 0; i < n; i++)
            {
                Cost[i] = new T[Edges[i].Length];
            }
            int[] temp = new int[n];

            for (int j = 0; j < c.Length; j++)
            {
                if (a[j] != b[j])
                {
                    Cost[a[j] - 1][temp[a[j] - 1]++] = c[j];
                    Cost[b[j] - 1][temp[b[j] - 1]++] = c[j];
                }
                else
                {
                    Cost[a[j] - 1][temp[a[j] - 1]++] = c[j];
                }
            }
        }

        public override string ToString()
        {
            string answer = "";
            for (int i = 0; i < Cost.Length; i++)
            {
                for (int j = 0; j < Cost[i].Length; j++)
                {
                    answer += (i + 1) + " " + (Edges[i][j] + 1) + " " + Cost[i][j] + Environment.NewLine;
                }
            }
            return answer;
        }
    }

    class SimplePair<U, V>
    {
        public U first;
        public V second;
        public SimplePair(U first, V second)
        {
            this.first = first;
            this.second = second;
        }

    }

    class Pair<U, V> : IComparable<Pair<U, V>>
        where U : IComparable<U>
        where V : IComparable<V>
    {
        public U first;
        public V second;
        public Pair(U first, V second)
        {
            this.first = first;
            this.second = second;
        }

        public int CompareTo(Pair<U, V> b)
        {
            if (first.CompareTo(b.first) == 0)
            {
                return second.CompareTo(b.second);
            }
            return first.CompareTo(b.first);
        }
    }

    class SuperList<T>
    {
        protected LinkedList<T> linkedListMain;
        protected LinkedList<SimplePair<int, LinkedListNode<T>>> linkedListAdditional;
        int step = 0;
        public int resize = 0;

        public SuperList(IEnumerable<T> input)
        {
            Init(input);
        }

        public int Count { get { return linkedListMain.Count; } }

        public T this[int index]
        {
            get
            {
                return GetNode(index).Value;
            }
            set
            {
                GetNode(index).Value = value;
            }
        }

        public void AddValueToIndex(int index, T value)
        {
            if (index > linkedListMain.Count || index < 0)
            {
                throw new IndexOutOfRangeException();
            }
            if (index == linkedListMain.Count)
            {
                linkedListMain.AddLast(value);
                linkedListAdditional.Last.Value.second = linkedListMain.Last;
                linkedListAdditional.Last.Value.first = linkedListMain.Count - 1;
                IncreaseReferenceIndexes(index + 1);
                return;
            }
            if (index == 0)
            {
                linkedListMain.AddFirst(value);
                linkedListAdditional.First.Value.second = linkedListMain.First;
                IncreaseReferenceIndexes(1);
                return;
            }
            linkedListMain.AddBefore(GetNode(index), value);
            IncreaseReferenceIndexes(index);
        }

        private LinkedListNode<T> GetNode(int index)
        {
            var NowNode = linkedListAdditional.First;
            while (NowNode != linkedListAdditional.Last
                && NowNode.Value.first < index)
            {
                NowNode = NowNode.Next;
            }
            var NodeAnswer = NowNode.Value.second;
            int i = NowNode.Value.first;
            while (i > index)
            {
                i--;
                NodeAnswer = NodeAnswer.Previous;
            }
            while (i < index)
            {
                i++;
                NodeAnswer = NodeAnswer.Next;
            }
            return NodeAnswer;
        }

        private void Init(IEnumerable<T> input)
        {
            linkedListMain = new LinkedList<T>();
            foreach (T iter in input)
            {
                linkedListMain.AddLast(iter);
            }
            InitReferences();
        }

        private void InitReferences()
        {
            resize++;
            linkedListAdditional = new LinkedList<SimplePair<int, LinkedListNode<T>>>();
            step = Math.Max(1, (int)Math.Sqrt(linkedListMain.Count));
            int now = step;
            LinkedListNode<T> NowNode = null;
            for (int i = 0; i < linkedListMain.Count; i++)
            {
                if (NowNode == null)
                    NowNode = linkedListMain.First;
                else
                    NowNode = NowNode.Next;
                if (now == step)
                {
                    now = 0;
                    linkedListAdditional.AddLast(new SimplePair<int, LinkedListNode<T>>(i, NowNode));
                }
                else
                {
                    now++;
                }
            }
            if (linkedListMain.Last != linkedListAdditional.Last.Value.second)
            {
                linkedListAdditional.AddLast(new SimplePair<int, LinkedListNode<T>>
                    (linkedListMain.Count - 1, linkedListMain.Last));
            }
        }

        private void IncreaseReferenceIndexes(int BeginIndex)
        {
            if (linkedListMain.Count == 2)
            {
                InitReferences();
                return;
            }
            LinkedListNode<SimplePair<int, LinkedListNode<T>>> NowNode = null;
            int maxstep = 0;
            for (int i = 0; i < linkedListAdditional.Count; i++)
            {
                if (NowNode == null)
                {
                    NowNode = linkedListAdditional.First;
                }
                else
                {
                    NowNode = NowNode.Next;
                }
                if (NowNode.Value.first >= BeginIndex)
                {
                    NowNode.Value.first++;
                }
                if (NowNode.Previous != null)
                {
                    maxstep = Math.Max(maxstep, NowNode.Value.first - NowNode.Previous.Value.first);
                }
            }
            if (maxstep > step * 2)
            {
                InitReferences();
            }
        }

        public override string ToString()
        {
            return String.Join(" ", linkedListMain);
        }
    }
}


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

namespace Codeforces
{
   class B
   {
     static int n = 0;
     static int[] a;
      static void Main(string[] args)
      {
         n = int.Parse(Console.ReadLine());
         a = new int[n];
         string[] token = Console.ReadLine().Split();
         for(int i=0;i<n;i++){
           a[i] = int.Parse(token[i]);
         }
         int ans = 1000;
         for(int i=0;i<n;i++){
           ans = Math.Min(ans,Sum(i));
         }
        Console.WriteLine(ans);
      }
      static int Sum(int j){
        int A=0,B = 0;
        for (int i = 0; i < n; i++)
        {
          if(a[(i+j)%n]<180-A){
            A += a[(i+j)%n];
          }else{
            B = A + a[(i+j)%n];
            break;
          }
        }
        return Math.Min(180-A,B-180)*2;
      }

   }

}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Text;

namespace Codeforces
{
    class Program : IDisposable
    {
        private static readonly TextReader textReader = new StreamReader(Console.OpenStandardInput());
        private static readonly TextWriter textWriter = new StreamWriter(Console.OpenStandardOutput());

        private void Solve()
        {
            var n = int.Parse(Console.ReadLine());
           var arr = Console.ReadLine().Split(' ').Select(int.Parse).ToList();

            if (n == 1)
            {
                Console.WriteLine(360);
                return;
            }
            var min = 360;
            for (int i = 0; i < n; i++)
            {
                var diff = Math.Abs(arr[i] - (360 - arr[i]));
                min = Math.Min(min, diff);
                var sum = arr[i];
                for (int j = i+1; j < n; j++)
                {
                    sum += arr[j];
                    var val = Math.Abs(sum - (360 - sum));
                    if (val < diff)
                    {
                        diff = val;
                        min = Math.Min(min, diff);
                    }
                    else
                    {
                        break;
                    }
                }
            }
            Console.WriteLine(min);
        }

        int BinarySearch(int[] arr, int q)
        {
            var l = 0;
            var r = arr.Length - 1;
            //int med = -1;
            while (l <= r)
            {
                var med = l + (r - l) / 2;
                if (arr[med] == q)
                {
                    return med;
                }
                if (q < arr[med])
                {
                    r = med - 1;
                }
                else
                {
                    l = med + 1;
                }
            }
            return -1;
        }

        static void Main(string[] args)
        {
            var p = new Program();
            p.Solve();
            //Console.ReadLine();
            //p.Dispose();
            //////////////////////////////
        }

        #region Helpers

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

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

        private static int[] ReadIntArray()
        {
            return textReader.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        #endregion

        public void Dispose()
        {
            textReader.Close();
            textWriter.Close();
        }
    }
}


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

namespace CF
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            using (var sr = new InputReader(Console.In))
//			using (var sr = new InputReader(new StreamReader("input.txt")))
            using (var sw = Console.Out)
                //using (var sw = new StreamWriter("output.txt"))
            using (var task = new Task(sr, sw)) {
                task.Solve();
//                Console.ReadKey();
            }
        }
    }

    internal class Task : IDisposable
    {
        private readonly InputReader sr;
        private readonly TextWriter sw;
        private bool isDispose;

        public Task(InputReader sr, TextWriter sw)
        {
            this.sr = sr;
            this.sw = sw;
        }

        public void Solve()
        {
            var n = sr.NextInt32();
            var sectors = sr.ReadArrayOfInt32();
            var minD = 360;
            for (var i = 0; i < sectors.Length; i++) {
                for (var len = 0; len < sectors.Length; len++) {
                    var sum = 0;
                    for (var j = i; j < i + len; j++) {
                        sum += sectors[j % sectors.Length];
                    }
                    var other = 360 - sum;
                    var currD = Math.Abs(sum - other);
                    minD = Math.Min(currD, minD);
                }
            }

            sw.WriteLine(minD);

        }

        ~Task()
        {
            Dispose(false);
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        private void Dispose(bool disposing)
        {
            if (!isDispose) {
                if (disposing) {
                    if(sr != null)
                        sr.Dispose();

                    if(sw != null)
                        sw.Dispose();
                }

                isDispose = true;
            }
        }
    }
}

internal class InputReader : IDisposable
{
    private bool isDispose;
    private readonly TextReader sr;
    private string[] buffer;
    private int seek;

    public InputReader(TextReader stream)
    {
        sr = stream;
    }

    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    public string NextString()
    {
        var result = sr.ReadLine();
        return result;
    }

    public int NextInt32()
    {
        return Int32.Parse(ReadNextToken());
    }

    private string ReadNextToken()
    {
        if (buffer == null || seek == buffer.Length) {
            seek = 0;
            buffer = NextSplitStrings();
        }

        return buffer[seek++];
    }

    public long NextInt64()
    {
        return Int64.Parse(ReadNextToken());
    }

    public int[] ReadArrayOfInt32()
    {
        return ReadArray(Int32.Parse);
    }

    public long[] ReadArrayOfInt64()
    {
        return ReadArray(Int64.Parse);
    }

    public string[] NextSplitStrings()
    {
        return NextString()
            .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
    {
        return NextSplitStrings()
            .Select(s => func(s, CultureInfo.InvariantCulture))
            .ToArray();
    }

    public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
    {
        return
            str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(s => func(s, CultureInfo.InvariantCulture))
                .ToArray();
    }

    protected void Dispose(bool dispose)
    {
        if (!isDispose)
        {
            if (dispose)
                sr.Close();

            isDispose = true;
        }
    }

    ~InputReader()
    {
        Dispose(false);
    }
}


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

class Program
{
    static long Max(long a, long b, long c)
    {
        return Math.Max(a, Math.Max(b, c));
    }

    static long Min(long a, long b, long c)
    {
        return Math.Min(a, Math.Min(b, c));
    }

    static int gcd(int a, int b)
    {
        if (b == 0)
            return a;

        return gcd(b, a % b);
    }

    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        var sum = a.Sum();

        var min = int.MaxValue;

        for (int i = 0; i < n; i++)
        {
            for (int j = i; j < n; j++)
            {
                var tmp = 0;
                for (int x = i; x <= j; x++)
                {
                    tmp += a[x];
                }

                var tmp2 = sum - tmp;
                var raz = Math.Abs(tmp2 - tmp);

                if (raz < min) { min = raz; }
            }
        }

        Console.WriteLine(min);
    }
}


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

public class Program
{

    public static void Main()
    {
        Console.ReadLine();
        int[] a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        int minCondSum = int.MaxValue;
        for (var i = 0; i < a.Length; ++i)
        {
            int sum = 0;
            for (var j = i; j < a.Length; ++j)
            {
                sum += a[j];
                if (Math.Abs(2*sum - 360) < minCondSum)
                    minCondSum = Math.Abs(2*sum - 360);
            }
        }

        Console.WriteLine(minCondSum);
    }
}


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

namespace _895A
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var sp = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int[] A = new int[N];
            for (var i = 0; i < N; ++i)
                A[i] = int.Parse(sp[i]);
            int sum = 360;
            for(int j = 0; j < N; ++j)
                for(int i = 1; i < N - j; ++i)
                {
                    int idx1 = 0;
                    int sum1 = 0;
                    while (idx1 < i)
                        sum1 += A[(idx1++ + j) % N];
                    idx1 = 0;
                    while(idx1 < N - i)
                        sum1 -= A[(idx1++ + j + i) % N];
                    sum = (sum > Math.Abs(sum1)) ? Math.Abs(sum1) : sum;
                }
            Console.WriteLine(sum);
        }
    }
}


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

 class Solution {
 	static void Main()
 	{
 		var n = Convert.ToInt16(Console.ReadLine());
		var mas = Console.ReadLine().Split(' ').Select(p => Convert.ToInt32(p)).ToList();
		 mas.AddRange(mas);
		 var x = 0;
		 var l = 0;
		 var res = 180;
		 foreach (var i in mas)
		 {
			 x += i;
			 res = Math.Min(res, Math.Abs(180 - x));
			 if (x > 180)
			 {
				 x -= mas[l];
				 l++;
				 res = Math.Min(res, Math.Abs(180 - x));
			 }
		 }
		 Console.WriteLine(2*res);
	 }
 }


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

namespace Codeforces
{
   class B
   {
     static int n = 0;
     static int[] a;
      static void Main(string[] args)
      {
         n = int.Parse(Console.ReadLine());
         a = new int[n];
         string[] token = Console.ReadLine().Split();
         for(int i=0;i<n;i++){
           a[i] = int.Parse(token[i]);
         }

        Console.WriteLine(Math.Min(Sum(0),Sum(1)));
      }
      static int Sum(int j){
        int A=0,B = 0;
        for (int i = 0; i < n; i++)
        {
          if(a[(i+j)%n]<180-A){
            A += a[(i+j)%n];
          }else{
            B = A + a[(i+j)%n];
            break;
          }
        }
        return Math.Min(180-A,B-180)*2;
      }

   }

}


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

 class Solution {
 	static void Main()
 	{
 		var n = Convert.ToInt16(Console.ReadLine());
		var mas = Console.ReadLine().Split(' ').Select(p => Convert.ToInt32(p)).ToArray();
		 var x = 0;
		 var l = 0;
		 var res = 180;
		 foreach (var i in mas)
		 {
			 x += i;
			 res = Math.Min(res, Math.Abs(180 - x));
			 if (x > 180)
			 {
				 x -= mas[l];
				 l++;
				 res = Math.Min(res, Math.Abs(180 - x));
			 }
		 }
		 Console.WriteLine(2*res);
	 }
 }


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

namespace CF
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            using (var sr = new InputReader(Console.In))
//			using (var sr = new InputReader(new StreamReader("input.txt")))
            using (var sw = Console.Out)
                //using (var sw = new StreamWriter("output.txt"))
            using (var task = new Task(sr, sw)) {
                task.Solve();
//                Console.ReadKey();
            }
        }
    }

    internal class Task : IDisposable
    {
        private readonly InputReader sr;
        private readonly TextWriter sw;
        private bool isDispose;

        public Task(InputReader sr, TextWriter sw)
        {
            this.sr = sr;
            this.sw = sw;
        }

        public void Solve()
        {
            var n = sr.NextInt32();
            var sectors = sr.ReadArrayOfInt32();
            const int max = 361;
            var dp = new bool[max, max];
            dp[0, 0] = true;
            for (var i = 1; i <= sectors.Length; i++) {
                for (var k = 0; k < max; k++) {
                    if (k < sectors[i - 1]) {
                        dp[i, k] = dp[i - 1, k];
                    }
                    else {
                        dp[i, k] = dp[i - 1, k - sectors[i - 1]];
                    }
                }
            }
            var minD = 360;
            for (var i = 1; i <= sectors.Length; i++) {
                for (var k = 0; k < max; k++) {
                    if (dp[i, k]) {
                        var other = 360 - k;
                        var currD = Math.Abs(other - k);
                        minD = Math.Min(minD, currD);
                    }
                }
            }

            sw.WriteLine(minD);
        }

        ~Task()
        {
            Dispose(false);
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        private void Dispose(bool disposing)
        {
            if (!isDispose) {
                if (disposing) {
                    if(sr != null)
                        sr.Dispose();

                    if(sw != null)
                        sw.Dispose();
                }

                isDispose = true;
            }
        }
    }
}

internal class InputReader : IDisposable
{
    private bool isDispose;
    private readonly TextReader sr;
    private string[] buffer;
    private int seek;

    public InputReader(TextReader stream)
    {
        sr = stream;
    }

    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    public string NextString()
    {
        var result = sr.ReadLine();
        return result;
    }

    public int NextInt32()
    {
        return Int32.Parse(ReadNextToken());
    }

    private string ReadNextToken()
    {
        if (buffer == null || seek == buffer.Length) {
            seek = 0;
            buffer = NextSplitStrings();
        }

        return buffer[seek++];
    }

    public long NextInt64()
    {
        return Int64.Parse(ReadNextToken());
    }

    public int[] ReadArrayOfInt32()
    {
        return ReadArray(Int32.Parse);
    }

    public long[] ReadArrayOfInt64()
    {
        return ReadArray(Int64.Parse);
    }

    public string[] NextSplitStrings()
    {
        return NextString()
            .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
    {
        return NextSplitStrings()
            .Select(s => func(s, CultureInfo.InvariantCulture))
            .ToArray();
    }

    public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
    {
        return
            str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(s => func(s, CultureInfo.InvariantCulture))
                .ToArray();
    }

    protected void Dispose(bool dispose)
    {
        if (!isDispose)
        {
            if (dispose)
                sr.Close();

            isDispose = true;
        }
    }

    ~InputReader()
    {
        Dispose(false);
    }
}


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

class Scanner
{
    private readonly char Separator = ' ';
    private int Index = 0;
    private string[] Line = new string[0];
    public string Next()
    {
        if (Index >= Line.Length)
        {
            Line = Console.ReadLine().Split(Separator);
            Index = 0;
        }
        var ret = Line[Index];
        Index++;
        return ret;
    }

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

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

    public string[] StringArray()
    {
        Line = Console.ReadLine().Split(Separator);
        Index = Line.Length;
        return Line;
    }

    public int[] IntArray()
    {
        var l = StringArray();
        var res = new int[l.Length];
        for (int i = 0; i < l.Length; i++)
        {
            res[i] = int.Parse(l[i]);
        }
        return res;
    }

    public long[] LongArray()
    {
        var l = StringArray();
        var res = new long[l.Length];
        for (int i = 0; i < l.Length; i++)
        {
            res[i] = long.Parse(l[i]);
        }
        return res;
    }
}
class Program
{
    private int N;
    private int[] A;
    private void Scan()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        A = sc.IntArray();
    }

    public void Solve()
    {
        Scan();
        bool[] B = new bool[361];
        B[0] = true;
        for (int i = 0; i < N; i++)
        {
            var next = new bool[361];
            for (int j = 0; j <= 360; j++)
            {
                if (B[j])
                {
                    var a = Math.Abs(j + A[i]);
                    var b = Math.Abs(j - A[i]);
                    if (a <= 360)
                        next[a] = true;
                    if (b < 360)
                        next[b] = true;
                }
            }
            B = next;
        }
        for (int i = 0; i <= 360; i++)
        {
            if (B[i])
            {
                Console.WriteLine(i);
                return;
            }
        }
    }

    static void Main(string[] args)
    {
        new Program().Solve();
    }
}


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

 class Solution {
 	static void Main()
 	{
 		var n = Convert.ToInt16(Console.ReadLine());
		var mas = Console.ReadLine().Split(' ').Select(p => Convert.ToInt32(p)).ToList();
		 mas.AddRange(mas);

		 var x = 0;
		 var l = 0;
		 var res = 180;
		 foreach (var i in mas)
		 {
			 x += i;
			 res = Math.Min(res, Math.Abs(180 - x));
			 if (x >= 180)
			 {
				 x -= mas[l];
				 l++;
				 res = Math.Min(res, Math.Abs(180 - x));
			 }
		 }
		 Console.WriteLine(2*res);
	 }
 }


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

class Scanner
{
    private readonly char Separator = ' ';
    private int Index = 0;
    private string[] Line = new string[0];
    public string Next()
    {
        if (Index >= Line.Length)
        {
            Line = Console.ReadLine().Split(Separator);
            Index = 0;
        }
        var ret = Line[Index];
        Index++;
        return ret;
    }

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

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

    public string[] StringArray()
    {
        Line = Console.ReadLine().Split(Separator);
        Index = Line.Length;
        return Line;
    }

    public int[] IntArray()
    {
        var l = StringArray();
        var res = new int[l.Length];
        for (int i = 0; i < l.Length; i++)
        {
            res[i] = int.Parse(l[i]);
        }
        return res;
    }

    public long[] LongArray()
    {
        var l = StringArray();
        var res = new long[l.Length];
        for (int i = 0; i < l.Length; i++)
        {
            res[i] = long.Parse(l[i]);
        }
        return res;
    }
}
class Program
{
    private int N;
    private int[] A;
    private void Scan()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        A = sc.IntArray();
    }

    public void Solve()
    {
        Scan();
        var ans = new HashSet<int>() { 0 };
        for (int i = 0; i < N; i++)
        {
            var next = new HashSet<int>();
            foreach (int j in ans)
            {
                next.Add(j + A[i]);
                next.Add(j - A[i]);
            }
            ans = next;
        }
        int anser = int.MaxValue;
        foreach (int i in ans)
        {
            anser = Math.Min(anser, Math.Abs(i));
        }
        Console.WriteLine(anser);
    }

    static void Main(string[] args)
    {
        new Program().Solve();
    }
}


using System;

namespace consap1
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            String[] inp = Console.ReadLine().Split();
            long Ax = long.Parse(inp[0]), Ay = long.Parse(inp[1]),
            Bx = long.Parse(inp[2]), By = long.Parse(inp[3]),
            Cx = long.Parse(inp[4]), Cy = long.Parse(inp[5]);
            if ((Ax - Bx)*(Ax - Bx) + (Ay - By)*(Ay - By) == (Cx - Bx) * (Cx - Bx) + (Cy - By) * (Cy - By) && !( Bx - Ax == Cx - Bx && By - Ay == Cy - By)) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}


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

namespace ConsoleApplication1.CodeForces
{
    public class LowerBoundSortedSet<T> : SortedSet<T>
    {

        private ComparerDecorator<T> _comparerDecorator;

        private class ComparerDecorator<T> : IComparer<T>
        {

            private IComparer<T> _comparer;

            public T LowerBound { get; private set; }
            public T UpperBound { get; private set; }

            private bool _reset = true;

            public void Reset()
            {
                _reset = true;
            }

            public ComparerDecorator(IComparer<T> comparer)
            {
                _comparer = comparer;
            }

            public int Compare(T x, T y)
            {
                int num = _comparer.Compare(x, y);
                if (_reset)
                {
                    LowerBound = y;
                    UpperBound = y;
                }
                if (num >= 0)
                {
                    LowerBound = y;
                    _reset = false;
                }
                if (num <= 0)
                {
                    UpperBound = y;
                    _reset = false;
                }
                return num;
            }
        }

        public LowerBoundSortedSet()
            : this(Comparer<T>.Default) { }

        public LowerBoundSortedSet(IComparer<T> comparer)
            : base(new ComparerDecorator<T>(comparer))
        {
            _comparerDecorator = (ComparerDecorator<T>)this.Comparer;
        }

        public T FindLowerBound(T key)
        {
            _comparerDecorator.Reset();
            this.Contains<T>(key);
            return _comparerDecorator.LowerBound;
        }

        public T FindUpperBound(T key)
        {
            _comparerDecorator.Reset();
            this.Contains<T>(key);
            return _comparerDecorator.UpperBound;
        }
    }
    public abstract class Heap<T> : IEnumerable<T>
    {
        private const int InitialCapacity = 0;
        private const int GrowFactor = 2;
        private const int MinGrow = 1;

        private int _capacity = InitialCapacity;
        private T[] _heap = new T[InitialCapacity];
        private int _tail = 0;

        public int Count { get { return _tail; } }
        public int Capacity { get { return _capacity; } }

        protected Comparer<T> Comparer { get; private set; }
        protected abstract bool Dominates(T x, T y);

        protected Heap() : this(Comparer<T>.Default)
        {
        }

        protected Heap(Comparer<T> comparer) : this(Enumerable.Empty<T>(), comparer)
        {
        }

        protected Heap(IEnumerable<T> collection)
            : this(collection, Comparer<T>.Default)
        {
        }

        protected Heap(IEnumerable<T> collection, Comparer<T> comparer)
        {
            if (collection == null) throw new ArgumentNullException("collection");
            if (comparer == null) throw new ArgumentNullException("comparer");

            Comparer = comparer;

            foreach (var item in collection)
            {
                if (Count == Capacity)
                    Grow();

                _heap[_tail++] = item;
            }

            for (int i = Parent(_tail - 1); i >= 0; i--)
                BubbleDown(i);
        }

        public void Add(T item)
        {
            if (Count == Capacity)
                Grow();

            _heap[_tail++] = item;
            BubbleUp(_tail - 1);
        }

        private void BubbleUp(int i)
        {
            if (i == 0 || Dominates(_heap[Parent(i)], _heap[i]))
                return; //correct domination (or root)

            Swap(i, Parent(i));
            BubbleUp(Parent(i));
        }

        public T GetMin()
        {
            if (Count == 0) throw new InvalidOperationException("Heap is empty");
            return _heap[0];
        }

        public T ExtractDominating()
        {
            if (Count == 0) throw new InvalidOperationException("Heap is empty");
            T ret = _heap[0];
            _tail--;
            Swap(_tail, 0);
            BubbleDown(0);
            return ret;
        }

        private void BubbleDown(int i)
        {
            int dominatingNode = Dominating(i);
            if (dominatingNode == i) return;
            Swap(i, dominatingNode);
            BubbleDown(dominatingNode);
        }

        private int Dominating(int i)
        {
            int dominatingNode = i;
            dominatingNode = GetDominating(YoungChild(i), dominatingNode);
            dominatingNode = GetDominating(OldChild(i), dominatingNode);

            return dominatingNode;
        }

        private int GetDominating(int newNode, int dominatingNode)
        {
            if (newNode < _tail && !Dominates(_heap[dominatingNode], _heap[newNode]))
                return newNode;
            else
                return dominatingNode;
        }

        private void Swap(int i, int j)
        {
            T tmp = _heap[i];
            _heap[i] = _heap[j];
            _heap[j] = tmp;
        }

        private static int Parent(int i)
        {
            return (i + 1) / 2 - 1;
        }

        private static int YoungChild(int i)
        {
            return (i + 1) * 2 - 1;
        }

        private static int OldChild(int i)
        {
            return YoungChild(i) + 1;
        }

        private void Grow()
        {
            int newCapacity = _capacity * GrowFactor + MinGrow;
            var newHeap = new T[newCapacity];
            Array.Copy(_heap, newHeap, _capacity);
            _heap = newHeap;
            _capacity = newCapacity;
        }

        public IEnumerator<T> GetEnumerator()
        {
            return _heap.Take(Count).GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }
    }

    public class MaxHeap<T> : Heap<T>
    {
        public MaxHeap()
            : this(Comparer<T>.Default)
        {
        }

        public MaxHeap(Comparer<T> comparer)
            : base(comparer)
        {
        }

        public MaxHeap(IEnumerable<T> collection, Comparer<T> comparer)
            : base(collection, comparer)
        {
        }

        public MaxHeap(IEnumerable<T> collection) : base(collection)
        {
        }

        protected override bool Dominates(T x, T y)
        {
            return Comparer.Compare(x, y) >= 0;
        }
    }

    public class MinHeap<T> : Heap<T>
    {
        public MinHeap()
            : this(Comparer<T>.Default)
        {
        }

        public MinHeap(Comparer<T> comparer)
            : base(comparer)
        {
        }

        public MinHeap(IEnumerable<T> collection) : base(collection)
        {
        }

        public MinHeap(IEnumerable<T> collection, Comparer<T> comparer)
            : base(collection, comparer)
        {
        }

        protected override bool Dominates(T x, T y)
        {
            return Comparer.Compare(x, y) <= 0;
        }
    }
    static class _4032123
    {
        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';
            }
        }
        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);

        class Node
        {
            public int Number { get; set; }
            public int Depth { get; set; }

        }
        static long Distance(long x1, long y1, long x2, long y2)
        {
            return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
        }
        static void Main(String[] args)
        {
            //var n = int.Parse(Console.ReadLine().TrimEnd());
            var data = Console.ReadLine().TrimEnd().Split(' ').Select(long.Parse).ToList();
            var x1 = data[0];
            var y1 = data[1];
            var x2 = data[2];
            var y2 = data[3];
            var x3 = data[4];
            var y3 = data[5];
            var d1 = Distance(x1, y1, x2, y2);
            var d2 = Distance(x2, y2, x3, y3);
            if (d1 == d2 && (y1-y2)* (x1 - x3) != (y1 - y3) * (x1 - x2))
            {
                writer.WriteLine("Yes");
            } else
            {
                writer.WriteLine("No");
            }

            writer.Flush();

        }
    }
}


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

namespace Arpa_and_an_exam_about_geometry
{
    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) ? "Yes" : "No");
            writer.Flush();
        }

        private static bool Solve(string[] args)
        {
            long ax = Next(), ay = Next(), bx = Next(), by = Next(), cx = Next(), cy = Next();

            if ((ax - bx)*(ax - bx) + (ay - by)*(ay - by) == (cx - bx)*(cx - bx) + (cy - by)*(cy - by))
            {
                return (cx - ax)*(cy - by) != (cy - ay)*(cx - bx);
            }

            return false;
        }

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