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.


-----Input-----

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


-----Output-----

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).


-----Examples-----
Input
1359257

Output
YES
Input
17851817

Output
NO


-----Note-----

In 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.

Source: codeforces | Difficulty: EASY
Tags: Complete search


Solutions:
n = int(input())
for a in range(0, n + 1, 1234567):
	for b in range(0, n - a + 1, 123456):
		if (n - a - b) % 1234 == 0:
			print('YES')
			exit()
print('NO')


import math
game_score = int(input())

def verify_spent(score):
	for a in range(1000):
		for b in range(1000):
			c = (score - b * 123456 - a * 1234567) / 1234
			if c >= 0 and c - math.floor(c) == 0:
				print('YES')
				return
	print('NO')
verify_spent(game_score)


n = input()
n = int(n)
a = 1234567
b = 123456
c = 1234
flag = 0
for i in range(n // a + 1):
	for j in range((n - a * i) // b + 1):
		if (n - a * i - b * j) % c == 0:
			flag = 1
			break
	if flag == 1:
		break
if flag == 1:
	print('YES')
else:
	print('NO')


n = int(input())
a = 1234567
b = 123456
c = 1234
for i in range(n // a + 1):
	for j in range(n // b + 1):
		t = n - i * a - j * b
		if t < 0:
			break
		elif t % c == 0:
			print('YES')
			exit()
print('NO')


n = int(input())
from sys import *
l = [1234567, 123456, 1234]
m = n
j = 0
t = 1
while j * l[0] <= m and t:
	mm = m
	m -= j * l[0]
	jj = 0
	while jj * l[1] <= m and t:
		mmm = m
		m -= jj * l[1]
		if m % l[2] == 0:
			print('YES')
			t = 0
		m = mmm
		jj += 1
	m = mm
	j += 1
if t:
	print('NO')


n = int(input())
x = 1234567
y = 123456
z = 1234
if n < z:
	print('NO')
	return
else:
	a = 0
	while a * x <= n:
		b = 0
		while b * y + a * x <= n:
			if (n - (b * y + a * x)) % z == 0:
				print('YES')
				return
			b += 1
		a += 1
print('NO')


n = int(input())
x = 1234567
y = 123456
z = 1234
r = False
i = 0
while i * x <= n and (not r):
	j = 0
	while i * x + j * y <= n and (not r):
		if (n - i * x - j * y) % z == 0:
			r = True
		j += 1
	i += 1
if r:
	print('YES')
else:
	print('NO')


n = int(input())
a = b = c = 0
while a * 1234567 <= n:
	cur = a * 1234567
	b = 0
	while cur + b * 123456 <= n:
		if (n - cur - b * 123456) % 1234 == 0:
			print('YES')
			exit()
		b += 1
	a += 1
print('NO')


n = int(input())

def solve(n):
	for item in range(n // 1234567 + 1):
		for i in range(n // 123456 + 1):
			current = n - (item * 1234567 + i * 123456)
			if current < 0:
				break
			maxi = current // 1234 + 1
			low = 0
			hi = maxi
			mid = maxi // 2
			while low < hi:
				if mid * 1234 == current:
					return 'YES'
				elif mid * 1234 < current:
					low = mid + 1
				else:
					hi = mid - 1
				mid = low + (hi - low) // 2
	return 'NO'
print(solve(n))


n = int(input())
aa = 1234567
bb = 123456
cc = 1234
ans = False
a = 0
while ans is False:
	left = n - a
	if left < 0:
		break
	b = 0
	while ans is False:
		leftleft = left - b
		if leftleft < 0:
			break
		if leftleft % cc == 0:
			ans = True
			break
		b += bb
	a += aa
if ans is True:
	print('YES')
else:
	print('NO')


from sys import stdin, stdout
phouse = 1234567
pcare = 123456
pcomputer = 1234
ans = 'NO'
n = int(stdin.readline())
for i in range(n // phouse + 1):
	for j in range(n // pcare + 1):
		if n - i * phouse - j * pcare >= 0 and (not (n - i * phouse - j * pcare) % pcomputer):
			ans = 'YES'
stdout.write(ans)


n = int(input())
f = False
for a in range(n // 1234567 + 1):
	for b in range((n - a * 1234567) // 123456 + 1):
		if (n - a * 1234567 - b * 123456) % 1234 == 0:
			print('YES')
			f = True
			break
	if f:
		break
if not f:
	print('NO')


n = int(input())
for i in range(0, 1000):
	b = i * 1234567
	if b > n:
		break
	for j in range(0, n):
		if b + j * 123456 > n:
			break
		c = n - b - j * 123456
		if c % 1234 == 0:
			print('YES')
			exit()
		j += 1
print('NO')


from sys import *
n = int(input())
for a in range(n // 1234567 + 1):
	for b in range((n - a * 1234567) // 123456 + 1):
		if (n - a * 1234567 - b * 123456) % 1234 == 0:
			print('YES')
			return
print('NO')


n = int(input())
for x in range(0, n + 1, 1234567):
	for y in range(0, n - x + 1, 123456):
		if (n - x - y) % 1234 == 0:
			print('YES')
			exit()
print('NO')


n = int(input())
a = 1234567
b = 123456
c = 1234
while n >= 0:
	m = n
	while m >= 0:
		if m % c == 0:
			print('YES')
			exit()
		m -= b
	n -= a
print('NO')


n = int(input())
casa = 1234567
carro = 123456
comp = 1234
ans = False
if n % casa == 0 or n % carro == 0 or n % comp == 0:
	ans = True
else:
	for a in range(0, n + 1, casa):
		if a > n or ans:
			break
		for b in range(0, n - a + 1, carro):
			if a + b > n or ans:
				break
			elif (n - a - b) % comp == 0:
				ans = True
if ans:
	print('YES')
else:
	print('NO')


n = int(input())
a = 1234567
b = 123456
c = 1234
nat = 'NO'
for i in range(n // a + 1):
	n2 = n - a * i
	for i2 in range(n2 // b + 1):
		if (n2 - b * i2) % c == 0:
			nat = 'YES'
print(nat)


def main():
	n = int(input())
	p = funct(n)
	if p == 1:
		print('YES')
	else:
		print('NO')

def funct(n):
	a = 0
	while a <= n:
		b = 0
		while b <= n - a:
			if (n - a - b) % 1234 == 0:
				return 1
			else:
				b += 123456
		a += 1234567
	return 0
main()


n = int(input())
a = 0
ok = True
while n - 1234567 * a >= 0 and ok:
	b = 0
	while n - 1234567 * a - 123456 * b >= 0 and ok:
		if (n - 1234567 * a - 123456 * b) % 1234 == 0:
			ok = False
		b += 1
	a += 1
if ok:
	print('NO')
else:
	print('YES')


w = int(input())
house = 1234567
car = 123456
comp = 1234
q = False
b = 0
c = 0
while c <= w // comp and q == False and (w >= comp):
	while b <= w // car and q == False and (w >= car):
		if (w - c * comp - b * car) % house == 0 and w - c * comp - b * car >= 0:
			q = True
			break
		b += 1
	if (w - c * comp - b * car) % house == 0 and w - c * comp - b * car >= 0:
		q = True
		break
	c += 1
	b = 0
if q == True:
	print('YES')
else:
	print('NO')


su = int(input())
a = 0
b = 0
c = 0
amax = su // 1234567
bmax = su // 123456
for a in range(amax + 1):
	if c > 0 or su - a * 1234567 < 0:
		break
	for b in range(bmax + 1):
		if su - (a * 1234567 + b * 123456) < 0:
			break
		if (su - (a * 1234567 + b * 123456)) % 1234 == 0:
			c += 1
			break
if c > 0:
	print('YES')
else:
	print('NO')


import math

def find(x):
	for i in range(1000):
		for j in range(1000):
			value = (x - j * 123456 - i * 1234567) / 1234
			if value >= 0 and value - math.floor(value) == 0:
				print('YES')
				return
	print('NO')
find(int(input()))


def do2():
	n = int(input())
	house_price = 1234567
	car_price = 123456
	pc_price = 1234
	for i in range(0, n // house_price + 1):
		a = i * house_price
		for j in range(0, n // car_price + 1):
			b = j * car_price
			if (n - a - b) % pc_price == 0 and n - a - b >= 0:
				print('YES')
				return
	print('NO')
	return
do2()


n = int(input())
for nombre in range(0, n + 1, 1234567):
	for nombre2 in range(0, n + 1, 123456):
		reste = (n - nombre - nombre2) % 1234
		diviseur = (n - nombre - nombre2) // 1234
		if diviseur >= 0 and reste == 0:
			print('YES')
			exit(0)
print('NO')


import sys

def __starting_point():
	n = int(input())
	for i in range(n // 1234567 + 1):
		cur = n - i * 1234567
		for j in range(cur // 123456 + 1):
			if (cur - j * 123456) % 1234 == 0:
				print('YES')
				return
	print('NO')
__starting_point()


import sys
n = int(input())
for i in range(n // 1234567 + 1):
	cur = n - i * 1234567
	for j in range(cur // 123456 + 1):
		if (cur - j * 123456) % 1234 == 0:
			print('YES')
			sys.exit(0)
print('NO')


n = int(input())
for i in range(n // 1234567 + 1):
	for j in range(n // 123456 + 1):
		t = n - i * 1234567 - j * 123456
		if t >= 0 and t % 1234 == 0:
			print('YES')
			exit()
print('NO')


x = int(input())
k = 0
suma = 0
casa = 1234567
carro = 123456
computadora = 1234
mensaje = 'NO'
while x >= computadora:
	a = x
	b = x
	c = x
	d = x
	e = x
	f = x
	if x >= casa:
		if x % casa == 0 or x % computadora == 0 or x % carro == 0:
			mensaje = 'YES'
			x = computadora - 1
		if x % casa == 0:
			mensaje = 'YES'
			x = computadora - 1
		if x % computadora == 0 or x % carro == 0:
			mensaje = 'YES'
			x = computadora - 1
		x = x - casa
	if x >= carro and x < casa:
		if x % carro == 0:
			mensaje = 'YES'
			x = computadora - 1
		if x % computadora == 0:
			mensaje = 'YES'
			x = computadora - 1
		x = x - carro
	if x >= computadora and x < carro:
		x = x - computadora
		if x % computadora == 0:
			mensaje = 'YES'
			x = computadora - 1
	while (a and b) >= computadora:
		a = a - computadora
		b = b - carro
		if (a % casa == 0 or b % casa == 0) and (a and b) > 0:
			mensaje = 'YES'
			x = computadora - 1
			a = computadora - 1
		if ((a - carro) % casa == 0 or (b - computadora) % casa == 0) and (a - carro and b - computadora) > 0:
			mensaje = 'YES'
			x = computadora - 1
			a = computadora - 1
	while (c and d) >= computadora:
		c = c - computadora
		d = d - casa
		if (c % carro == 0 or d % carro == 0) and (c and d) > 0:
			mensaje = 'YES'
			x = computadora - 1
			c = computadora - 1
		if ((c - casa) % carro == 0 or (d - computadora) % carro == 0) and (c - casa and d - computadora) > 0:
			mensaje = 'YES'
			x = computadora - 1
			c = computadora - 1
	while (e and f) >= computadora:
		e = e - casa
		f = f - carro
		if (e % computadora == 0 or f % computadora == 0) and (e and f) > 0:
			mensaje = 'YES'
			x = computadora - 1
			e = computadora - 1
		if ((e - carro) % computadora == 0 or (f - casa) % computadora == 0) and (e - carro and f - casa) > 0:
			mensaje = 'YES'
			x = computadora - 1
			e = computadora - 1
print(mensaje)


x = int(input())
o = [1234567, 123456, 1234]
c = 1
t = x

def ok():
	global c
	c = 0

def test(g):
	for p in range(3):
		if g % o[p] == 0 and g >= 0:
			ok()
			break
if c != 0:
	for i in range(int(x / 1234567) + 1):
		if c == 0:
			break
		temp = 1234567 * i
		test(x - temp)
		for p in range(i * 11):
			if c == 0:
				break
			test(x - p * 123456 - temp)
if c != 0:
	for i in range(int(x / 1234567) + 1):
		if c == 0:
			break
		temp = 1234567 * i
		test(x - temp)
		for p in range(i * 1001):
			if c == 0:
				break
			test(x - p * 1234 - temp)
if c != 0:
	for i in range(int(x / 123456) + 1):
		if c == 0:
			break
		temp = 123456 * i
		test(x - temp)
if c == 0:
	print('YES')
else:
	print('NO')


n = int(input())
if n < 1234:
	print('NO')
else:
	f = 0
	for i in range(10000):
		for j in range(10000):
			if i * 1234567 + j * 123456 <= n:
				if (n - (i * 1234567 + j * 123456)) % 1234 == 0:
					print('YES')
					f = 1
					break
			else:
				break
		if f == 1:
			break
	if f == 0:
		print('NO')


__author__ = 'aste'

def solve(n):
	max_a = n // 1234567
	a = 0
	while a <= max_a:
		b = 0
		max_b = (n - 1234567 * a) // 123456
		while b <= max_b:
			c = n - 1234567 * a - 123456 * b
			if c >= 0 and c % 1234 == 0:
				return True
			b += 1
		a += 1
	return False

def main():
	n = int(input())
	print(solve(n) and 'YES' or 'NO')
main()


n = int(input())
ans = n
a = 1234567
b = 123456
c = 1234
ch = True
count_a = n // a
count_b = n // b
count_c = n // c
for i in range(count_a + 1):
	n = ans
	n = n - i * a
	ans2 = n
	for j in range(count_b + 1):
		n = ans2
		n = n - j * b
		if n < 0:
			break
		elif n % c == 0:
			print('YES')
			ch = False
			break
	if not ch:
		break
if ch:
	print('NO')


n = int(input())
for i in range(0, n + 1, 1234567):
	for j in range(0, n - i + 1, 123456):
		if (n - i - j) % 1234 == 0:
			print('YES')
			quit()
print('NO')


from math import gcd
from sys import exit
N = int(input())
x = 1234567
y = 123456
z = 1234
g = gcd(y, z)
if N % x == 0:
	print('YES')
	exit()
for a in range(N // x + 1):
	n = N - a * x
	if n % y == 0 or n % z == 0:
		print('YES')
		exit()
	if n % g != 0:
		continue
	x0 = -22 * n // 2
	y0 = 2201 * n // 2
	k = -x0 // (z // 2) + 1
	x0 += k * z // 2
	y0 -= k * y // 2
	if y0 >= 0:
		print('YES')
		exit()
print('NO')


nn = int(input())
for a in range(0, nn + 1, 1234567):
	for b in range(0, nn - a + 1, 123456):
		if (nn - a - b) % 1234 == 0:
			print('Yes')
			exit()
print('No')


n = int(input())

def solve(n):
	(x, y, z) = (1234567, 123456, 1234)
	for i in range(0, n + 1, x):
		for j in range(0, n - i + 1, y):
			v = n - i - j
			if v >= 0 and v % z == 0:
				return 'YES'
	return 'NO'
print(solve(n))


coin = int(input())
ans = 'NO'
a = coin // 1234567
for x in range(a, -1, -1):
	b = (coin - x * 1234567) // 123456
	for y in range(b, -1, -1):
		z = (coin - x * 1234567 - y * 123456) // 1234
		if x * 1234567 + y * 123456 + z * 1234 == coin:
			ans = 'YES'
			break
		if ans == 'YES':
			break
	if ans == 'YES':
		break
print(ans)


n = int(input())
(i, j) = (0, 0)
while i * 1234567 <= n:
	while i * 1234567 + j * 123456 <= n:
		if (n - i * 1234567 - j * 123456) % 1234 == 0:
			print('YES')
			exit()
		j += 1
	j = 0
	i += 1
print('NO')


n = int(input())
y = False
for i in range(n // 1234567 + 2):
	for j in range((n - 1234567 * i) // 123456 + 2):
		a = n - i * 1234567 - j * 123456
		if a >= 0 and a % 1234 == 0:
			y = True
			break
if y:
	print('YES')
else:
	print('NO')


from collections import defaultdict
import sys
import math

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def minput():
	return map(int, input().split())

def listinput():
	return list(map(int, input().split()))
n = iinput()
answer = 0
for i in range(n // 1234567 + 1):
	for j in range((n - i * 1234567) // 123456 + 1):
		if (n - i * 1234567 - j * 123456) % 1234 == 0:
			answer = 1
			break
	if answer:
		break
if answer:
	print('YES')
else:
	print('NO')


3

def main():
	n = int(input())
	ans = False
	for a in range(0, 1001):
		for b in range(0, 1001):
			left = n - 1234567 * a - 123456 * b
			if left >= 0 and left % 1234 == 0:
				ans = True
	print('YES' if ans else 'NO')
main()


def thefunction():
	if n % 1234567 == 0:
		print('YES')
		return
	else:
		bigones = n // 1234567
		while bigones >= 0:
			leftover = n - bigones * 1234567
			if leftover % 123456 == 0:
				print('YES')
				return
			else:
				middleones = leftover // 123456
				while middleones >= 0:
					secondleftover = leftover - middleones * 123456
					if secondleftover % 1234 == 0:
						print('YES')
						return
					else:
						middleones -= 1
			bigones -= 1
		print('NO')
n = int(input())
thefunction()


n = int(input())
x = 1234567
y = 123456
z = 1234
for a in range(811):
	if a * x > n:
		break
	for b in range(8111):
		if a * x + b * y > n:
			break
		c = (n - a * x - b * y) // z
		if a * x + b * y + c * z == n:
			print('YES')
			exit()
print('NO')


n = int(input())
for i in range(n // 1234567 + 1):
	ii = n - i * 1234567
	if ii == 0:
		print('YES')
		return
	for j in range(ii // 123456 + 1):
		jj = ii - j * 123456
		if jj == 0:
			print('YES')
			return
		if jj % 1234 == 0:
			print('YES')
			return
print('NO')


n = int(input())
(a, b, c) = (1234567, 123456, 1234)
ak = n // a + 1
ans = 0
for i in range(ak):
	num1 = i * a
	bk = (n - num1) // b + 1
	for j in range(bk):
		if (n - num1 - j * b) % c == 0:
			ans += 1
			break
if ans > 0:
	print('YES')
else:
	print('NO')


n = int(input())
x = 1234567
y = 123456
z = 1234
aRange = int(n / x)
yes = False
for a in range(aRange + 1):
	bRange = int((n - a * x) / y)
	for b in range(bRange + 1):
		if (n - a * x - b * y) % z == 0:
			yes = True
			break
if yes:
	print('YES')
else:
	print('NO')


n1 = int(input())
a = int(n1 / 1234567)
b = int(n1 / 123456)
t = 0
resultado = 0
for x in range(0, a + 1):
	for i in range(0, b + 1):
		resultado = n1 - (1234567 * x + 123456 * i)
		if resultado % 1234 == 0 and resultado >= 0:
			print('YES')
			t = 1
			break
	if t == 1:
		break
if t == 0:
	print('NO')


def cj():
	n = int(input())
	for i in range(int(n / 1234567) + 1):
		a = i * 1234567
		for j in range(int((n - a) / 123456 + 1)):
			b = j * 123456
			if (n - a - b) % 1234 == 0:
				return 'YES'
	return 'NO'
print(cj())


n = int(input())
for a in range(n):
	if a * 1234567 > n:
		break
	for b in range(n):
		if a * 1234567 + b * 123456 > n:
			break
		if (n - a * 1234567 - b * 123456) % 1234 == 0:
			print('Yes')
			exit()
print('No')


import sys, bisect
from sys import stdin, stdout
from bisect import bisect_left, bisect_right, bisect, insort, insort_left, insort_right
from math import gcd, ceil, floor, sqrt
from collections import Counter, defaultdict, deque, OrderedDict
from queue import Queue, PriorityQueue
from string import ascii_lowercase
from heapq import *
from itertools import islice
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 998244353
mod = 10 ** 9 + 7

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	for i in range(5, ceil(sqrt(n)) + 1, 6):
		if n % i == 0 or n % (i + 2) == 0:
			return False
	return True

def st():
	return list(stdin.readline().strip())

def inp():
	return int(stdin.readline())

def li():
	return list(map(int, stdin.readline().split()))

def mp():
	return map(int, stdin.readline().split())

def pr(n):
	stdout.write(str(n) + '\n')

def DFS(dictionary, vertex, visited):
	visited[vertex] = True
	stack = [vertex]
	print(vertex)
	while stack:
		a = stack.pop()
		for i in dictionary[a]:
			if not visited[i]:
				print(i)
				visited[i] = True
				stack.append(i)

def BFS(dictionary, vertex, visited):
	visited[vertex] = True
	q = deque()
	q.append(vertex)
	while q:
		a = q.popleft()
		for i in dictionary[a]:
			if not visited[i]:
				visited[i] = True
				q.append(i)
				print(i)

def soe(limit):
	l = [1] * (limit + 1)
	l[0] = 0
	l[1] = 0
	prime = []
	for i in range(2, limit + 1):
		if l[i]:
			for j in range(i * i, limit + 1, i):
				l[j] = 0
	for i in range(2, limit + 1):
		if l[i]:
			prime.append(i)
	return prime

def segsoe(low, high):
	limit = int(high ** 0.5) + 1
	prime = soe(limit)
	n = high - low + 1
	l = [0] * (n + 1)
	for i in range(len(prime)):
		lowlimit = low // prime[i] * prime[i]
		if lowlimit < low:
			lowlimit += prime[i]
		if lowlimit == prime[i]:
			lowlimit += prime[i]
		for j in range(lowlimit, high + 1, prime[i]):
			l[j - low] = 1
	for i in range(low, high + 1):
		if not l[i - low]:
			if i != 1:
				print(i)

def gcd(a, b):
	while b:
		a = a % b
		(b, a) = (a, b)
	return a

def power(a, n):
	r = 1
	while n:
		if n & 1:
			r = r * a
		a *= a
		n = n >> 1
	return r

def don(d, ans, vi, i):
	vi[i] = True
	stack = [i]
	while stack:
		a = stack.pop()
		for x in d[a]:
			if not vi[x]:
				ans[i] += 1
				vi[x] = True
				stack.append(x)

def solve():
	n = inp()
	a = 1234567
	b = 123456
	c = 1234
	for i in range(n // a + 1):
		for j in range(n // b + 1):
			if n - (i * a + b * j) >= 0 and (n - (i * a + b * j)) % c == 0:
				pr('YES')
				return
	pr('NO')
for _ in range(1):
	solve()


def get_ints():
	return list(map(int, input().split()))

def main():
	(ea, eb, ec) = (1234567, 123456, 1234)
	n = int(input())
	ma = n // ea
	for a in range(ma + 1):
		tn = n - a * ea
		mb = tn // eb
		for b in range(mb + 1):
			r = tn - b * eb
			if r % ec == 0:
				print('YES')
				return
	print('NO')
main()


n = int(input())
a = [1234567 * i for i in range(n // 1234567 + 1)]
b = [123456 * i for i in range(n // 123456 + 1)]
c = {1234 * i for i in range(n // 1234 + 1)}
for i in a:
	num = n - i
	for j in b:
		num1 = num - j
		if num1 < 0:
			break
		if num1 in c:
			print('YES')
			exit()
print('NO')


n = int(input())
for i in range((n - 1234567 if n & 1 else n) // 2, -1, -1234567):
	for j in range(i, -1, -61728):
		if not j % 617:
			print('YES')
			exit(0)
print('NO')


n = int(input())
a = 1234567
b = 123456
c = 1234
for i in range((n + 2) // a + 2):
	left = n - i * a
	for j in range((left + 2) // b + 2):
		if left - j * b >= 0 and (left - j * b) % c == 0:
			print('YES')
			exit()
print('NO')


n = int(input())
A = 1234567
B = 123456
C = 1234
for a in range(int(n / A) + 1):
	for b in range(int(n / B) + 1):
		r = n - a * A - b * B
		if r >= 0 and r % C == 0:
			print('YES')
			exit(0)
print('NO')


def main():
	n = int(input())
	for i in range((n - 1234567 if n & 1 else n) // 2, -1, -1234567):
		for j in range(i, -1, -61728):
			if not j % 617:
				print('YES')
				return
	print('NO')
main()


n = int(input())
for a in range(2000):
	for b in range((n - 1234567 * a) // 123456 + 50):
		rem = n - 1234567 * a - 123456 * b
		if rem % 1234 == 0 and rem // 1234 >= 0:
			print('YES')
			quit()
print('NO')


n = int(input())
a = 0
c = 0
while a * 1234567 <= n:
	b = 0
	v = a * 1234567
	while a * 1234567 + b * 123456 <= n:
		if (n - v - b * 123456) % 1234 == 0:
			print('YES')
			c = 1
			break
		b = b + 1
	a = a + 1
	if c == 1:
		break
if c == 0:
	print('NO')
l = 0


n = int(input())
i = 0
while i <= n:
	k = n - i
	for j in range(k // 123456 + 1):
		k2 = k - j * 123456
		if k2 % 1234 == 0:
			print('YES')
			exit()
	i += 1234567
print('NO')


while True:
	try:
		num = int(input())
		k = 0
		for a in range(num // 1234567 + 1):
			if k == 0:
				for b in range((num - a * 1234567) // 123456 + 1):
					if (num - a * 1234567 - b * 123456) % 1234 == 0:
						k += 1
						break
		if k == 1:
			print('YES')
		else:
			print('NO')
	except:
		break


n = int(input())
(x, y, z) = (1234567, 123456, 1234)
a_max = n // x
b_max = n // y

def do_it():
	for a in range(a_max + 1):
		for b in range(b_max + 1):
			if a * x + b * y > n:
				break
			if (n - (a * x + b * y)) % z == 0:
				print('YES')
				return
	print('NO')
do_it()


n = int(input())
a = 1234567
b = 123456
c = 1234
for i in range(0, n // a + 2):
	d = i * a - b
	for j in range(0, n // b + 2):
		d += b
		if d > n:
			break
		if (n - d) % c == 0:
			print('YES')
			exit(0)
print('NO')


def can_spend(n):
	a = 1234567
	b = 123456
	c = 1234
	values = set()
	values.add(a)
	values.add(b)
	values.add(c)
	values.add(0)
	init = n // a
	while init >= 0:
		current = n - init * a
		if current % a in values or current % b in values or current % c in values:
			return 'YES'
		init_b = current // b
		while init_b >= 0:
			current_b = current - init_b * b
			if current_b % b in values or current_b % c in values:
				return 'YES'
			init_b -= 1
		init -= 1
	return 'NO'
n = int(input())
print(can_spend(n))


s = int(input())
n = 0
l = []
for i in range(0, s, 1234567):
	for j in range(0, s, 123456):
		n = s - i - j
		l.append(n)
if any((i >= 0 and i % 1234 == 0 for i in l)):
	print('YES')
elif s % 1234567 == 0 or s % 123456 == 0 or s % 1234 == 0:
	print('YES')
else:
	print('NO')


success = False
n = int(input())
aa = n // 1234567 + 1
a = n % 2
while a <= aa:
	nn = n - 1234567 * a
	for b in range(nn // 123456 + 1):
		if (nn - 123456 * b) % 1234 == 0:
			success = True
	a += 2
if success:
	print('YES')
else:
	print('NO')


import sys
n = int(input())
i = 0
while n - i * 1234567 >= 0:
	z = n - i * 1234567
	j = 0
	while z - j * 123456 >= 0:
		k = z - j * 123456
		if k % 1234 == 0:
			print('YES')
			sys.exit()
		j += 1
	i += 1
print('NO')


n = int(input())
x = 1234567
y = 123456
z = 1234
for a in range(900):
	if a * x > n:
		break
	for b in range(9000):
		if a * x + b * y > n:
			break
		c = (n - a * x - b * y) // z
		if a * x + b * y + c * z == n:
			print('YES')
			exit()
print('NO')


import os
import sys
from io import BytesIO, IOBase
mod = 10 ** 9 + 7

def main():
	n = int(input())
	for a in range(n // 1234567 + 1):
		for b in range(n // 123456 + 1):
			temp = n - a * 1234567 - b * 123456
			if temp < 0:
				break
			elif temp % 1234 == 0:
				print('YES')
				exit()
	print('NO')

def nouse0():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse1():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse2():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def nouse3():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse4():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse5():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')
main()


initial_score = int(input())
bug = True
paro = False
for a in range(1000):
	for b in range(10000):
		t = initial_score - a * 1234567 - b * 123456
		if t >= 0 and t % 1234 == 0:
			print('YES')
			bug = False
			paro = True
			break
	if paro:
		break
if bug:
	print('NO')


import os
import sys

def main():
	pass

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def lts(l):
	s = ''.join(map(str, l))
	return s

def stl(s):
	l = list(s)
	return l

def sq(a, target, arr=[]):
	s = sum(arr)
	if s == target:
		return arr
	if s >= target:
		return
	for i in range(len(a)):
		n = a[i]
		remaining = a[i + 1:]
		ans = sq(remaining, target, arr + [n])
		if ans:
			return ans

def SieveOfEratosthenes(n):
	cnt = 0
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			cnt += 1
	return cnt

def nCr(n, r):
	f = math.factorial
	return f(n) // f(r) // f(n - r)
mod = int(1000000000.0) + 7

def ssinp():
	return input()

def iinp():
	return int(input())

def nninp():
	return map(int, input().split())

def llinp():
	return list(map(int, input().split()))

def p(xyz):
	print(xyz)

def p2(a, b):
	print(a, b)
import math
from collections import OrderedDict
n = iinp()
x = 1234567
y = 123456
z = 1234
for a in range(0, math.ceil(n / x) + 5):
	s = a * x
	for b in range(0, math.ceil(n / y) + 5):
		temp = s + b * y
		if (n - temp) / z % 1 == 0 and (n - temp) / z >= 0:
			print('YES')
			exit()
print('NO')


n = int(input())
(i, t) = [0, 0]
(a, b) = [1234567, 123456]
while a * i <= n:
	j = 0
	while b * j + a * i <= n:
		if (n - a * i - b * j) % 1234 == 0:
			t = 1
			break
		j += 1
	i += 1
	if t:
		break
if t:
	print('YES', end='')
else:
	print('NO', end='')


n = int(input())
flag = 0
i = 0
(h, c, p) = (1234567, 123456, 1234)
while i * h <= n:
	j = 0
	while j * c <= n - i * h:
		if (n - i * h - j * c) % p == 0:
			flag = 1
			break
		j += 1
	if flag == 1:
		break
	i += 1
if flag:
	print('YES')
else:
	print('NO')


n = int(input())
i = 0
changed = True
found = False
while changed:
	j = 0
	changed = False
	while i * 1234567 + j * 123456 <= n:
		s = i * 1234567 + j * 123456
		if s == n or (n - s) % 1234 == 0:
			found = True
			changed = False
			break
		changed = True
		j += 1
	i += 1
print('YES' if found else 'NO')


n = int(input())
x = 1234567
y = 123456
z = 1234
for i in range(0, n):
	if i * x > n:
		break
	m = n - x * i
	for j in range(0, n):
		if j * y > m:
			break
		l = m - y * j
		if l % 1234 == 0:
			print('YES')
			exit(0)
print('NO')


n = int(input())
ok = 0
for a in range(1001):
	for b in range(1001):
		if n - 1234567 * a - 123456 * b >= 0 and (n - 1234567 * a - 123456 * b) % 1234 == 0:
			ok = 1
print('YES') if ok else print('NO')


from sys import stdin

def rb(num):
	quo = int(num / 123456)
	for i in range(quo + 1):
		if num % 1234 == 0:
			return True
		num -= 123456
	return False

def ra(num):
	quo = int(num / 1234567)
	for i in range(quo + 1):
		success = rb(num)
		if success:
			return True
		num -= 1234567
	return False

def solve(num):
	success = ra(num)
	if success:
		print('YES')
	else:
		print('NO')

def parse():
	N = int(stdin.readline().strip())
	solve(N)
parse()


def main():
	n = int(input())
	x = 1234567
	y = 123456
	z = 1234
	for a in range(1000):
		for b in range(10000):
			c = (n - a * x - b * y) // z
			if c < -100:
				break
			if c >= 0 and a * x + b * y + c * z == n:
				print('YES')
				exit()
	print('NO')
main()


import sys
(a, b, c) = (1234567, 123456, 1234)
n = int(input())
for aq in range(int(n // a) + 3):
	nn = n - a * aq
	if nn < 0:
		break
	for bq in range(int(nn // b) + 3):
		nnn = nn - b * bq
		if nnn < 0:
			continue
		if nnn % c == 0:
			print('YES')
			return
print('NO')


import math, sys
n = int(input())
x = math.ceil(n / 1234567)
y = math.ceil(n / 123456)
houses = 0
while houses <= x:
	cars = 0
	while cars <= y:
		nComputers = n - houses * 1234567 - cars * 123456
		if nComputers < 0:
			break
		result = nComputers % 1234
		if result == 0:
			print('YES')
			sys.exit()
		cars += 1
	houses += 1
print('NO')


HOUSE = 1234567
CAR = 123456
COMP = 1234
n = int(input())
answer = 'NO'
for h in range(n // HOUSE + 1):
	rest = n - h * HOUSE
	for c in range(rest // CAR + 1):
		rest2 = rest - c * CAR
		if rest2 % COMP == 0:
			answer = 'YES'
			break
print(answer)


n = int(input())
at_best = 1000
for i in range(0, at_best):
	for j in range(0, at_best):
		current = i * 1234567 + j * 123456
		remain = n - current
		if n % 1234 == 0 or current == n or (remain % 1234 == 0 and remain > 0):
			print('YES')
			quit()
print('NO')


n = int(input())
ok = False
i = 0
while i * 1234567 <= n:
	j = 0
	while i * 1234567 + j * 123456 <= n:
		x = i * 1234567 + j * 123456
		if (n - x) % 1234 == 0:
			ok = True
			break
		j += 1
	if ok:
		break
	i += 1
print('YES' if ok else 'NO')


n = int(input())
ans = False
for i in range(n // 1234567 + 1):
	broken = False
	for j in range((n - i * 1234567) // 123456 + 1):
		if (n - i * 1234567 - j * 123456) % 1234 == 0:
			ans = True
			broken = True
			break
	if broken:
		break
if ans:
	print('YES')
else:
	print('NO')


def p1():
	n = int(input())
	for i in range(0, n + 1, 1234567):
		for j in range(0, n - i + 1, 123456):
			if (n - i - j) % 1234 == 0:
				return 'YES'
	return 'NO'

def p2():
	(n, m) = [int(i) for i in input().split()]
	l = [int(i) for i in input().split()]
	for i in range(n):
		if m - i - 1 <= 0:
			return l[m - 1]
		m = m - i - 1

def p3():
	n = int(input())
	b = n // 7 * 2 + min(2, n % 7)
	a = n // 7 * 2
	if n == n // 7 * 7 + 6:
		a = a + 1
	print(a, b)
print(p1())


from collections import defaultdict, deque, Counter, OrderedDict
from bisect import insort, bisect_right, bisect_left
import threading, sys

def main():
	n = int(input())
	a = 1234567
	b = 123456
	c = 1234
	if n % 2 != 0:
		n -= a
		if n < 0:
			print('NO')
			return
	for i in range(0, 1000):
		now = a * i
		toc = n - now
		if toc < 0:
			print('NO')
			return
		j = 0
		while j * b <= toc:
			if (toc - j * b) % c == 0:
				print('YES')
				return
			j += 1

def __starting_point():
	thread = threading.Thread(target=main)
	thread.start()
__starting_point()


x = int(input())
flag = 0
for i in range(0, 100):
	for j in range(0, 1000):
		if (x - 1234567 * i - 123456 * j) % 1234 == 0:
			if flag == 0 and x - 1234567 * i - 123456 * j >= 0:
				print('YES')
				flag = 1
				break
if flag == 0:
	print('NO')


n = int(input())

def tre(n):
	if n % 1234 == 0:
		return True
	return False

def dva(n):
	if n % 123456 == 0:
		return True
	else:
		k = n // 123456
		nn = n - k * 123456
		for i in range(k, -1, -1):
			if tre(nn):
				return True
			nn += 123456
		return False

def one(n):
	if n % 1234567 == 0:
		return True
	else:
		kk = n // 1234567
		nnn = n - kk * 1234567
		for i in range(kk, -1, -1):
			if dva(nnn):
				return True
			nnn += 1234567
		return False
if n < 1234:
	print('NO')
elif n < 123456:
	if tre(n):
		print('YES')
	else:
		print('NO')
elif n < 1234567:
	if dva(n):
		print('YES')
	else:
		print('NO')
elif one(n):
	print('YES')
else:
	print('NO')


n = int(input())
yes = 0
breaker = 0
for a in range(n // 1234567 + 1):
	for b in range((n - a * 1234567) // 123456 + 1):
		y = 1234567 * a + 123456 * b
		if (n - y) % 1234 == 0:
			yes = 1
			print('YES')
			breaker = 1
			break
	if breaker == 1:
		break
if yes == 0:
	print('NO')


def economic_game(n):
	outer = 1234567
	inner = 123456
	c = 1234
	for x in range(0, n + 1, outer):
		for y in range(0, n + 1 - x, inner):
			if (n - (x + y)) % c == 0:
				return 'YES'
	return 'NO'
print(economic_game(int(input())))


n = int(input())
for i in range(900):
	for j in range(900):
		cur = n - 1234567 * i - 123456 * j
		if cur >= 0 and cur % 1234 == 0:
			print('YES')
			exit(0)
print('NO')


n = int(input())
maxA = int(n / 1234567)
maxB = int(n / 123456)

def check(n, maxA, maxB):
	for a in range(0, maxA + 1):
		for b in range(0, maxB + 1):
			target = n - a * 1234567 - b * 123456
			if target >= 0 and target % 1234 == 0:
				return 1
	return 2
if check(n, maxA, maxB) == 1:
	print('YES')
else:
	print('NO')


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
from decimal import *
BUFSIZE = 8192
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	n = int(input())
	for i in range(0, n // 1234567 + 1):
		for j in range(0, (n - i * 1234567) // 123456 + 1):
			t = n - i * 1234567 - j * 123456
			if t % 1234 == 0:
				print('YES')
				return
	print('NO')
main()


a = 1234567
b = 123456
c = 1234
n = int(input())
for ia in range(n // a + 1):
	for ib in range((n - ia * a) // b + 1):
		r = n - ia * a - ib * b
		if r % c == 0:
			print('YES')
			exit()
print('NO')


import sys
input = sys.stdin.buffer.readline
import os
from math import *
n = int(input())
z = 0
for i in range(n // 1234567 + 1):
	for j in range((n - i * 1234567) // 123456 + 1):
		var = n - i * 1234567 - j * 123456
		if var >= 0 and var % 1234 == 0:
			z = 1
			break
	if z == 1:
		break
if z == 1:
	print('YES')
else:
	print('NO')


n = int(input())
X = 1234567
Y = 123456
Z = 1234
li = n // X
flag = 0
for i in range(li + 1):
	lj = (n - X * i) // Y
	if flag == 1:
		break
	for j in range(lj + 1):
		if (n - i * X - j * Y) % Z == 0:
			flag = 1
			break
if flag == 1:
	print('YES')
else:
	print('NO')


n = int(input())
a = 1234567
b = 123456
c = 1234
x = n // a
for i in range(x + 1):
	xx = n - i * a
	y = xx // b
	for j in range(y + 1):
		z = n - (a * i + j * b)
		if z % c == 0:
			print('YES')
			exit()
print('NO')


import sys
import math
import bisect

def solve(n1):
	a = 1234567
	b = 123456
	for i in range(n1 // a + 1):
		n2 = n1 - a * i
		for j in range(n2 // b + 1):
			n3 = n2 - b * j
			if n3 % 1234 == 0:
				return True
	return False

def main():
	n = int(input())
	if solve(n):
		print('YES')
	else:
		print('NO')
main()


(n, k) = (int(input()), True)
for i in range(0, n + 1, 1234567):
	for j in range(0, n - i + 1, 123456):
		if (n - i - j) % 1234 == 0:
			print('YES')
			k = False
			break
	if not k:
		break
if k:
	print('NO')


moedas = int(input())
for i in range(810):
	for j in range(8100):
		aux = i * 1234567
		aux += j * 123456
		if aux > moedas:
			break
		aux = moedas - aux
		if aux % 1234 == 0:
			print('YES')
			exit(0)
print('NO')


n = int(input())
a = n // 1234567
results = 'NO'
for x in range(a + 1):
	p = n - 1234567 * x
	b = p // 123456
	for y in range(b + 1):
		q = p - 123456 * y
		if q % 1234 == 0:
			results = 'YES'
			break
	if results == 'YES':
		break
print(results)


IL = lambda : list(map(int, input().split()))
IS = lambda : input().split()
I = lambda : int(input())
S = lambda : input()
n = I()
prices = [1234567, 123456, 1234]
ans = False
for p1 in range(0, n + 1, prices[0]):
	for p2 in range(0, n - p1 + 1, prices[1]):
		if (n - p1 - p2) % prices[2] == 0:
			ans = True
			break
print('YES' if ans else 'NO')


import sys
import random

def test():
	for i in range(100):
		(a, b, c) = [random.randint(1, 20) for _ in range(3)]
		k = 1234567 * a + 123456 * b + 1234 * c
		assert k <= 1000000000.0
		assert solve(k) == 'YES'

def solve(n):
	for i in range(811):
		for j in range(8111):
			k = 1234567 * i + 123456 * j
			if k > n:
				break
			elif (k - n) % 1234 == 0:
				return 'YES'
	return 'NO'
n = int(input())
print(solve(n))


n = int(input())
p = 0
from math import ceil
if n == 17851817:
	print('NO')
else:
	for a in range(0, ceil(n / 1234567) + 4):
		for b in range(0, ceil(n / 123456) + 4):
			c = n - a * 1234567 - b * 123456
			if c >= 0 and c % 1234 == 0:
				p = 1
			if p == 1:
				break
		if p == 1:
			break
	if p == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
br = False
for a in range(0, n + 1, 1234567):
	for b in range(0, n - a + 1, 123456):
		if (n - a - b) % 1234 == 0:
			print('YES')
			br = True
			break
	if br:
		break
else:
	print('NO')


num = int(input())
a = 0
b = 0
c = 0
q = [0, 0]
kr = [0, 0, 0, 0]
output = False

def sum0():
	s = a * 1234567
	return s

def sum1():
	s = a * 1234567 + b * 123456
	return s

def sum2():
	s = a * 1234567 + b * 123456 + c * 1234
	return s
q[0] = int(num / 1234567)
if num % 1234567 == 0:
	output = True
if num % 123456 == 0:
	output = True
if num % 1234 == 0:
	output = True
while a <= q[0]:
	q[1] = int((num - sum0()) / 123456)
	while b <= q[1]:
		c = int((num - sum1()) / 1234)
		d = int((num - sum2()) / 56)
		if (num - sum2()) % 56 == 0 and d <= c / 100:
			output = True
			break
		else:
			b += d
		c = 0
		b += 1
	if output == True:
		break
	b = 0
	a += 1
if output == True:
	print('YES')
else:
	print('NO')


n = int(input())
a = 1234567
b = 123456
c = 1234

def ab(num):
	while num >= 0:
		if num % c == 0:
			return True
		num -= b
	return False

def abc(num):
	while num >= 0:
		if ab(num):
			return True
		num -= a
	return False
print('YES' if abc(n) else 'NO')


import sys
n = int(input())
a = 1234567
b = 123456
c = 1234
da = {0}
db = {0}
dc = {0}
try:
	for i in range(812):
		for j in range(8102):
			if n - a * i - b * j < 0:
				break
			if (n - a * i - b * j) % c == 0:
				sys.exit(0)
	print('NO')
except:
	print('YES')


import sys
import math
a = int(input())
for i in range(0, a // 1234567 + 1):
	for j in range(0, (a - i * 1234567) // 123456 + 1):
		if (a - i * 1234567 - j * 123456) % 1234 == 0:
			print('YES')
			sys.exit(0)
print('NO')


n = int(input())
sol = False
for i in range(max(n // 1234567 + 1, 1)):
	n2 = n - i * 1234567
	for j in range(max(n2 // 123456 + 1, 1)):
		n3 = n2 - j * 123456
		if n3 % 1234 == 0:
			sol = True
			break
print(['NO', 'YES'][sol])


def isPossible(num):
	for a in range(812):
		for b in range(8102):
			aux = a * 1234567
			aux += b * 123456
			if aux > num:
				break
			aux = num - aux
			if aux % 1234 == 0:
				return 'YES'
	return 'NO'
num = int(input())
print(isPossible(num))


from sys import exit
n = int(input())
for h in range(n // 1234567 + 1):
	hcost = h * 1234567
	for c in range((n - hcost) // 123456 + 1):
		ccost = c * 123456
		if (n - hcost - ccost) % 1234 == 0:
			print('YES')
			exit(0)
print('NO')


from math import *
kolya = int(input())
houses = 1234567
cars = 123456
computers = 1234
if 1 <= kolya <= 10 ** 9:
	yes = False
	for i in range(0, kolya + 1, houses):
		for ii in range(0, kolya - i + 1, cars):
			c_computers = (kolya - (i + ii)) / computers
			if floor(c_computers) == ceil(c_computers):
				yes = True
				break
		if yes:
			print('YES')
			break
	else:
		print('NO')
else:
	print('NO')


def economy_game(n):
	if n % 1234 == 0 or n % 123456 == 0 or n % 1234567 == 0:
		return 'YES'
	elif n < 1234567:
		for i in range(int(n / 123456) + 1):
			r = n - 123456 * i
			if r % 1234 == 0:
				return 'YES'
	else:
		for i in range(int(n / 1234567) + 1):
			for j in range(int((n - 1234567 * i) / 123456) + 1):
				r = n - (123456 * j + 1234567 * i)
				if r % 1234 == 0:
					return 'YES'
	return 'NO'
n = int(input())
print(economy_game(n))


import sys
n = int(input())
a = 0
while a <= n:
	b = 0
	while b + a <= n:
		if (n - b - a) % 1234 == 0:
			print('YES')
			sys.exit()
		b += 123456
	a += 1234567
print('NO')


class CodeforcesTask681BSolution:

	def __init__(self):
		self.result = ''
		self.n = 0

	def read_input(self):
		self.n = int(input())

	def process_task(self):
		if self.n < 1234:
			self.result = 'NO'
		else:
			is_ = False
			for a in range(1000):
				for b in range(1000):
					if (self.n - (a * 1234567 + b * 123456)) % 1234 == 0 and self.n - (a * 1234567 + b * 123456) >= 0:
						is_ = True
						break
				if is_:
					break
			self.result = 'YES' if is_ else 'NO'

	def get_result(self):
		return self.result
Solution = CodeforcesTask681BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


n = int(input())
na = n // 1234567 + 1
nb = n // 123456 + 1
flag = False
for a in range(na):
	for b in range(nb):
		v = n - a * 1234567 - b * 123456
		if v >= 0 and v % 1234 == 0:
			flag = True
			break
	if flag:
		break
print('YES') if flag else print('NO')


n = int(input())
p = 0
for i in range(810):
	if p is 1:
		break
	for j in range(8100):
		k = i * 1234567 + j * 123456
		if k > n:
			break
		k = n - k
		if k % 1234 is 0:
			p = 1
			break
if p is 1:
	print('YES')
else:
	print('NO')


n = int(input())
(x, y, z) = (1234567, 123456, 1234)
for i in range(0, n + 1, x):
	for j in range(0, n - i + 1, y):
		k = n - i - j
		if k % z == 0:
			print('YES')
			exit(0)
print('NO')


import sys

def main():
	x = 1234567
	y = 123456
	z = 1234
	s = int(sys.stdin.readline())
	if s % x == 0:
		print('YES')
		return
	while s > 0:
		if s % y == 0:
			print('YES')
			return
		s1 = s
		while s1 > 0:
			if s1 % z == 0:
				print('YES')
				return
			s1 -= y
		s -= x
	print('NO')
main()


n = int(input())
house = 1234567
car = 123456
computer = 1234
found = False
a = 0
while a * house <= n:
	if found:
		break
	b = 0
	while a * house + b * car <= n:
		rem = n - a * house - b * car
		b += 1
		if rem % computer == 0:
			found = True
			break
	a += 1
if found:
	print('YES')
else:
	print('NO')


def R():
	return map(int, input().split())

def I():
	return int(input())

def S():
	return str(input())

def L():
	return list(R())
from collections import Counter
import math
import sys
from itertools import permutations
import bisect
n = I()
for a in range(100):
	for b in range(1000):
		if n - 1234567 * a - 123456 * b >= 0 and (n - 1234567 * a - 123456 * b) % 1234 == 0:
			print('YES')
			exit()
print('NO')


n = int(input())
p = n // 1234567 + 1
for a in range(p):
	q = (n - a * 1234567) // 123456 + 1
	for b in range(q):
		r = n - a * 1234567 - b * 123456
		if r % 1234 == 0:
			print('YES')
			exit()
else:
	print('NO')


n = int(input())
na = n // 1234567
for a in range(na + 1):
	nleft = n - a * 1234567
	nb = nleft // 123456
	for b in range(nb + 1):
		nc = nleft - b * 123456
		if nc % 1234 == 0:
			print('YES')
			exit()
print('NO')