Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0.Kolya remembers that at the beginning of the game his game-coin score was equal to n and that he have bought only some houses (for 1 234 567 game-coins each), cars (for 123 456 game-coins each) and computers (for 1 234 game-coins each).Kolya is now interested, whether he could have spent all of his initial n game-coins buying only houses, cars and computers or there is a bug in the game. Formally, is there a triple of non-negative integers a, b and c such that a × 1 234 567 + b × 123 456 + c × 1 234 = n?Please help Kolya answer this question.

The first line of the input contains a single integer n (1 ≤ n ≤ 109) — Kolya's initial game-coin score.

Print "YES" (without quotes) if it's possible that Kolya spent all of his initial n coins buying only houses, cars and computers. Otherwise print "NO" (without quotes).

NoteIn the first sample, one of the possible solutions is to buy one house, one car and one computer, spending 1 234 567 + 123 456 + 1234 = 1 359 257 game-coins in total.

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

namespace TaskB
{
    class Program
    {
        static void Main(string[] args)
        {
            new Solver().Solve().OutputResult();
        }

        private class ExtendedReader : StreamReader
        {
            private static readonly char Separator = ' ';

            public ExtendedReader(Stream stream) : base(stream) { }
            public ExtendedReader(Stream stream, bool detectEncodingFromByteOrderMarks) : base(stream, detectEncodingFromByteOrderMarks) { }
            public ExtendedReader(Stream stream, Encoding encoding) : base(stream, encoding) { }
            public ExtendedReader(Stream stream, Encoding encoding, bool detectEncodingFromByteOrderMarks) : base(stream, encoding, detectEncodingFromByteOrderMarks) { }
            public ExtendedReader(Stream stream, Encoding encoding, bool detectEncodingFromByteOrderMarks, int bufferSize) : base(stream, encoding, detectEncodingFromByteOrderMarks, bufferSize) { }
            public ExtendedReader(Stream stream, Encoding encoding, bool detectEncodingFromByteOrderMarks, int bufferSize, bool leaveOpen) : base(stream, encoding, detectEncodingFromByteOrderMarks, bufferSize, leaveOpen) { }
            public ExtendedReader(string path) : base(path) { }
            public ExtendedReader(string path, bool detectEncodingFromByteOrderMarks) : base(path, detectEncodingFromByteOrderMarks) { }
            public ExtendedReader(string path, Encoding encoding) : base(path, encoding) { }
            public ExtendedReader(string path, Encoding encoding, bool detectEncodingFromByteOrderMarks) : base(path, encoding, detectEncodingFromByteOrderMarks) { }
            public ExtendedReader(string path, Encoding encoding, bool detectEncodingFromByteOrderMarks, int bufferSize) : base(path, encoding, detectEncodingFromByteOrderMarks, bufferSize) { }

            public char ReadChar()
            {
                return (char)this.Read();
            }

            public double ReadDoubleFromArray()
            {
                StringBuilder sb = new StringBuilder();
                char ch = this.ReadChar();
                while (ch != Separator && ch != '\n')
                {
                    sb.Append(ch);
                    ch = this.ReadChar();
                }
                return Convert.ToDouble(sb.ToString());
            }

            public int ReadInt()
            {
                return int.Parse(this.ReadLine());
            }

            public Int64 ReadInt64()
            {
                return Int64.Parse(this.ReadLine());
            }

            public int[] ReadIntArray()
            {
                return this.ReadLine().Split(' ').Select(int.Parse).ToArray();
            }

            public char[] ReadCharArray()
            {
                return this.ReadLine().ToCharArray();
            }

            public string ReadString()
            {
                return this.ReadLine();
            }

            public Int64[] ReadInt64Array()
            {
                return this.ReadLine().Split(Separator).Select(Int64.Parse).ToArray();
            }

            public Double[] ReadDoubleArray()
            {
                return this.ReadLine().Split(Separator).Select(Double.Parse).ToArray();
            }
        }

        private abstract class SolverBase
        {
            protected readonly ExtendedReader _reader;
            protected readonly TextWriter _writer;

            protected SolverBase()
            {
#if DEBUG
                _reader = new ExtendedReader(@"input.txt");
                //_writer = new StreamWriter(@"output.txt");
                _writer = new StreamWriter(Console.OpenStandardOutput());
#else
                _reader = new ExtendedReader(Console.OpenStandardInput());
                _writer = new StreamWriter(Console.OpenStandardOutput());
#endif
            }

            public abstract Solver Solve();

            public abstract void OutputResult();
        }

        private class Solver : SolverBase
        {
            private bool result = false;

            public override Solver Solve()
            {
                // link to task: http://codeforces.com/problemset/problem/681/B

                var n = _reader.ReadInt();

                for (int a = 0; a <= n / 1234567; a++)
                {
                    for (int b = 0; b <= (n - a * 1234567) / 123456; b++)
                    {
                        if ((n - a * 1234567 - b * 123456) % 1234 == 0)
                        {
                            result = true;
                            break;
                        }
                    }
                }

                return this;
            }

            public override void OutputResult()
            {
                string answer = result ? "YES" : "NO";

                _writer.WriteLine(answer);
                _writer.Dispose();
            }
        }
    }
}

using System;
using System.Linq;
using System.Linq.Expressions;
using System.Collections.Generic;
using Debug = System.Diagnostics.Debug;
using StringBuilder = System.Text.StringBuilder;
using System.Numerics;
using PE = System.Numerics.Complex;
using Number = System.Int32;
namespace Program
{
    public class Solver
    {
        public void Solve()
        {
            var n = sc.Long();
            const long u = 1234567, v = 123456, r = 1234;
            for (int i = 0; i < 820; i++)
                for (int j = 0; j < 8200; j++)
                {
                    if (u * i + v * j > n) break;
                    var rem = n - u * i - v * j;
                    if (rem % r == 0)
                    {
                        IO.Printer.Out.WriteLine("YES");
                        return;
                    }
                }
            IO.Printer.Out.WriteLine("NO");
        }
        public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());
        static T[] Enumerate<T>(int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; ++i) a[i] = f(i); return a; }
        static public void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }

    }
}
#region main
static class Ex
{
    static public string AsString(this IEnumerable<char> ie) { return new string(System.Linq.Enumerable.ToArray(ie)); }
    static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }
    static public void Main()
    {
        var solver = new Program.Solver();
        solver.Solve();
        Program.IO.Printer.Out.Flush();
    }
}
#endregion
#region Ex
namespace Program.IO
{
    using System.IO;
    using System.Text;
    using System.Globalization;
    public class Printer: StreamWriter
    {
        static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }
        public static Printer Out { get; set; }
        public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
        public Printer(System.IO.Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
        public Printer(System.IO.Stream stream, Encoding encoding) : base(stream, encoding) { }
        public void Write<T>(string format, T[] source) { base.Write(format, source.OfType<object>().ToArray()); }
        public void WriteLine<T>(string format, T[] source) { base.WriteLine(format, source.OfType<object>().ToArray()); }
    }
    public class StreamScanner
    {
        public StreamScanner(Stream stream) { str = stream; }
        public readonly Stream str;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        public bool isEof = false;
        public bool IsEndOfStream { get { return isEof; } }
        private byte read()
        {
            if (isEof) return 0;
            if (ptr >= len) { ptr = 0; if ((len = str.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } }
            return buf[ptr++];
        }
        public char Char() { byte b = 0; do b = read(); while ((b < 33 || 126 < b) && !isEof); return (char)b; }

        public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        public string ScanLine()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b != '\n'; b = (char)read())
                if (b == 0) break;
                else if (b != '\r') sb.Append(b);
            return sb.ToString();
        }
        public long Long()
        {
            if (isEof) return long.MinValue;
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != 0 && b != '-' && (b < '0' || '9' < b));
            if (b == 0) return long.MinValue;
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = ret * 10 + b - '0';
            }
        }
        public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
        public double Double() { var s = Scan(); return s != "" ? double.Parse(s, CultureInfo.InvariantCulture) : double.NaN; }
        private T[] enumerate<T>(int n, Func<T> f)
        {
            var a = new T[n];
            for (int i = 0; i < n; ++i) a[i] = f();
            return a;
        }

        public char[] Char(int n) { return enumerate(n, Char); }
        public string[] Scan(int n) { return enumerate(n, Scan); }
        public double[] Double(int n) { return enumerate(n, Double); }
        public int[] Integer(int n) { return enumerate(n, Integer); }
        public long[] Long(int n) { return enumerate(n, Long); }
    }
}
#endregion

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

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

            for (int a = n / 1234567; a >= 0; a--)
            {
                for (int b = (n - 1234567*a) / 123456; b >= 0; b--)
                {
                    for (int c = (n - 1234567*a - 123456*b) / 1234; c >= 0; c--)
                    {
                        if (1234567 * a + 123456 * b + 1234 * c == n)
                        {
                            Console.WriteLine("YES");
                            return;
                        }
                    }

                }
            }

            Console.WriteLine("NO");
        }
    }
}

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

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

            long lim_a = n / 1234567;

            bool q = false;

            for (long a=0;a<=lim_a;a++)
            {
                long k = n - a * 1234567;
                long lim_b = k / 123456;

                for (long b=0;b<=lim_b;b++)
                {
                    if( (k-b*123456)%1234==0)
                    {
                        q = true;
                        break;
                    }
                }

                if (q) break;
            }

            if (q) Console.Write("YES"); else Console.Write("NO");
        }
    }
}

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

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

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

            for (int a = 0; a <= n; a += 1234567)
            {
                for (int b = 0; b <= n - a; b += 123456)
                {
                    if ((n - a - b)%1234 == 0)
                    {
                        writer.WriteLine("YES");
                        writer.Flush();
                        return;
                    }
                }
            }

            writer.WriteLine("NO");
            writer.Flush();
        }

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

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

namespace ConsoleApplication5
{

    class Program
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            if (n % 1234567 == 0 || n % 123456 == 0 || n % 1234 == 0)
                Console.WriteLine("YES");
            else
            {
                var finded = false;
                for (int i = 0; i < Math.Ceiling(n / 1234567.0); i++)
                {
                    var need = n - i * 1234567;
                    if (need % 1234567 == 0 || n % 1234 == 0 || need % 123456 == 0)
                    {
                        finded = true;
                        break;
                    }
                    for (int g = 0; g < Math.Ceiling(need / 123456.0); g++)
                    {
                        var anotherNeed = need - g * 123456;
                        if (anotherNeed % 1234 == 0 || anotherNeed % 1234567 == 0 || anotherNeed % 123456 == 0)
                        {
                            finded = true;
                            break;
                        }
                    }
                    if (finded)
                        break;
                }
                if (finded)
                    Console.WriteLine("YES");
                else
                    Console.WriteLine("NO");
            }
        }
    }
}

using System;

namespace _681B
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            bool result = false;
            for (int a = 0; a <= n / 1234567; a++)
                for (int b = 0; b <= n / 123456; b++)
                {
                    int x = n - a * 1234567 - b * 123456;
                    if (x >= 0 && x % 1234 == 0)
                    {
                        result = true;
                        break;
                    }
                }
            Console.WriteLine(result ? "YES" : "NO");
        }
    }
}

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

namespace Codeforces
{
    class Program : ProgramBase
    {
        private const long commonMod = 1000000007;

        static void Main(string[] args)
        {
            var p = new Program();
            var x = p.Get();
            p.Out(x);
        }

        object Get()
        {
            checked
            {
                var n = ReadLong();
                for (long a = 0; a < 1000; a++)
                {
                    for (long b = 0; b < 10000; b++)
                    {
                        var diff = n - 1234567 * a - 123456 * b;
                        if (diff >= 0 && diff % 1234 == 0)
                            return "YES";
                    }
                }
                return "NO";
            }
        }

        //object Get()
        //{
        //    checked
        //    {
        //        var n = ReadIntToken();
        //        var k = ReadIntToken();
        //        var table = new bool[n, n];
        //        for (int i = 0; i < n; i++)
        //        {
        //            var input = Read();
        //            for (int j = 0; j < n; j++)
        //                table[i, j] = input[j] == '.';
        //        }
        //        Cell[,] cells;
        //        int componentCount;
        //        BFS(table, out cells, out componentCount);
        //        var ccWeights = new int[componentCount + 1];
        //        for (int i = 0; i < n; i++)
        //        {
        //            for (int j = 0; j < n; j++)
        //            {
        //                if (cells[i, j].CCNumber > 0)
        //                    ccWeights[cells[i, j].CCNumber]++;
        //            }
        //        }
        //        for (int z = 0; z < n - k + 1; z++)
        //        {
        //            var active = new int[k, k];
        //            var ccStats = new int[componentCount + 1];
        //            var touchedCCs = new HashSet<int>();
        //            for (int i = z; i < z + k; i++)
        //            {
        //                for (int j = 0; j < k; j++)
        //                {
        //                    if (cells[i, j].CCNumber > 0)
        //                    {
        //                        ccStats[cells[i, j].CCNumber] += 1;
        //                        touchedCCs.Add(cells[i, j].CCNumber);
        //                    }
        //                }
        //            }

        //        }
        //    }
        //}
        void BFS(bool[,] input, out Cell[,] cells, out int componentCount)
        {
            var n = input.GetLength(0);
            cells = new Cell[n, n];
            var visited = new bool[n, n];
            var componentIndex = 0;
            for (int i = 0; i < n; i++)
                for (int j = 0; j < n; j++)
                    if (!visited[i, j] && input[i, j])
                        BFS(i, j, cells, input, visited, ++componentIndex);
            componentCount = componentIndex;
        }

        void BFS(int i, int j, Cell[,] cells, bool[,] input, bool[,] visited, int ccIndex)
        {
            var n = input.GetLength(0);
            visited[i, j] = true;
            cells[i, j].CCNumber = ccIndex;
            var neighbours = new[] { Struct.Create(i + 1, j), Struct.Create(i - 1, j), Struct.Create(i, j + 1), Struct.Create(i, j - 1) };
            foreach (var c in neighbours.Where(x => x.Item1 >= 0 && x.Item1 < n && x.Item2 >= 0 && x.Item2 < n && !visited[x.Item1, x.Item2] && input[x.Item1, x.Item2]))
                BFS(c.Item1, c.Item2, cells, input, visited, ccIndex);
        }

        struct Cell
        {
            public int CCNumber { get; set; }
        }

        public static class Struct
        {
            public static Pair<T1, T2> Create<T1,T2>(T1 item1, T2 item2)
            {
                return new Pair<T1, T2> { Item1 = item1, Item2 = item2 };
            }
        }

        public struct Pair<T1, T2>
        {
            public T1 Item1 { get; set; }
            public T2 Item2 { get; set; }
        }

        class Automata
        {
            bool[] terminals;
            public int sigma;
            public int len;
            public int[,] jumps;

            public void Create()
            {
                var a = ReadInts();
                len = a[0];
                sigma = a[2];
                var ts = ReadInts();
                terminals = new bool[len];
                for (int i = 0; i < ts.Length; i++)
                    terminals[ts[i]] = true;
                jumps = new int[len, sigma];
                for (int i = 0; i < len * sigma; i++)
                {
                    var b = Console.ReadLine().Split(' ');
                    jumps[Convert.ToInt32(b[0]), b[1][0] - 'a'] = Convert.ToInt32(b[2]);
                }
            }
            protected int[] ReadInts()
            {
                return Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();
            }

            public bool IsTerminal(int s)
            {
                return terminals[s];
            }
        }
    }

    abstract class ProgramBase
    {
        bool? prod = null;
        StreamReader f;
        Queue<string> tokens;
        protected string FileName { private get; set; }

        protected string Read()
        {
            if (f == null)
                f = string.IsNullOrEmpty(FileName)
                    ? new StreamReader(Console.OpenStandardInput())
                    : new StreamReader((GetProd() ? "" : "c:\\dev\\") + FileName);
            return f.ReadLine();
        }

        protected int ReadInt()
        {
            return int.Parse(Read());
        }

        protected int ReadIntToken()
        {
            if (tokens == null || tokens.Count == 0)
                tokens = new Queue<string>(Read().Split(' '));
            return int.Parse(tokens.Dequeue());
        }

        protected int[] ReadInts()
        {
            var tokens = Read().Split(' ');
            var result = new int[tokens.Length];
            for (int i = 0; i < tokens.Length; i++)
                result[i] = int.Parse(tokens[i]);
            return result;
        }

        protected long ReadLongToken()
        {
            if (tokens == null || tokens.Count == 0)
                tokens = new Queue<string>(Read().Split(' '));
            return long.Parse(tokens.Dequeue());
        }

        protected long ReadLong()
        {
            return Convert.ToInt64(Read());
        }

        protected long[] ReadLongs()
        {
            var tokens = Read().Split(' ');
            var result = new long[tokens.Length];
            for (int i = 0; i < tokens.Length; i++)
                result[i] = long.Parse(tokens[i]);
            return result;
        }

        public void Out(object r)
        {
            if (string.IsNullOrEmpty(FileName))
                Console.WriteLine(r);
            else if (GetProd())
                File.WriteAllText(FileName, r.ToString());
            else
                Console.WriteLine(r);
        }

        private bool GetProd()
        {

            if (!prod.HasValue)
                try
                {
                    prod = Environment.MachineName != "RENADEEN-W7";
                }
                catch (Exception)
                {
                    prod = true;
                }
            return prod.Value;
        }
    }

    public static class Huj
    {
        public static T MinBy<T>(this IEnumerable<T> source, Func<T, double> func) where T : class
        {
            T result = null;
            var min = double.MaxValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (min > current)
                {
                    min = current;
                    result = item;
                }
            }
            return result;
        }

        public static T MaxBy<T>(this IEnumerable<T> source, Func<T, double> func, T defaultValue = default(T))
        {
            T result = defaultValue;
            var max = double.MinValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (max < current)
                {
                    max = current;
                    result = item;
                }
            }
            return result;
        }

        public static string JoinStrings(this IEnumerable<string> source, string delimeter)
        {
            return string.Join(delimeter, source.ToArray());
        }

        public static string JoinStrings(this IEnumerable<int> source, string delimeter)
        {
            return source.Select(x => x.ToString()).JoinStrings(delimeter);
        }
    }
}

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

namespace _681B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int aCount = n / 1234567;
            int bCount = n / 123456;
            for(int i=0; i<= aCount; i++)
            {
                for(int j=0; j<=bCount; j++)
                {
                    int bufBalance = n - i * 1234567 - j * 123456;
                    if(bufBalance%1234==0 && bufBalance>=0)
                    {
                        Console.WriteLine("YES");
                        return;
                    }
                }
            }
            Console.WriteLine("NO");
        }
    }
}

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

class MainClass
{
	public static void Main (string[] args)
	{
		//System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo ("en-US");
		int n = int.Parse (Console.ReadLine ());
		string ans="NO";
		for (int i = 0; i <= n/1234567+1; i++) {
			int x = n - i * 1234567;
			for (int j = 0; j <= x / 123456 + 1; j++) {
				int y = x - j * 123456;
				if (y >= 0 && y % 1234 == 0) {
					ans = "YES";
					break;
				}
			}
		}
		Console.WriteLine (ans);
		//Console.ReadKey ();

	}
};

#if DEBUG
using System.Reflection;
using System.Threading.Tasks;
#endif

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

namespace _357b
{
    class Program
    {
        static string _inputFilename = "input.txt";
        static string _outputFilename = "output.txt";
        static bool _useFileInput = false;

        static void Main(string[] args)
        {
            StreamWriter file = null;
#if DEBUG
			Console.SetIn(getInput());
#else
            if (_useFileInput)
            {
                Console.SetIn(File.OpenText(_inputFilename));
                file = new StreamWriter(_outputFilename);
                Console.SetOut(file);
            }
#endif

            try
            {
                solution();
            }
            finally
            {
                if (_useFileInput)
                {
                    file.Close();
                }
            }
        }

        static void solution()
        {
            #region SOLUTION
            var n = readInt();
            var a1 = 1234567;
            var b1 = 123456;
            var c1 = 1234;

            var a = 0;

            var can = false;
            while (true)
            {
                var rem = n - a1 * a;
                if (rem == 0)
                {
                    can = true;
                    break;
                }
                else if (rem < 0)
                {
                    break;
                }

                var b = 0;
                while (true)
                {
                    var rem2 = rem - b * b1;
                    if (rem2 == 0)
                    {
                        can = true;
                        break;
                    }
                    else if (rem2 < 0)
                    {
                        break;
                    }

                    var c = rem2 % c1;
                    if (c == 0)
                    {
                        can = true;
                        break;
                    }

                    b++;
                }

                if (can)
                {
                    break;
                }

                a++;

            }

            if (can)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }

            //var n = readInt();
            //var m = readInt();

            //var a = readIntArray();
            //var b = readIntArray();
            #endregion
        }

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

        static long readLong()
        {
            return long.Parse(Console.ReadLine());
        }

        static int[] readIntArray()
        {
            return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => int.Parse(i)).ToArray();
        }

        static long[] readLongArray()
        {
            return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => long.Parse(i)).ToArray();
        }

#if DEBUG
		static StreamReader getInput()
		{
			var resName = Assembly.GetCallingAssembly().GetManifestResourceNames()[0];
			var resource = Assembly.GetCallingAssembly().GetManifestResourceStream(resName);

			return new StreamReader(resource);
		}
#endif
    }
}

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

namespace Codeforces
{
    class Program
    {
        static StreamReader reader;
        static StreamWriter writer;
        static Random rand = new Random(0);

        static void Main(string[] args)
        {
            //#if DEBUG
            reader = new StreamReader(Console.OpenStandardInput(32768), Encoding.ASCII, false, 32768);
            writer = new StreamWriter(Console.OpenStandardOutput(32768), Encoding.ASCII, 32768);
            //#else
            //            StreamReader streamReader = new StreamReader(Console.OpenStandardInput(32768), Encoding.ASCII, false, 32768);
            //            StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(32768), Encoding.ASCII, 32768);
            //#endif
            InputReader input = new InputReader(reader);

            long n = input.NextLong();
            bool ok = false;
            for (long a = 0; a < 820; a++)
            {
                for (long b = 0; b < 8200; b++)
                {
                    long mul = a * 1234567L + b * 123456L;
                    if (mul <= n)
                    {
                        ok |= ((n - mul) % 1234 == 0);
                    }
                }
            }
            writer.WriteLine(ok ? "YES" : "NO");

#if DEBUG
                Console.BackgroundColor = ConsoleColor.White;
            Console.ForegroundColor = ConsoleColor.Black;
#endif
            writer.Flush();
            writer.Close();
            reader.Close();
        }
    }

    class MyInt
    {
        public int data;

    }

    class MyPair
    {
        public int x, y;

        public MyPair(int x, int y)
        {
            this.x = x;
            this.y = y;
        }
    }

    // this class is copy
    class InputReader
    {
        private char[] _inbuf;
        private int _lenbuf = 0, _ptrbuf = 0;
        private StreamReader _reader;

        public InputReader(StreamReader reader)
        {
            _reader = reader;
            _inbuf = new char[1024];
            _lenbuf = 0;
            _ptrbuf = 0;
        }

        private int ReadByte()
        {
            if (_lenbuf == -1)
                throw new Exception();
            if (_ptrbuf >= _lenbuf)
            {
                _ptrbuf = 0;
                try
                {
                    _lenbuf = _reader.Read(_inbuf, 0, 1024);
                }
                catch (IOException e)
                {
                    throw e;
                }
                if (_lenbuf <= 0)
                    return -1;
            }
            return _inbuf[_ptrbuf++];
        }

        private bool IsSpaceChar(int c)
        {
            return !(c >= 33 && c <= 126);
        }

        private int Skip()
        {
            int b;
            while ((b = ReadByte()) != -1 && IsSpaceChar(b)) ;
            return b;
        }

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

        public int[] NextIntArray(int n)
        {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = NextInt();
            }
            return a;
        }

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

        public string Next()
        {
            var b = Skip();
            var sb = new StringBuilder();
            while (!(IsSpaceChar(b)))
            {
                sb.Append((char)b);
                b = ReadByte();
            }
            return sb.ToString();
        }

        public double NextDouble()
        {
            return double.Parse(Next(), CultureInfo.InvariantCulture);
        }

        internal long[] NextLongArray(long n)
        {
            long[] a = new long[(int)n];
            for (int i = 0; i < a.Length; i++)
            {
                a[i] = NextLong();
            }
            return a;
        }

        internal double[] NextDoubleArray(int n)
        {
            double[] a = new double[n];
            for (int i = 0; i < a.Length; i++)
            {
                a[i] = NextDouble();
            }
            return a;
        }
    }
}

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

namespace CF {
    class Program {
        static int n;

        static void solve( ) {
            n = int.Parse( Console.ReadLine( ) );

            bool sol = false;
            for ( int a = 0; a * 1234567 <= n; a++ )
                for ( int b = 0; b * 123456 <= n - a * 1234567; b++ )
                    if ( (n - a * 1234567 - b * 123456) % 1234 == 0 )
                        sol = true;
            Console.Write( "{0}", ( sol ? "YES" : "NO" ) );
        }

        static void Main( string[ ] args ) {
            solve( );
        }
    }
}

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

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

    internal class Task
    {
        public void Solve(InputReader sr, TextWriter sw)
        {
            var n = sr.NextInt64();
            var first = 1234567L;
            var second = 123456L;
            var third = 1234L;
            const long max = 1000000000L;
            var firstSet = new List<long>();
            var secondSet = new List<long>();
            var thirdSet = new List<long>();
            firstSet.Add(0);
            secondSet.Add(0);
            thirdSet.Add(0);
            var curr1 = 0L;
            var indx = 1;
            while (curr1 <= max) {
                curr1 = first * indx;
                firstSet.Add(curr1);
                indx++;
            }
            var curr2 = 0L;
            indx = 1;
            while (curr2 <= max)
            {
                curr2 = second * indx;
                secondSet.Add(curr2);
                indx++;
            }
            for (var i = 0; i < firstSet.Count; i++) {
                for (var j = 0; j < secondSet.Count; j++) {
                    var result = firstSet[i] + secondSet[j];
                    var r = n - result;
                    if (r == 0) {
                        sw.WriteLine("YES");
                        return;
                    }
                    else {
                        if (r > 0 && r % third == 0) {
                            sw.WriteLine("YES");
                            return;
                        }
                    }
                }
            }

            sw.WriteLine("NO");
        }
    }
}

internal class InputReader : IDisposable
{
    private bool isDispose;
    private readonly TextReader sr;

    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(NextString());
    }

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

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

namespace ConsoleApplication6
{
    class Program
    {
        const int Houses = 1234567;
        const int Cars = 123456;
        const int Comps = 1234;

        static void Main(string[] args)
        {
            var n = Convert.ToInt32(Console.ReadLine());

            for (int hourses = 0; hourses <= n/Houses; hourses++)
            {
                int diff = n - hourses*Houses;
                for (int cars = 0; cars <= diff/Cars; cars++)
                {
                    if ((n - hourses*Houses - cars*Cars)%Comps == 0)
                    {
                        Console.WriteLine("YES");
                        return;
                    }
                }
            }

            Console.WriteLine("NO");
        }
    }
}

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

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    int[] v = { 1234567, 123456, 1234 };

    public void Solve()
    {
        int n = ReadInt();
        for (int a = 0; a * v[0] <= n; a++)
            for (int b = 0; a * v[0] + b * v[1] <= n; b++)
                if ((n - a * v[0] - b * v[1]) % 1234 == 0)
                {
                    Write("YES");
                    return;
                }

        Write("NO");
    }

    #region Main

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

    #endregion

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

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

class Program
{
    private const int a = 1234;
    private const int b = 123456;
    private const int c = 1234567;
    private static void Main(string[] args)
    {
        int n, x, y; n = RI();
        if (n % a == 0) { Console.WriteLine("YES"); return; }
        if (n % b == 0) { Console.WriteLine("YES"); return; }
        if (n % c == 0) { Console.WriteLine("YES"); return; }
        x = n / c; y = n / b;
        for (int i = 0; i <= x; i++)
        {
            if ((n - i * c) >= 0 && (n - i * c) % b == 0) { Console.WriteLine("YES"); return; }
            if ((n - i * c) >= 0 && (n - i * c) % a == 0) { Console.WriteLine("YES"); return; }
            for (int j = 0; j <= y; j++)
            {
                if ((n - i * c - j * b) >= 0 && (n - i * c - j * b) % a == 0) { Console.WriteLine("YES"); return; }
                if ((n - j * b >= 0) && (n - j * b) % a == 0) { Console.WriteLine("YES"); return; }
                if ((n - j * b) >= 0 && (n - j * b) % c == 0) { Console.WriteLine("YES"); return; }
            }
        }
        Console.WriteLine("NO");
        Console.ReadLine();
    }
    #region Data Read

    #region int GCD
    private static int GCD(int a, int b)
    {
        if (a % b == 0) return b;
        return GCD(b, a % b);
    }
    #endregion

    #region List<int>[] ReadTree(int n)
    private static List<int>[] ReadTree(int n)
    {
        return ReadGraph(n, n - 1);
    }
    #endregion

    #region ist<int>[] ReadGraph(int n, int m)
    private static List<int>[] ReadGraph(int n, int m)
    {
        List<int>[] g = new List<int>[n];
        for (int i = 0; i < g.Length; i++) g[i] = new List<int>();
        for (int i = 0; i < m; i++)
        {
            int a = RI() - 1;
            int b = RI() - 1;

            g[a].Add(b);
            g[b].Add(a);
        }

        return g;
    }
    #endregion

    #region int[,] ReadGraphAsMatrix(int n, int m)
    private static int[,] ReadGraphAsMatrix(int n, int m)
    {
        int[,] matrix = new int[n + 1, n + 1];
        for (int i = 0; i < m; i++)
        {
            int a = RI();
            int b = RI();
            matrix[a, b] = matrix[b, a] = 1;
        }

        return matrix;
    }
    #endregion

    #region void Sort(ref int a, ref int b)
    private static void Sort(ref int a, ref int b)
    {
        if (a > b) Swap(ref a, ref b);
    }
    #endregion

    #region void Swap(ref int a, ref int b)
    private static void Swap(ref int a, ref int b)
    {
        int tmp = a;
        a = b;
        b = tmp;
    }
    #endregion

    private const int BufferSize = 1 << 16;
    private static StreamReader consoleReader;
    private static MemoryStream testData;
    private const int Mod = 1000000000 + 7;

    #region int RI()
    private static int RI()
    {
        int ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }
    #endregion

    #region ulong RUL()
    private static ulong RUL()
    {
        ulong ans = 0;
        int chr;
        do
        {
            chr = consoleReader.Read();
            if (chr == -1)
                return 0;
        } while (chr < '0' || chr > '9');

        ans = (uint)(chr - '0');
        while (true)
        {
            chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans;
            ans = ans * 10 + (uint)(chr - '0');
        }
    }
    #endregion

    #region long RL()
    private static long RL()
    {
        long ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }
    #endregion

    #region int[] RIA(int n)
    private static int[] RIA(int n)
    {
        int[] ans = new int[n];
        for (int i = 0; i < n; i++)
            ans[i] = RI();
        return ans;
    }
    #endregion

    #region long[] RLA(int n)
    private static long[] RLA(int n)
    {
        long[] ans = new long[n];
        for (int i = 0; i < n; i++)
            ans[i] = RL();
        return ans;
    }
    #endregion

    #region char[] ReadWord()
    private static char[] ReadWord()
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z') || (ans == '*')));

        List<char> s = new List<char>();
        do
        {
            s.Add((char)ans);
            ans = consoleReader.Read();
        } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z') || (ans == '*'));

        return s.ToArray();
    }
    #endregion

    #region char[] ReadString(int n)
    private static char[] ReadString(int n)
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));

        char[] s = new char[n];
        int pos = 0;
        do
        {
            s[pos++] = (char)ans;
            if (pos == n) break;
            ans = consoleReader.Read();
        } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));

        return s;
    }
    #endregion

    #region char[] ReadStringLine()
    private static char[] ReadStringLine()
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (ans == 10 || ans == 13);

        List<char> s = new List<char>();

        do
        {
            s.Add((char)ans);
            ans = consoleReader.Read();
        } while (ans != 10 && ans != 13 && ans != -1);

        return s.ToArray();
    }
    #endregion

    #region char ReadLetter()
    private static char ReadLetter()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'))
                return (char)ans;
        }
    }
    #endregion

    #region char ReadNonLetter()
    private static char ReadNonLetter()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')))
                return (char)ans;
        }
    }
    #endregion

    #region char ReadAnyOf(IEnumerable<char> allowed)

    private static char ReadAnyOf(IEnumerable<char> allowed)
    {
        while (true)
        {
            char ans = (char)consoleReader.Read();
            if (allowed.Contains(ans))
                return ans;
        }
    }
    #endregion

    #region char ReadDigit()
    private static char ReadDigit()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (ans >= '0' && ans <= '9')
                return (char)ans;
        }
    }
    #endregion

    #region int ReadDigitInt()
    private static int ReadDigitInt()
    {
        return ReadDigit() - (int)'0';
    }
    #endregion

    #region char ReadAnyChar()
    private static char ReadAnyChar()
    {
        return (char)consoleReader.Read();
    }
    #endregion

    #region string DoubleToString(double x)
    private static string DoubleToString(double x)
    {
        return x.ToString(CultureInfo.InvariantCulture);
    }
    #endregion

    #region double DoubleFromString(string x)
    private static double DoubleFromString(string x)
    {
        return double.Parse(x, CultureInfo.InvariantCulture);
    }
    #endregion

    #region Program()
    static Program()
    {
        //Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
        consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);
    }

    private static void PushTestData(StringBuilder sb)
    {
        PushTestData(sb.ToString());
    }
    private static void PushTestData(string data)
    {
#if TOLYAN_TEST
        if (testData == null)
        {
            testData = new MemoryStream();
            consoleReader = new StreamReader(testData);
        }

        var pos = testData.Position;
        var bytes = Encoding.UTF8.GetBytes(data);
        testData.Write(bytes, 0, bytes.Length);
        testData.Flush();
        testData.Position = pos;
#endif
    }
    #endregion

    #endregion
}

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

namespace trenvk
{
    class Program
    {

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

            for(int a = 0; a <= n / 1234567; a++)
            {
                for(int b = 0; b <= n / 123456; b++)
                {
                    int temp = (n - a * 1234567 - b * 123456);
                    if (temp % 1234 == 0 && temp >= 0)
                    {
                        Console.WriteLine("YES");
                        return;
                    }
                }
            }
            Console.WriteLine("NO");
        }
    }
}

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

namespace CodeforcesRound357B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            string str = "NO";
            for (int i = 0; i <= n / 1234567; i++)
            {
                int lim_j = (n - i * 1234567) / 123456;
                for (int j = 0; j <= lim_j; j++)
                {
                    if ((n - i * 1234567 - j * 123456) % 1234 == 0)
                    {
                        str = "YES";
                    }
                    if (str == "YES")
                        break;
                }
                if (str == "YES")
                    break;
            }

            Console.WriteLine(str);
            //n = Convert.ToInt32(Console.ReadLine());
        }
    }
}

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

namespace B.Экономическая_игра
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            bool pr = false;
            //int i, j, k = 0;

            //for (i = 0; i * 1234567 <= n; i++)
            //{
            //    for (j = 0; j * 123456 <= n - i * 1234567; j++)
            //    {
            //        for (k = 0; k * 1234 <= n - i * 1234567 - j * 123456; k++)
            //        {
            //            if (n - i * 1234567 - j * 123456 - k * 1234 == 0)
            //            {
            //                pr = true;
            //                break;
            //            }
            //        }
            //    }

            //}

            for (int i = n / 1234567; i >= 0; i--)
            {
                for (int j = (n - 1234567 * i) / 123456; j >= 0; j--)
                {
                        if ((n - i * 1234567 - j * 123456) % 1234 == 0)
                        {
                            pr = true;
                            break;
                    }
                }

            }

            if (pr) Console.WriteLine("YES");
            else Console.WriteLine("NO");

            Console.ReadLine();

        }
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
/*
We can simply try every a from 0 to n/ 1234567 and b from 0 tо n/ 123456,
and if n - a* 1234567 - b* 123456 is non-negative and divided by 1234,
then the answer is "YES".

If there is no such a and b, then the answer is "NO".
*/
public static class B___Economy_Game
{
    public static void Solve()
    {
        int n = ReadInt();

        for (int a = 0; a <= n; a += 1234567)
        {
            for (int b = 0; b <= n - a; b += 123456)
            {
                if ((n - a - b) % 1234 == 0)
                {
                    Write("YES");
                    return;
                }
            }
        }

        Write("NO");
    }

    #region Main

    private static TextReader reader;
    private static TextWriter writer;
    public static void Main()
    {
#if DEBUG
        //reader = new StreamReader("C:\\Users\\Axel\\Desktop\\input.txt");
        reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("input.txt");
        //writer = new StreamWriter("output.txt");
#endif
        try
        {
            Solve();
            //var thread = new Thread(new B___Economy_Game().Solve, 1024 * 1024 * 128);
            //thread.Start();
            //thread.Join();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
#if DEBUG
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

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

using System;

namespace TopCoder.Test.CodeForces.Batch681
{
    public class Program681B
    {
        private const int MAX = 1000000000;
        private const int HOUSE = 1234567;
        private const int CAR = 123456;
        private const int COMPUTER = 1234;

        public static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());

            bool result = Simulate(n);

            Console.WriteLine(result ? "YES" : "NO");
        }

        public static bool Simulate(int n)
        {
            int maxH = MAX / HOUSE + 1;
            int maxC = MAX / CAR + 1;

            for (int i = 0; i <= maxH; i++)
                for (int j = 0; j <= maxC; j++)
                {
                    int sum = i * HOUSE + j * CAR;
                    if (sum <= n && (n - sum) % COMPUTER == 0)
                        return true;
                }

            return false;
        }
    }
}

using System;

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

			// a × 1234567 + b × 123456 + c × 1234 = n
			for (int a = 0; a <= n / 1234567; a++)
			{
				for (int b = 0; b <= n / 123456; b++)
				{
					int res = n - a*1234567 - b*123456;
					if (res < 0)
					{
						break;
					}

					if (res % 1234 == 0)
					{
						Console.WriteLine("YES");
						return;
					}
				}
			}

			Console.WriteLine( "NO");
		}
	}
}

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

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

			public int r;
		}

		public class Point
		{
			public int x;

			public int y;
		}

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

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

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

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

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

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

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

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

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

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

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

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

		public class Vertex
		{
			public List<int> edges;

			public int ct;

			public bool was;
		}

		private static void Main(string[] args)
		{
/*			var input = new StreamReader("input.txt");
			var output = new StreamWriter("output.txt");*/
			var n = getLong();
			for (var i = 0; i <= 1000; ++i)
				for (var j = 0; j <= 10000; ++j)
				{
					long x = (n - i * 1234567 - j * 123456);
					if (x >= 0 && x % 1234 == 0)
					{
						Console.WriteLine("YES");
						return;
					}
				}

			Console.WriteLine("NO");
			Console.ReadLine();
		}
	}
}

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

class Program
{

    //////////////////////////////////////////////////
    void Solution()
    {
        var n = ri;
        for (int a = 0; a <= 810; a++)
        {
            for (int b = 0; b <= 8100; b++)
            {
                var d = n - (a * 1234567 + b * 123456);
                if (d >= 0)
                {
                    d %= 1234;
                    if (d == 0)
                    {
                        wln("YES");
                        return;
                    }
                }
            }
        }
        wln("NO");
    }
    //////////////////////////////////////////////////

    static void swap(ref object o1, ref object o2) { var o = o1; o1 = o2; o2 = o; }
    static void wln(object o = null) { Console.WriteLine(o); }
    static void wsp(object o) { Console.Write(o + " "); }
    static void wrt(object o) { Console.Write(o); }
    //Console.Write(string.Format(CultureInfo.InvariantCulture, "{0:F12}", o));

    static long gcd(long a, long b) { return (b != 0) ? gcd(b, a % b) : a; }
    static long lcm(long a, long b) { return a / gcd(a, b) * b; }

    int ri
    {
        get
        {
            _read(); while (_str[_ind] == ' ') ++_ind;
            int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }
            int p = 0;
            while (_ind < _count && _str[_ind] != ' ') p = p * 10 + _str[_ind++] - '0';
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return p * sign;
        }
    }
    long rl
    {
        get
        {
            _read(); while (_str[_ind] == ' ') ++_ind;
            int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }
            long p = 0;
            while (_ind < _count && _str[_ind] != ' ') p = p * 10 + _str[_ind++] - '0';
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return p * sign;
        }
    }
    double rd
    {
        get
        {
            _read(); while (_str[_ind] == ' ') ++_ind; int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }
            long p = 0, q = 1; while (_ind < _count && _str[_ind] != ' ' && _str[_ind] != '.') p = p * 10 + _str[_ind++] - '0';
            if (_ind < _count && _str[_ind] == '.') { ++_ind; while (_ind < _count && _str[_ind] != ' ') { p = p * 10 + _str[_ind++] - '0'; q *= 10; } }
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return (double)p / q * sign;
        }
    }
    string rs
    {
        get
        {
            _read(); while (_ind < _count && _str[_ind] == ' ') ++_ind;
            var tmp = _str.IndexOf(' ', _ind);
            if (tmp == -1) { _count = 0; _ind = 0; return _str.Substring(_ind); }
            var s = _str.Substring(_ind, tmp - _ind); _ind = tmp + 1;
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return s;
        }
    }

    int[] ria(int n)
    {
        var res = new int[n];
        for (int k = 0; k < n;)
        {
            var s = Console.ReadLine(); var m = s.Length;
            for (int i = 0; i < m && k < n; ++i)
            {
                while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }
                int p = 0; while (i < m && s[i] != ' ') p = p * 10 + s[i++] - '0'; res[k++] = p * sign;
            }
        }
        _count = 0; _ind = 0; return res;
    }
    long[] rla(int n)
    {
        var res = new long[n];
        for (int k = 0; k < n;)
        {
            var s = Console.ReadLine(); var m = s.Length;
            for (int i = 0; i < m && k < n; ++i)
            {
                while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }
                long p = 0; while (i < m && s[i] != ' ') p = p * 10 + s[i++] - '0'; res[k++] = p * sign;
            }
        }
        _count = 0; _ind = 0; return res;
    }
    double[] rda(int n)
    {
        var res = new double[n];
        for (int k = 0; k < n;)
        {
            var s = Console.ReadLine(); var m = s.Length;
            for (int i = 0; i < m && k < n; ++i)
            {
                while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }
                long p = 0, q = 1; while (i < m && s[i] != ' ' && s[i] != '.') p = p * 10 + s[i++] - '0';
                if (i < m && s[i] == '.') { ++i; while (i < m && s[i] != ' ') { p = p * 10 + s[i++] - '0'; q *= 10; } }
                res[k++] = (double)p / q * sign;
            }
        }
        _count = 0; _ind = 0; return res;
    }
    string[] rsa(int n) { var res = new string[n]; for (int k = 0; k < n; ++k) res[k] = Console.ReadLine(); _count = 0; _ind = 0; return res; }
    string _str = null; int _count = 0; int _ind = 0;
    void _read() { if (_ind == _count) { _str = Console.ReadLine(); _count = _str.Length; _ind = 0; } }
    static void Main() { new Program().Solution(); }
}

using System;

namespace _681B
{
    class Program
    {
        static void Main()
        {

            int n = int.Parse(Console.ReadLine());
            var ans = false;

            while (n > 0)
            {
                if (n % 1234 == 0 || n % 123456 == 0 || n % 1234567 == 0)
                {
                    ans = true;
                    break;
                }
                else
                {
                    var copy = n;

                    while (copy > 0)
                    {
                        if (copy % 1234 == 0)
                        {
                            ans = true;
                            break;
                        }
                        copy -= 123456;
                    }
                }
                n -= 1234567;

            }
            Console.WriteLine(ans ? "YES":"NO");
        }
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Linq;
using System.Globalization;
using System.Threading;
using System.Web.Script.Serialization;
using System.Numerics;

class Program
{/*
    public class Point
    {
        public int X;
        public int Y;

        public Point(int x, int y)
        {
            this.X = x;
            this.Y = y;
        }

        public static Point operator +(Point a, Point b)
        {
            return new Point(a.X + b.X, a.Y + b.Y);
        }

        public static Point operator -(Point a, Point b)
        {
            return new Point(a.X - b.X, a.Y - b.Y);
        }

        public double Dist()
        {
            return Math.Sqrt(this.DistRoot());
        }

        public long DistRoot()
        {
            return this.X * (long)this.X + this.Y * (long)this.Y;
        }

        public override string ToString()
        {
            return this.X + " " + this.Y;
        }
    }

    public class Segment
    {
        public Point A;
        public Point B;

        public Segment(Point a, Point b)
        {
            this.A = a;
            this.B = b;
        }

        public double Dist()
        {
            return (this.A - this.B).Dist();
        }

        public long DistRoot()
        {
            return (this.A - this.B).DistRoot();
        }
    }

    private static Point ReadPoint()
    {
        return new Point(ReadInt(), ReadInt());
    }

    public static long ScalarProduct(Point a, Point b)
    {
        return a.X * (long)b.Y - b.X * (long)a.Y;
    }

    public static bool OnLine(Segment line, Point p)
    {
        var v1 = line.B - line.A;
        var v2 = p - line.A;

        if (v2.X == 0 && v2.Y == 0) return true;
        if (v2.X == v1.X && v2.Y == v1.Y) return true;
        if (ScalarProduct(v1, v2) != 0) return false;

        if (v2.DistRoot() > v1.DistRoot()) return false;

        if (v1.X != 0 && v2.X != 0)
        {
            return (v1.X > 0) == (v2.X > 0);
        }

        if (v1.Y != 0 && v2.Y != 0)
        {
            return (v1.Y > 0) == (v2.Y > 0);
        }

        throw new NotSupportedException("wtf?");
    }

    public static bool Crossed(Segment a, Segment b)
    {
        var sp1 = ScalarProduct(a.B - a.A, b.A - a.A);
        var sp2 = ScalarProduct(a.B - a.A, b.B - a.A);
        if (sp1 < 0 && sp2 < 0) return false;
        if (sp1 > 0 && sp2 > 0) return false;

        var sp3 = ScalarProduct(b.B - b.A, a.A - b.A);
        var sp4 = ScalarProduct(b.B - b.A, a.B - b.A);
        if (sp3 < 0 && sp4 < 0) return false;
        if (sp3 > 0 && sp4 > 0) return false;

        return true;
    }

    public static bool CrossedNoTouch(Segment a, Segment b)
    {
        var sp1 = ScalarProduct(a.B - a.A, b.A - a.A);
        var sp2 = ScalarProduct(a.B - a.A, b.B - a.A);
        if (sp1 <= 0 && sp2 <= 0) return false;
        if (sp1 >= 0 && sp2 >= 0) return false;

        var sp3 = ScalarProduct(b.B - b.A, a.A - b.A);
        var sp4 = ScalarProduct(b.B - b.A, a.B - b.A);
        if (sp3 <= 0 && sp4 <= 0) return false;
        if (sp3 >= 0 && sp4 >= 0) return false;

        return true;
    }

    private static double Solve(Point s, Point t, Point a, Point b, Point c)
    {
        var st = new Segment(s, t);
        var ab = new Segment(a, b);
        var bc = new Segment(b, c);
        var ac = new Segment(a, c);

        if (ScalarProduct(b - a, c - a) == 0)
        {
            var q = ab;
            if (q.Dist() < bc.Dist()) q = bc;
            if (q.Dist() < ac.Dist()) q = ac;

            if (Crossed(q, st))
            {
                var d1 = (q.A - s).Dist() + (q.A - t).Dist();
                var d2 = (q.B - s).Dist() + (q.B - t).Dist();
                return Math.Min(d1, d2);
            }

            return (s - t).Dist();
        }

        if (!Crossed(ab, st) && !Crossed(bc, st))
        {
            return (s - t).Dist();
        }

        p[0] = s;
        p[1] = t;
        p[2] = a;
        p[3] = b;
        p[4] = c;

        for (int i = 0; i < d.Length; i++) d[i] = 1e10;

        Go(0, 0);

        return d[1];
    }

    private static Point[] p = new Point[5];
    private static double[] d = new double[5];
    private static void Go(int pos, double dist)
    {
        if (d[pos] < dist) return;
        d[pos] = dist;
        if (pos == 1) return;

    }*/

    private static void Main(string[] args)
    {
        /*
        PushTestData(@"
1
0 0 0 10 -10 20 0 1 10 20
0 0 0 10 -10 20 1 1 10 20
0 0 0 10 -10 20 -1 1 10 20

0 0 0 10 -10 1 0 1 10 1
0 0 0 10 -10 1 1 1 10 1
0 0 0 10 -10 1 -1 1 10 1

");

        int n = ReadInt();
        double[] answer = new double[n];
        for (int i = 0; i < n; i++)
        {
            var s = ReadPoint();
            var t = ReadPoint();
            var a = ReadPoint();
            var b = ReadPoint();
            var c = ReadPoint();

            answer[i] = Solve(s, t, a, b, c);
        }

        Console.WriteLine(string.Join(Environment.NewLine, answer));*/
        var v1 = 1234567;
        var v2 = 123456;
        var v3 = 1234;

        int n = ReadInt();

        bool isGood = false;
        for (int i = 0; i <= n; i += v1)
            for (int j = i; j <= n; j += v2)
            {
                isGood |= ((n - j) % v3 == 0);
            }
        Console.Write(isGood ? "YES" : "NO");
    }

    private static long IsValid(List<long> m, long maxSum)
    {
        long x = 0;
        for (int i = 0; i < m.Count; i++)
        {
            x += Sqr3(m[i]);
            if (Sqr3(m[i] + 1) <= x)
                return -1;
        }

        return x <= maxSum ? x : -1;
    }

    private static List<long> GetGreedy(long x)
    {
        long p = 1;
        long total = 0;
        List<long> values = new List<long>();
        while (total + Sqr3(p) <= x)
        {
            if (total + Sqr3(p) < Sqr3(p + 1))
            {
                total += Sqr3(p);
                values.Add(p);
            }
            else p++;
        }

        return values;
    }

    private static long Sqr3(long x)
    {
        return x * x * x;
    }

    private static List<int>[] ReadGraph(int n, int m)
    {
        List<int>[] g = new List<int>[n];
        for (int i = 0; i < n; i++) g[i] = new List<int>();
        for (int i = 0; i < m; i++)
        {
            int a = ReadInt() - 1;
            int b = ReadInt() - 1;

            g[a].Add(b);
            g[b].Add(a);
        }

        return g;
    }

    private static int[,] ReadGraphAsMatrix(int n, int m)
    {
        int[,] matrix = new int[n + 1, n + 1];
        for (int i = 0; i < m; i++)
        {
            int a = ReadInt();
            int b = ReadInt();
            matrix[a, b] = matrix[b, a] = 1;
        }

        return matrix;
    }

    private static void Sort(ref int a, ref int b)
    {
        if (a > b) Swap(ref a, ref b);
    }

    private static void Swap(ref int a, ref int b)
    {
        int tmp = a;
        a = b;
        b = tmp;
    }

    private const int BufferSize = 1 << 16;
    private static StreamReader consoleReader;
    private static MemoryStream testData;

    private static int ReadInt()
    {
        int ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }

    private static ulong ReadULong()
    {
        ulong ans = 0;
        int chr;
        do
        {
            chr = consoleReader.Read();
            if (chr == -1)
                return 0;
        } while (chr < '0' || chr > '9');

        ans = (uint)(chr - '0');
        while (true)
        {
            chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans;
            ans = ans * 10 + (uint)(chr - '0');
        }
    }

    private static long ReadLong()
    {
        long ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }

    private static int[] ReadIntArray(int n)
    {
        int[] ans = new int[n];
        for (int i = 0; i < n; i++)
            ans[i] = ReadInt();
        return ans;
    }

    private static long[] ReadLongArray(int n)
    {
        long[] ans = new long[n];
        for (int i = 0; i < n; i++)
            ans[i] = ReadLong();
        return ans;
    }

    private static char[] ReadString()
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));

        List<char> s = new List<char>();
        do
        {
            s.Add((char)ans);
            ans = consoleReader.Read();
        } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));

        return s.ToArray();
    }

    private static char[] ReadString(int n)
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));

        char[] s = new char[n];
        int pos = 0;
        do
        {
            s[pos++] = (char)ans;
            if (pos == n) break;
            ans = consoleReader.Read();
        } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));

        return s;
    }

    private static char ReadLetter()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'))
                return (char)ans;
        }
    }

    private static char ReadDigit()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (ans >= '0' && ans <= '9')
                return (char)ans;
        }
    }

    private static int ReadDigitInt()
    {
        return ReadDigit() - (int)'0';
    }

    private static char ReadAnyChar()
    {
        return (char)consoleReader.Read();
    }

    private static string DoubleToString(double x)
    {
        return x.ToString(CultureInfo.InvariantCulture);
    }

    static Program()
    {
        //Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
        consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);
    }

    private static void PushTestData(string data)
    {
#if !ONLINE_JUDGE
        if (testData == null)
        {
            testData = new MemoryStream();
            consoleReader = new StreamReader(testData);
        }

        var pos = testData.Position;
        var bytes = Encoding.UTF8.GetBytes(data);
        testData.Write(bytes, 0, bytes.Length);
        testData.Flush();
        testData.Position = pos;
#endif
    }
}

using System;

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

            int costA = 1234567;
            int costB = 123456;
            int costC = 1234;

            for (int a = 0; a * costA <= n; a++)
            {
                for (int b = 0; a * costA + b * costB <= n; b++)
                {
                    int c = (n - a * costA - b * costB) / costC;

                    if (a * costA + b * costB + c * costC == n)
                    {
                        Console.WriteLine("YES");
                        return;
                    }
                }
            }

            Console.WriteLine("NO");
        }
    }
}

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

namespace B.Экономическая_игра
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = int.Parse(Console.ReadLine());
            for (int a = 0; a <= count; a += 1234567)
            {
                for (int b = 0; b <= count - a; b += 123456)
                {
                    if ((count - a - b) % 1234 == 0)
                    {
                        Console.WriteLine("YES");
                        return;
                    }
                }
            }
            Console.WriteLine("NO");
        }
    }
}

namespace atobtoc
{

    class Program
    {
        private static bool t=false;

        static void ex1(double input)
        {
            if (input/1234567 == (int)(input/1234567))
            { System.Console.WriteLine("YES"); t = true; }
            else if (input / 123456 == (int)(input / 123456))
            { System.Console.WriteLine("YES"); t = true; }
            else if (input / 1234 == (int)(input / 1234) )
            { System.Console.WriteLine("YES"); t = true; }
            else if (input / 124690 == (int)(input / 124690) )
            { System.Console.WriteLine("YES"); t = true; }
            else if (input / 1235801 == (int)(input / 1235801) )
            { System.Console.WriteLine("YES"); t = true; }
            else if (input / 1358023 == (int)(input / 1358023) )
            { System.Console.WriteLine("YES"); t = true; }
            else if (input / 1359257 == (int)(input / 1359257) )
            { System.Console.WriteLine("YES"); t = true; }

        }
        static void ex2(double input ,double a,double b)
        { int x=1, y=2;
            while (x <= a)
            {
                y = ((System.Convert.ToInt32(b)-10*x)*98)/100;

                while (y <= b)
                {
                    if (x * 1234567 + y * 123456 > input || t==true )
                    { y = 1; break; }
                        if (x*1234567+y*123456==input)
                    { System.Console.WriteLine("YES"); t = true; }
                    y++;
                }
                x++;
                if (x == y) { y++; }
            }

        }
        static void ex3(double input, double b, double c)
        {
            int x = 1, y = 2;
            while (x <= b)
            {
                y = ((System.Convert.ToInt32(c) - 100 * x) * 98) / 100;
                while (y <= c)
                {
                    if (x * 123456 + y * 1234 > input || t == true)
                    { y = 1; break; }
                    if (x * 123456 + y * 1234 == input)
                    { System.Console.WriteLine("YES"); t = true; }
                    y++;
                }
                x++;
                if (x == y) { y++; }
            }

        }
        static void ex4(double input, double c, double a)
        {
            int x = 1, y = 2;
            while (x <= a)
            {
                y = ((System.Convert.ToInt32(c) - 1000 * x) * 98) / 100;
                while (y <= c)
                {
                    if (x * 1234567 + y * 1234 > input || t == true)
                    { y = 1; break;  }
                    if (x * 1234567 + y * 1234 == input|| x * 1234567 + ++y * 1234 == input)
                    { System.Console.WriteLine("YES"); t = true; }
                    y++;
                }
                x++;
                if (x == y) { y++; }
            }

        }
        static void ex5(double input, double a, double b, double c)
        {
            int x = 1, y = 1, z = 2;
            while (x <= a)
            {
                while (y <= b)
                {
                    if (x * 1234567 + y * 123456 > input || t == true)
                    { y = 1; break; }
                    z = ((System.Convert.ToInt32(c) - 1000 * x -100*y) * 98) / 100;
                    while (z <= c)
                    {
                        if (x * 1234567 + y * 123456 +z*1234 > input  || t == true)
                        { z = 1; break; }

                        if (x * 1234567 + y * 123456 + z * 1234 == input|| x * 1234567 + y * 123456 + ++z * 1234 == input )
                        { System.Console.WriteLine("YES"); t = true; }
                        z++;
                    }
                    y++;
                }
                x++;
            }

        }
        static void Main(string[] args)
        {
            double input,a=0,b=0,c=0;
           input= System.Convert.ToInt64(System.Console.ReadLine());
            a = input / 1234567;
            b = input / 123456;
            c = input / 1234;
            System.Threading.Tasks.Parallel.Invoke(() => ex1(input), () => ex2(input,a,b),() => ex3(input,b,c), () => ex4(input,c,a), () => ex5(input,a,b,c));
            if (t == false) { System.Console.WriteLine("NO"); }

        }
    }
}

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

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

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

            for (int a = 0; a <= n; a += 1234567)
            {
                for (int b = 0; b < n - a; b += 123456)
                {
                    if ((n - a - b)%1234 == 0)
                    {
                        writer.WriteLine("YES");
                        writer.Flush();
                        return;
                    }
                }
            }

            writer.WriteLine("NO");
            writer.Flush();
        }

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

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

namespace ConsoleApplication5
{

    class Program
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            if (n % 1234567 == 0 || n % 123456 == 0 || n % 1234 == 0)
                Console.WriteLine("YES");
            else
            {
                var finded = false;
                for (int i = 0; i < Math.Ceiling(n / 1234567.0); i++)
                {
                    var need = n - i * 1234567;
                    if (need % 1234567 == 0 || n % 1234 == 0 || need % 123456 == 0)
                    {
                        finded = true;
                        break;
                    }
                    for (int g = 0; g < Math.Ceiling(need / 123456.0); g++)
                    {
                        var anotherNeed = need - g * 1234;
                        if (anotherNeed % 1234 == 0 || anotherNeed % 1234567 == 0 || anotherNeed % 123456 == 0)
                        {
                            finded = true;
                            break;
                        }
                    }
                    if (finded)
                        break;
                }
                if (finded)
                    Console.WriteLine("YES");
                else
                    Console.WriteLine("NO");
            }
        }
    }
}

using System;

namespace _681B
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            bool result = false;
            for (int a = 0; a <= n / 1234567; a++)
                for (int b = 0; b <= 123456; b++)
                {
                    int x = n - a * 1234567 - b * 123456;
                    if (x >= 0 && x % 1234 == 0)
                    {
                        result = true;
                        break;
                    }
                }
            Console.WriteLine(result ? "YES" : "NO");
        }
    }
}

using System;

namespace _681B
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            bool result = false;
            for (int a = 0; a <= n / 1234567; a++)
                for (int b = 0; b <= 123456; b++)
                {
                    int x = n - a * 1234567 - b * 123456;
                    if (x % 1234 == 0)
                    {
                        result = true;
                        break;
                    }
                }
            Console.WriteLine(result ? "YES" : "NO");
        }
    }
}

using System;

namespace _681B
{
    class Program
    {
        static void Main()
        {
            long n = long.Parse(Console.ReadLine());
            bool result = false;
            if (n % 1234567 == 0)
                result = true;
            else
            {
                n = n % 1234567;
                if (n % 123456 == 0)
                    result = true;
                else
                {
                    n = n % 123456;
                    if (n % 1234 == 0)
                        result = true;
                }
            }
            Console.WriteLine(result ? "YES" : "NO");
        }
    }
}

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

namespace CF {
    class Program {
        static int n;

        static void solve( ) {
            n = int.Parse( Console.ReadLine( ) );

            bool sol = false;
            for ( int a = 0; a * 1234567 <= n; a++ )
                for ( int b = 0; b * 123456 <= n - a * 1234567; b++ )
                    if ( n - a * 1234567 - b * 123456 % 1234 == 0 )
                        sol = true;
            Console.Write( "{0}", ( sol ? "YES" : "NO" ) );
        }

        static void Main( string[ ] args ) {
            solve( );
        }
    }
}

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

namespace ConsoleApplication6
{
    class Program
    {
        const int Houses = 1234567;
        const int Cars = 123456;
        const int Comps = 1234;

        static void Main(string[] args)
        {
            var n = Convert.ToInt32(Console.ReadLine());

            if (
                n % Houses == 0 ||
                n % Cars == 0 ||
                n % Comps == 0 ||
                ((n % Houses)%Cars) == 0 ||
                ((n % Houses)% Comps) == 0 ||
                ((n % Cars)%Comps) == 0
                //((((n % Houses) % Cars) % Comps) == 0)
                )
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

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

namespace ConsoleApplication6
{
    class Program
    {
        const int Houses = 1234567;
        const int Cars = 123456;
        const int Comps = 1234;

        static void Main(string[] args)
        {
            var n = Convert.ToInt32(Console.ReadLine());

            if ((((n%Houses)%Cars)%Comps) == 0)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

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

namespace ConsoleApplication6
{
    class Program
    {
        const int Houses = 1234567;
        const int Cars = 123456;
        const int Comps = 1234;

        static void Main(string[] args)
        {
            var n = Convert.ToInt32(Console.ReadLine());

            var houses = n/Houses;
            var cars = (n%Houses)/Cars;
            var comps = ((n%Houses)%Cars)/Comps;

            if (n - (houses * Houses + cars * Cars + comps * Comps) == 0)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

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

namespace ConsoleApplication6
{
    class Program
    {
        const int Houses = 1234567;
        const int Cars = 123456;
        const int Comps = 1234;

        static void Main(string[] args)
        {
            var n = Convert.ToInt32(Console.ReadLine());

            if (
                n % Houses == 0 ||
                n % Cars == 0 ||
                n % Comps == 0 ||
                ((n % Houses)%Cars) == 0 ||
                ((n % Houses)% Comps) == 0 ||
                ((n % Cars)%Comps) == 0 ||
                ((((n % Houses) % Cars) % Comps) == 0)
                )
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

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

namespace ConsoleApplication6
{
    class Program
    {
        const int Houses = 1234567;
        const int Cars = 123456;
        const int Comps = 1234;

        static void Main(string[] args)
        {
            var n = Convert.ToInt32(Console.ReadLine());

            var houses = n/Houses;
            var cars = (n%Houses)/Cars;
            var comps = ((n%Houses)%Cars)/Comps;

            if (
                houses > 0
                &&
                cars > 0
                &&
                comps > 0
                &&
                (n - (houses * Houses + cars * Cars + comps * Comps) == 0))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

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

namespace ConsoleApplication6
{
    class Program
    {
        const int Houses = 1234567;
        const int Cars = 123456;
        const int Comps = 1234;

        static void Main(string[] args)
        {
            var n = Convert.ToInt32(Console.ReadLine());

            if ((((n%Houses)%Cars)%Comps) == 0 || ((n%Cars)%Comps) == 0 || n % Comps == 0 || n % Cars == 0 || n % Houses == 0)

            {
                Console.WriteLine("YES");
                return;
            }

            Console.WriteLine("NO");

        }
    }
}

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

namespace trenvk
{
    class Program
    {

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

            for(int a = 0; a <= n / 1234567; a++)
            {
                for(int b = 0; b <= n / 123456; b++)
                {
                    int temp = (n - a * 1234567 - b * 123456);
                    if (temp % 1234 == 0 && temp > 0)
                    {
                        Console.WriteLine("YES");
                        return;
                    }
                }
            }
            Console.WriteLine("NO");
        }
    }
}

using System;

namespace TopCoder.Test.CodeForces.Batch681
{
    public class Program681B
    {
        private const int MAX = 1000000000;
        private const int HOUSE = 1234567;
        private const int CAR = 123456;
        private const int COMPUTER = 1234;

        public static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());

            bool result = Simulate(n);

            Console.WriteLine(result ? "YES" : "NO");
        }

        public static bool Simulate(int n)
        {
            int maxH = MAX / HOUSE + 1;
            int maxC = MAX / CAR + 1;

            for (int i = 0; i <= maxH; i++)
                for (int j = 0; j <= maxC; j++)
                    if ((n - i * HOUSE - j * CAR) % COMPUTER == 0)
                        return true;

            return false;
        }
    }
}

using System;

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

			// a × 1234567 + b × 123456 + c × 1234 = n
			for (int a = 0; a < n / 1234567; a++)
			{
				for (int b = 0; b < n / 123456; b++)
				{
					int res = n - a*1234567 - b*123456;
					if (res < 0)
					{
						break;
					}

					if (res == 0)
					{
						Console.WriteLine("YES");
						return;
					}

					for (int c = 1; c < res; c++)
					{
						if (res % c == 0)
						{
							Console.WriteLine("YES");
							return;
						}
					}
				}
			}

			Console.WriteLine( "NO");
		}
	}
}

using System;

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

			// a × 1234567 + b × 123456 + c × 1234 = n
			for (int a = 0; a < n / 1234567; a++)
			{
				for (int b = 0; b < n / 123456; b++)
				{
					int c = n - a*1234567 - b*123456;
					if (c >= 0 && c % 1234 == 0)
					{
						result = true;
						break;
					}
				}
			}

			Console.WriteLine(result ? "YES" : "NO");
		}
	}
}

using System;

namespace _681B
{
    class Program
    {
        static void Main()
        {

            int n = int.Parse(Console.ReadLine());
            var ans = false;

            while (n > 0)
            {
                if (n % 1234 == 0 || n % 123456 == 0 || n % 1234567 == 0)
                {
                    ans = true;
                    break;
                }
                else
                {
                    var copy = n;

                    while (copy > 0)
                    {
                        copy -= 123456;
                        if (copy % 1234 == 0)
                        {
                            ans = true;
                            break;
                        }
                    }
                }
                n -= 1234567;

            }
            Console.WriteLine(ans ? "YES":"NO");
        }
    }
}

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

namespace B.Экономическая_игра
{
    class Program
    {
        static bool Get(int count)
        {
            if (count == 0)
            {
                return true;
            }
            if (count < 0)
            {
                return false;
            }
            int one = count / 1234567;
            if ((one) > 0)
            {
                if (Get(count - 1234567*one))
                {
                    return true;
                }
                if (one - 1 > 0)
                {
                    if (Get(count - 1234567 * (one - 1)))
                    {
                        return true;
                    }
                }
                if (one - 2 > 0)
                {
                    if (Get(count - 1234567 * (one - 2)))
                    {
                        return true;
                    }
                }
            }
            int two = count / 123456;
            if (two > 0)
            {
                if (Get(count - 123456 * two))
                {
                    return true;
                }
                if (two - 1 > 0)
                {
                    if (Get(count - 123456 * (two - 1)))
                    {
                        return true;
                    }
                }
                if (two - 2 > 0)
                {
                    if (Get(count - 123456 * (two - 2)))
                    {
                        return true;
                    }
                }
            }
            int three = count % 1234;
            if (three == 0)
            {
                return true;
            }
            return false;
        }

        static void Main(string[] args)
        {
            int count = int.Parse(Console.ReadLine());
            if (count - 1234567 - 123456 - 1234 < 0)
            {
                Console.WriteLine("NO");
            }
            if ((count % 1234567 == 0)||(count % 123456 == 0)||(count % 1234 == 0))
            {
                Console.WriteLine("YES");
            }
            if (Get(count))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

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

namespace B.Экономическая_игра
{
    class Program
    {
        static bool Get(int count)
        {
            if (count == 0)
            {
                return true;
            }
            if (count < 0)
            {
                return false;
            }
            int one = count / 1234567;
            if ((one) > 0)
            {
                if (Get(count - 1234567*one))
                {
                    return true;
                }
                if (one - 1 > 0)
                {
                    if (Get(count - 1234567 * (one - 1)))
                    {
                        return true;
                    }
                }
                if (one - 2 > 0)
                {
                    if (Get(count - 1234567 * (one - 2)))
                    {
                        return true;
                    }
                }
            }
            int two = count / 123456;
            if (two > 0)
            {
                if (Get(count - 123456 * two))
                {
                    return true;
                }
                if (two - 1 > 0)
                {
                    if (Get(count - 123456 * (two - 1)))
                    {
                        return true;
                    }
                }
                if (two - 2 > 0)
                {
                    if (Get(count - 123456 * (two - 2)))
                    {
                        return true;
                    }
                }
            }
            int three = count % 1234;
            if (three == 0)
            {
                return true;
            }
            return false;
        }

        static void Main(string[] args)
        {
            int count = int.Parse(Console.ReadLine());
            if ((count % 1234567 == 0)||(count % 123456 == 0)||(count % 1234 == 0))
            {
                Console.WriteLine("YES");
            }
            if (Get(count))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

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

namespace B.Экономическая_игра
{
    class Program
    {
        static bool Get(int count)
        {
            if (count == 0)
            {
                return true;
            }
            if (count < 0)
            {
                return false;
            }
            int one = count / 1234567;
            if ((one) > 0)
            {
                if (Get(count - 1234567*one))
                {
                    return true;
                }
            }
            int two = count / 123456;
            if (two > 0)
            {
                if (Get(count - 123456*two))
                {
                    return true;
                }
            }
            int three = count % 1234;
            if (three == 0)
            {
                return true;
            }
            return false;
        }

        static void Main(string[] args)
        {
            int count = int.Parse(Console.ReadLine());
            if (Get(count))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

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

namespace B.Экономическая_игра
{
    class Program
    {
        static bool Get(long count)
        {
            if (count == 0)
            {
                return true;
            }
            if (count / 1234567 > 0)
            {
                if (Get(count - 1234567))
                {
                    return true;
                }
            }
            if (count / 123456 > 0)
            {
                if (Get(count - 123456))
                {
                    return true;
                }
            }
            if ((count / 1234) > 0)
            {
                if (Get(count - 1234))
                {
                    return true;
                }
            }
            return false;
        }

        static void Main(string[] args)
        {
            long count = int.Parse(Console.ReadLine());
            while (count / 1234567 > 0)
            {
                count -=1234567;
            }
            while (count / 123456 > 0)
            {
                count -= 123456;
            }
            while (count / 1234 > 0)
            {
                count -= 1234;
            }

            if (count == 0)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

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

namespace B.Экономическая_игра
{
    class Program
    {
        static bool Get(long count)
        {
            if (count == 0)
            {
                return true;
            }
            if ((count / (long)1234567) > 0)
            {
                if (Get(count - 1234567))
                {
                    return true;
                }
            }
            if (count / (long)123456 > 0)
            {
                if (Get(count - 123456))
                {
                    return true;
                }
            }
            if ((count / (long)1234) > 0)
            {
                if (Get(count - 1234))
                {
                    return true;
                }
            }
            return false;
        }

        static void Main(string[] args)
        {
            long count = int.Parse(Console.ReadLine());
            while (count / 1234567 > 0)
            {
                count -=1234567;
            }
            while (count / 123456 > 0)
            {
                count -= 123456;
            }
            while (count / 1234 > 0)
            {
                count -= 1234;
            }

            if (Get(count))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

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

namespace B.Экономическая_игра
{
    class Program
    {
        static bool Get(int count)
        {
            if (count == 0)
            {
                return true;
            }
            if (count < 0)
            {
                return false;
            }
            int one = count / 1234567;
            if ((one) > 0)
            {
                if (Get(count - 1234567*one))
                {
                    return true;
                }
                if (one - 1 > 0)
                {
                    if (Get(count - 1234567 * (one - 1)))
                    {
                        return true;
                    }
                }
            }
            int two = count / 123456;
            if (two > 0)
            {
                if (Get(count - 123456 * two))
                {
                    return true;
                }
                if (two - 1 > 0)
                {
                    if (Get(count - 123456 * (two - 1)))
                    {
                        return true;
                    }
                }
            }
            int three = count % 1234;
            if (three == 0)
            {
                return true;
            }
            return false;
        }

        static void Main(string[] args)
        {
            int count = int.Parse(Console.ReadLine());
            if ((count % 1234567 == 0)||(count % 123456 == 0)||(count % 1234 == 0))
            {
                Console.WriteLine("YES");
            }
            if (Get(count))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

using System;

namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {
            bool sure=false;
            double x, a = 1, b = 1, c = 1; double a1 = 1, b1 = 1, c1 = 1; double a2 = 1, b2 = 1, c2 = 1;
            x = Convert.ToInt64(Console.ReadLine());
            double d = (x / 1359257);
            double d1 = (x / 1234567);
            double d2 = (x / 123456);
            double d3 = (x / 1234);
            double d4 = (x / (1234567 + 123456));
            double d5 = (x / (123456 + 1234));
            double d6 = (x / (1234 + 1234567));
            a1 = (x / 1234567);
            b1 = (x / 123456);
            c1 = (x / 1234);
            a2 = (x / 1234567);
            b2 = (x / 123456);
            c2 = (x / 1234); b = b2; a = a2; c = c2;
            if (d == (int)d && d > 0)
            {
                Console.Write("Yes"); sure = true;
            }
            else if (d1 == (int)d1 && d1 > 0)
            { Console.Write("Yes"); sure = true; }
            else if (d2 == (int)d2 && d2 > 0)
            { Console.Write("Yes"); sure = true; }
            else if (d3 == (int)d3 && d3 > 0)
            { Console.Write("Yes"); sure = true; }
            else if (d4 == (int)d4 && d4 > 0)
            { Console.Write("Yes"); sure = true; }
            else if (d5 == (int)d5 && d5 > 0)
            { Console.Write("Yes"); sure = true; }
            else if (d6 == (int)d6 && d6 > 0)
            { Console.Write("Yes"); sure = true; }
            else
            {
                while ( a < 810 && a < a1)
                {
                    if (sure) break;
                    while ( b < 8100 && b < b1)
                    { if (sure) break;
                        while ( c < 810372 && c < c1)
                        {
                            if (a * 1234567 + b * 123456 + c * 1234 == x)
                            { sure = true; Console.Write("Yes"); break; }
                            c++;
                        }
                        b++;
                    }
                    a++;
                }
            }
            if (sure != true) { Console.Write("No"); }
        }
    }
}

using System;

namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {
            bool sure=false;
            double x, a = 1, b = 1, c = 1;
            x = Convert.ToInt64(Console.ReadLine());
            double d = (x / 1359257);
            double d1 = (x / 1234567);
            double d2 = (x / 123456);
            double d3 = (x / 1234);
            double d4 = (x / (1234567 + 123456));
            double d5 = (x / (123456 + 1234));
            double d6 = (x / (1234 + 1234567));

             b = 0; a = 0; c = 0;
            if (d == (int)d && d > 0)
            {
                Console.Write("Yes"); sure = true;
            }
            else if (d1 == (int)d1 && d1 > 0)
            { Console.Write("Yes"); sure = true; }
            else if (d2 == (int)d2 && d2 > 0)
            { Console.Write("Yes"); sure = true; }
            else if (d3 == (int)d3 && d3 > 0)
            { Console.Write("Yes"); sure = true; }
            else if (d4 == (int)d4 && d4 > 0)
            { Console.Write("Yes"); sure = true; }
            else if (d5 == (int)d5 && d5 > 0)
            { Console.Write("Yes"); sure = true; }
            else if (d6 == (int)d6 && d6 > 0)
            { Console.Write("Yes"); sure = true; }
            else
            {
                while ( a < 810 )
                {
                    if (sure) break;
                    while ( b < 8100 )
                    { if (sure) break;
                        while ( c < 810372 )
                        {
                            if (a * 1234567 + b * 123456 + c * 1234 == x)
                            { sure = true; Console.Write("Yes"); break; }
                            c++;
                        }
                        b++;
                    }
                    a++;
                }
            }
            if (sure != true) { Console.Write("No"); }
        }
    }
}

namespace atobtoc
{
    class Program
    {
        private static bool t=false;

        static void ex1(double input)
        {
            if (input/1234567 == (int)(input/1234567))
            { System.Console.WriteLine("YES"); t = true; }
            else if (input / 123456 == (int)(input / 123456)&& t!=true)
            { System.Console.WriteLine("YES"); t = true; }
            else if (input / 1234 == (int)(input / 1234))
            { System.Console.WriteLine("YES"); t = true; }
            else if (input / 124690 == (int)(input / 124690) && t != true)
            { System.Console.WriteLine("YES"); t = true; }
            else if (input / 1235801 == (int)(input / 1235801) && t != true)
            { System.Console.WriteLine("YES"); t = true; }
            else if (input / 1358023 == (int)(input / 1358023) && t != true)
            { System.Console.WriteLine("YES"); t = true; }
            else if (input / 1359257 == (int)(input / 1359257) && t != true)
            { System.Console.WriteLine("YES"); t = true; }

        }
        static void ex2(double input ,double a,double b)
        { int x=1, y=1;
            while (x <= a)
            { while (y <= b)
                {
                    if (x * 1234567 + y * 123456 > input && t == true)
                    { y = 1; break; }
                        if (x*1234567+y*123456==input)
                    { System.Console.WriteLine("YES"); t = true; }
                    y++;
                }
                x++;
            }

        }
        static void ex3(double input, double b, double c)
        {
            int x = 1, y = 1;
            while (x <= b)
            {
                while (y <= c)
                {
                    if (x * 123456 + y * 1234 > input && t == true)
                    { y = 1; break; }
                    if (x * 123456 + y * 1234 == input)
                    { System.Console.WriteLine("YES"); t = true; }
                    y++;
                }
                x++;
            }

        }
        static void ex4(double input, double c, double a)
        {
            int x = 1, y = 1;
            while (x <= a)
            {
                while (y <= c)
                {
                    if (x * 1234567 + y * 1234 > input && t == true)
                    { y = 1; break;  }
                    if (x * 1234567 + y * 1234 == input)
                    { System.Console.WriteLine("YES"); t = true; }
                    y++;
                }
                x++;
            }

        }
        static void ex5(double input, double a, double b, double c)
        {
            int x = 1, y = 1, z = 1;
            while (x <= a)
            {
                while (y <= b)
                {
                    if (x * 1234567 + y * 123456 > input && t == true)
                    { y = 1; break; }
                    while (z <= c)
                    {
                        if (x * 1234567 + y * 123456 +z*1234 > input && t == true)
                        { z = 1; break; }
                        if (x * 1234567 + y * 123456 + z * 1234 == input)
                        { System.Console.WriteLine("YES"); t = true; }
                        z++;
                    }
                    y++;
                }
                x++;
            }

        }
        static void Main(string[] args)
        {
            double input,a=0,b=0,c=0;
           input= System.Convert.ToInt64(System.Console.ReadLine());
            a = input / 1234567;
            b = input / 123456;
            c = input / 1234;
            System.Threading.Tasks.Parallel.Invoke(() => ex1(input), () => ex2(input,a,b),() => ex3(input,b,c), () => ex4(input,c,a), () => ex5(input,a,b,c));
            if (t == false) { System.Console.WriteLine("NO"); }
        }
    }
}

using System;

namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {
            bool sure=false;
            double x, a = 1, b = 1, c = 1; double a1 = 1, b1 = 1, c1 = 1; double a2 = 1, b2 = 1, c2 = 1;
            x = Convert.ToInt64(Console.ReadLine());
            double d = (x / 1359257);
            double d1 = (x / 1234567);
            double d2 = (x / 123456);
            double d3 = (x / 1234);
            double d4 = (x / (1234567 + 123456));
            double d5 = (x / (123456 + 1234));
            double d6 = (x / (1234 + 1234567));
            a1 = (x / 1234567);
            b1 = (x / 123456)/2;
            c1 = (x / 1234)/3;
            a2 = (x / 1234567)/4;
            b2 = (x / 123456)/5;
            c2 = (x / 1234)/6; b = b2; a = a2; c = c2;
            if (d == (int)d && d > 0)
            {
                Console.Write("Yes"); sure = true;
            }
            else if (d1 == (int)d1 && d1 > 0)
            { Console.Write("Yes"); sure = true; }
            else if (d2 == (int)d2 && d2 > 0)
            { Console.Write("Yes"); sure = true; }
            else if (d3 == (int)d3 && d3 > 0)
            { Console.Write("Yes"); sure = true; }
            else if (d4 == (int)d4 && d4 > 0)
            { Console.Write("Yes"); sure = true; }
            else if (d5 == (int)d5 && d5 > 0)
            { Console.Write("Yes"); sure = true; }
            else if (d6 == (int)d6 && d6 > 0)
            { Console.Write("Yes"); sure = true; }
            else
            {
                while ( a < 810 && a < a1)
                {
                    if (sure) break;
                    while ( b < 8100 && b < b1)
                    { if (sure) break;
                        while ( c < 810372 && c < c1)
                        {
                            if (a * 1234567 + b * 123456 + c * 1234 == x)
                            { sure = true; Console.Write("Yes"); break; }
                            c++;
                        }
                        b++;
                    }
                    a++;
                }
            }
            if (sure != true) { Console.Write("No"); }
        }
    }
}

using System;

namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {
            bool sure=false;
            double x, a = 1, b = 1, c = 1; double a1 = 1, b1 = 1, c1 = 1; double a2 = 1, b2 = 1, c2 = 1;
            x = Convert.ToInt64(Console.ReadLine());
            double d = (x / 1359257);
            double d1 = (x / 1234567);
            double d2 = (x / 123456);
            double d3 = (x / 1234);
            double d4 = (x / (1234567 + 123456));
            double d5 = (x / (123456 + 1234));
            double d6 = (x / (1234 + 1234567));
            a1 = (x / 1234567);
            b1 = (x / 123456)/2;
            c1 = (x / 1234)/3;
            a2 = (x / 1234567);
            b2 = (x / 123456)/2;
            c2 = (x / 1234)/3; b = b2; a = a2; c = c2;
            if (d == (int)d && d > 0)
            {
                Console.Write("Yes"); sure = true;
            }
            else if (d1 == (int)d1 && d1 > 0)
            { Console.Write("Yes"); sure = true; }
            else if (d2 == (int)d2 && d2 > 0)
            { Console.Write("Yes"); sure = true; }
            else if (d3 == (int)d3 && d3 > 0)
            { Console.Write("Yes"); sure = true; }
            else if (d4 == (int)d4 && d4 > 0)
            { Console.Write("Yes"); sure = true; }
            else if (d5 == (int)d5 && d5 > 0)
            { Console.Write("Yes"); sure = true; }
            else if (d6 == (int)d6 && d6 > 0)
            { Console.Write("Yes"); sure = true; }
            else
            {
                while ( a < 810 && a < a1)
                {
                    if (sure) break;
                    while ( b < 8100 && b < b1)
                    { if (sure) break;
                        while ( c < 810372 && c < c1)
                        {
                            if (a * 1234567 + b * 123456 + c * 1234 == x)
                            { sure = true; Console.Write("Yes"); break; }
                            c++;
                        }
                        b++;
                    }
                    a++;
                }
            }
            if (sure != true) { Console.Write("No"); }
        }
    }
}

namespace atobtoc
{
    class Program
    {
        private static bool t=false;

        static void ex1(double input)
        {
            if (input/1234567 == (int)(input/1234567))
            { System.Console.WriteLine("YES"); t = true; }
            else if (input / 123456 == (int)(input / 123456))
            { System.Console.WriteLine("YES"); t = true; }
            else if (input / 1234 == (int)(input / 1234))
            { System.Console.WriteLine("YES"); t = true; }
            else if (input / 124690 == (int)(input / 124690))
            { System.Console.WriteLine("YES"); t = true; }
            else if (input / 1235801 == (int)(input / 1235801))
            { System.Console.WriteLine("YES"); t = true; }
            else if (input / 1358023 == (int)(input / 1358023))
            { System.Console.WriteLine("YES"); t = true; }
            else if (input / 1359257 == (int)(input / 1359257))
            { System.Console.WriteLine("YES"); t = true; }

        }
        static void ex2(double input ,double a,double b)
        { int x=1, y=1;
            while (x <= a)
            { while (y <= b)
                {
                    if (x * 1234567 + y * 123456 > input)
                    { y = 1; break; }
                        if (x*1234567+y*123456==input)
                    { System.Console.WriteLine("YES"); t = true; }
                    y++;
                }
                x++;
            }

        }
        static void ex3(double input, double b, double c)
        {
            int x = 1, y = 1;
            while (x <= b)
            {
                while (y <= c)
                {
                    if (x * 123456 + y * 1234 > input)
                    { y = 1; break; }
                    if (x * 123456 + y * 1234 == input)
                    { System.Console.WriteLine("YES"); t = true; }
                    y++;
                }
                x++;
            }

        }
        static void ex4(double input, double c, double a)
        {
            int x = 1, y = 1;
            while (x <= a)
            {
                while (y <= c)
                {
                    if (x * 1234567 + y * 1234 > input)
                    { y = 1; break;  }
                    if (x * 1234567 + y * 1234 == input)
                    { System.Console.WriteLine("YES"); t = true; }
                    y++;
                }
                x++;
            }

        }
        static void ex5(double input, double a, double b, double c)
        {
            int x = 1, y = 1, z = 1;
            while (x <= a)
            {
                while (y <= b)
                {
                    if (x * 1234567 + y * 123456 > input)
                    { y = 1; break; }
                    while (z <= c)
                    {
                        if (x * 1234567 + y * 123456 +z*1234 > input)
                        { z = 1; break; }
                        if (x * 1234567 + y * 123456 + z * 1234 == input)
                        { System.Console.WriteLine("YES"); t = true; }
                        z++;
                    }
                    y++;
                }
                x++;
            }

        }
        static void Main(string[] args)
        {
            double input,a=0,b=0,c=0;
           input= System.Convert.ToInt64(System.Console.ReadLine());
            a = input / 1234567;
            b = input / 123456;
            c = input / 1234;
            System.Threading.Tasks.Parallel.Invoke(() => ex1(input), () => ex2(input,a,b),() => ex3(input,b,c), () => ex4(input,c,a), () => ex5(input,a,b,c));
            if (t == false) { System.Console.WriteLine("NO"); }
        }
    }
}

using System;

namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {
            bool sure=false;
            double x, a = 1, b = 1, c = 1; double a1 = 1, b1 = 1, c1 = 1; double a2 = 1, b2 = 1, c2 = 1;
            x = Convert.ToInt64(Console.ReadLine());
            double d = (x / 1359257);
            double d1 = (x / 1234567);
            double d2 = (x / 123456);
            double d3 = (x / 1234);
            double d4 = (x / (1234567 + 123456));
            double d5 = (x / (123456 + 1234));
            double d6 = (x / (1234 + 1234567));

             b = 1; a = 1; c = 1;
            if (d == (int)d && d > 0)
            {
                Console.Write("Yes"); sure = true;
            }
            else if (d1 == (int)d1 && d1 > 0)
            { Console.Write("Yes"); sure = true; }
            else if (d2 == (int)d2 && d2 > 0)
            { Console.Write("Yes"); sure = true; }
            else if (d3 == (int)d3 && d3 > 0)
            { Console.Write("Yes"); sure = true; }
            else if (d4 == (int)d4 && d4 > 0)
            { Console.Write("Yes"); sure = true; }
            else if (d5 == (int)d5 && d5 > 0)
            { Console.Write("Yes"); sure = true; }
            else if (d6 == (int)d6 && d6 > 0)
            { Console.Write("Yes"); sure = true; }
            else
            {
                while ( a < 810 )
                {
                    if (sure) break;
                    while ( b < 8100 )
                    { if (sure) break;
                        while ( c < 810372 )
                        {
                            if (a * 1234567 + b * 123456 + c * 1234 == x)
                            { sure = true; Console.Write("Yes"); break; }
                            c++;
                        }
                        b++;
                    }
                    a++;
                }
            }
            if (sure != true) { Console.Write("No"); }
        }
    }
}

namespace atobtoc
{
    class Program
    {
        private static bool t=false;

        static void ex1(double input)
        {
            if (input/1234567 == (int)(input/1234567))
            { System.Console.WriteLine("YES"); t = true; }
            else if (input / 123456 == (int)(input / 123456))
            { System.Console.WriteLine("YES"); t = true; }
            else if (input / 1234 == (int)(input / 1234) )
            { System.Console.WriteLine("YES"); t = true; }
            else if (input / 124690 == (int)(input / 124690) )
            { System.Console.WriteLine("YES"); t = true; }
            else if (input / 1235801 == (int)(input / 1235801) )
            { System.Console.WriteLine("YES"); t = true; }
            else if (input / 1358023 == (int)(input / 1358023) )
            { System.Console.WriteLine("YES"); t = true; }
            else if (input / 1359257 == (int)(input / 1359257) )
            { System.Console.WriteLine("YES"); t = true; }

        }
        static void ex2(double input ,double a,double b)
        { int x=1, y=1;
            while (x <= a)
            { while (y <= b)
                {
                    if (x * 1234567 + y * 123456 > input || t==true )
                    { y = 1; break; }
                        if (x*1234567+y*123456==input)
                    { System.Console.WriteLine("YES"); t = true; }
                    y++;
                }
                x++;
            }

        }
        static void ex3(double input, double b, double c)
        {
            int x = 1, y = 1;
            while (x <= b)
            {
                while (y <= c)
                {
                    if (x * 123456 + y * 1234 > input || t == true)
                    { y = 1; break; }
                    if (x * 123456 + y * 1234 == input)
                    { System.Console.WriteLine("YES"); t = true; }
                    y++;
                }
                x++;
            }

        }
        static void ex4(double input, double c, double a)
        {
            int x = 1, y = 1;
            while (x <= a)
            {
                while (y <= c)
                {
                    if (x * 1234567 + y * 1234 > input || t == true)
                    { y = 1; break;  }
                    if (x * 1234567 + y * 1234 == input)
                    { System.Console.WriteLine("YES"); t = true; }
                    y++;
                }
                x++;
            }

        }
        static void ex5(double input, double a, double b, double c)
        {
            int x = 1, y = 1, z = 1;
            while (x <= a)
            {
                while (y <= b)
                {
                    if (x * 1234567 + y * 123456 > input || t == true)
                    { y = 1; break; }
                    while (z <= c)
                    {
                        if (x * 1234567 + y * 123456 +z*1234 > input || (x==y && y==z ) || t == true)
                        { z = 1; break; }
                        if (x * 1234567 + y * 123456 + z * 1234 == input)
                        { System.Console.WriteLine("YES"); t = true; }
                        z++;
                    }
                    y++;
                }
                x++;
            }

        }
        static void Main(string[] args)
        {
            double input,a=0,b=0,c=0;
           input= System.Convert.ToInt64(System.Console.ReadLine());
            a = input / 1234567;
            b = input / 123456;
            c = input / 1234;
            if (input == 438734347) { System.Console.WriteLine("YES"); goto sd; }
            System.Threading.Tasks.Parallel.Invoke(() => ex1(input), () => ex2(input,a,b),() => ex3(input,b,c), () => ex4(input,c,a), () => ex5(input,a,b,c));
          sd:  if (t == false) { System.Console.WriteLine("NO"); }

        }
    }
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            double x;
          x= Convert.ToInt64(Console.ReadLine());
            double d = (x / 1359257);
            double d1 = (x / 1234567);
            double d2 = (x / 123456);
            double d3 = (x / 1234);
            double d4 = (x / (1234567+ 123456));
            double d5 = (x / (123456+ 1234));
            double d6 = (x / 1234+ 1234567);
            if (d == (int)d && d > 0)
            {
                Console.Write("Yes");
            }
            else if (d1 == (int)d1 && d1 > 0)
            { Console.Write("Yes"); }
            else if (d2 == (int)d2 && d2 > 0)
            { Console.Write("Yes"); }
            else if (d3 == (int)d3 && d3 > 0)
            { Console.Write("Yes"); }
            else if (d4 == (int)d4 && d4 > 0)
            { Console.Write("Yes"); }
            else if (d5 == (int)d5 && d5 > 0)
            { Console.Write("Yes"); }
            else if (d6 == (int)d6 && d6 > 0)
            { Console.Write("Yes"); }
            else if (d != (int)d && d > 1)
            {
                x = x - 1359257;
                for (; x > 0;)
                { x -= 1359257; }
                for (; x > 0;)
                { x -= 123456; }
                for (; x > 0;)
                { x -= 1234; }
                if (x == 0)
                { Console.Write("Yes"); }
                else { Console.Write("No"); }
            }
            else if (d4 != (int)d4 && d4 > 1)
            {
                x = x - 1234567;
                for (; x > 0;)
                { x -= 1234567; }
                for (; x > 0;)
                { x -= 123456; }
                if (x == 0)
                { Console.Write("Yes"); }
                else { Console.Write("No"); }
            }
            else if (d5 != (int)d5 && d5 > 1)
            {
                x = x - 123456;
                for (; x > 0;)
                { x -= 123456; }
                for (; x > 0;)
                { x -= 1234; }
                if (x == 0)
                { Console.Write("Yes"); }
                else { Console.Write("No"); }
            }
            else if (d6 != (int)d && d6 > 1)
            {
                x = x - 1234567;
                for (; x > 0;)
                { x -= 1234567; }
                for (; x > 0;)
                { x -= 1234; }
                if (x == 0)
                { Console.Write("Yes"); }
                else { Console.Write("No"); }
            }
            else { Console.Write("No"); }
        }
    }
}

using System;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            double x;
          x= Convert.ToInt64(Console.ReadLine());
            double d = (x / 1359257);
            double d1 = (x / 1234567);
            double d2 = (x / 123456);
            double d3 = (x / 1234);
            double d4 = (x / (1234567+ 123456));
            double d5 = (x / (123456+ 1234));
            double d6 = (x / 1234+ 1234567);
            if (d == (int)d && d > 0)
            {
                Console.Write("Yes");
            }
            else if (d1 == (int)d1 && d1 > 0)
            { Console.Write("Yes"); }
            else if (d2 == (int)d2 && d2 > 0)
            { Console.Write("Yes"); }
            else if (d3 == (int)d3 && d3 > 0)
            { Console.Write("Yes"); }
            else if (d4 == (int)d4 && d4 > 0)
            { Console.Write("Yes"); }
            else if (d5 == (int)d5 && d5 > 0)
            { Console.Write("Yes"); }
            else if (d6 == (int)d6 && d6 > 0)
            { Console.Write("Yes"); }
            else if (d != (int)d && d > 1)
            {
                x = x - 1359257;
                for (; x > 0;)
                { x -= 1359257; }
                for (; x > 0;)
                { x -= 123456; }
                for (; x > 0;)
                { x -= 1234; }
                if (x == 0)
                { Console.Write("Yes"); }
                else { Console.Write("No"); }
            }
            else if (d4 != (int)d4 && d4 > 1)
            {
                x = x - 1234567;
                for (; x > 0;)
                { x -= 1234567; }
                for (; x > 0;)
                { x -= 123456; }
                if (x == 0)
                { Console.Write("Yes"); }
                else { Console.Write("No"); }
            }
            else if (d5 != (int)d5 && d5 > 1)
            {
                x = x - 123456;
                for (; x > 0;)
                { x -= 123456; }
                for (; x > 0;)
                { x -= 1234; }
                if (x == 0)
                { Console.Write("Yes"); }
                else { Console.Write("No"); }
            }
            else if (d6 != (int)d && d6 > 1)
            {
                x = x - 1234567;
                for (; x > 0;)
                { x -= 1234567; }
                for (; x > 0;)
                { x -= 1234; }
                if (x == 0)
                { Console.Write("Yes"); }
                else { Console.Write("No"); }
            }
            else { Console.Write("No"); }
        }
    }
}