You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.

Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.

If a solution exists, you should print it.


-----Input-----

The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. 


-----Output-----

Print "NO" (without quotes), if there is no such way to remove some digits from number n. 

Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.

If there are multiple possible answers, you may print any of them.


-----Examples-----
Input
3454

Output
YES
344

Input
10

Output
YES
0

Input
111111

Output
NO

Difficulty: MEDIUM
Tags: Dynamic programming

Mathematics

Complete search
Skill types: Dynamic programming

Complete search

Starter code:

Solutions:
a = input()[::-1]
u = [False] * 3
t4 = 0
done = False
for i in a:
	j = int(i)
	if j % 2:
		if t4:
			print('YES\n' + i + t4)
			done = True
			break
		if j % 4 == 1:
			if u[2]:
				print('YES\n' + i + '6')
				done = True
				break
			if u[0]:
				t4 = i + '2'
		else:
			if u[0]:
				print('YES\n' + i + '2')
				done = True
				break
			if u[2]:
				t4 = i + '6'
	else:
		if j % 8 == 0:
			print('YES\n' + i)
			done = True
			break
		elif u[1]:
			if j == 4:
				if u[1]:
					t4 = i + '4'
			else:
				print('YES\n' + i + '4')
				done = True
				break
		u[j // 2 - 1] = True
if not done:
	print('NO')


s = str(input())
if len(s) < 3:
	a = list(map(str, list(range(0, 100, 8))))
	if s in a:
		print('YES')
		print(s)
		quit()
	else:
		if len(s) == 1:
			print('NO')
			quit()
		if len(s) == 2:
			if str(s[0]) in a:
				print('YES')
				print(s[0])
				quit()
			elif str(s[1]) in a:
				print('YES')
				print(s[1])
				quit()
			else:
				print('NO')
				quit()
for i in range(0, len(s)):
	for j in range(i + 1, len(s)):
		for k in range(j + 1, len(s)):
			p1 = s[i] + s[j] + s[k]
			p2 = s[i] + s[j]
			p3 = s[i] + s[k]
			p4 = s[j] + s[k]
			p5 = s[i]
			p6 = s[j]
			p7 = s[k]
			p1 = int(p1)
			p2 = int(p2)
			p3 = int(p3)
			p4 = int(p4)
			p5 = int(p5)
			p6 = int(p6)
			p7 = int(p7)
			if p1 % 8 == 0:
				print('YES')
				print(p1)
				quit()
			elif p2 % 8 == 0:
				print('YES')
				print(p2)
				quit()
			elif p3 % 8 == 0:
				print('YES')
				print(p3)
				quit()
			elif p4 % 8 == 0:
				print('YES')
				print(p4)
				quit()
			elif p5 % 8 == 0:
				print('YES')
				print(p5)
				quit()
			elif p6 % 8 == 0:
				print('YES')
				print(p6)
				quit()
			elif p7 % 8 == 0:
				print('YES')
				print(p7)
				quit()
print('NO')


n = '00' + input()
while len(n) >= 3 and int(n[-1]) % 2 == 1:
	n = n[:-1]
while len(n) >= 3 and int(n[-2] + n[-1]) % 4 != 0:
	n = n[:-2] + n[-1]
while len(n) >= 3 and int(n[-3] + n[-2] + n[-1]) % 8 != 0:
	n = n[:-3] + n[-2] + n[-1]
n = n[2:]
if n:
	print('YES')
	print(n)
else:
	print('NO')


def main():
	s = input()[::-1]
	for i in range(0, 1000, 8):
		start = 0
		for c in reversed(str(i)):
			stop = s.find(c, start)
			if stop == -1:
				break
			else:
				start = stop + 1
		else:
			print('YES')
			print(i)
			return
	print('NO')
main()


n = int(input())
c1 = 0
if n % 8 == 0:
	print('YES')
	print(n)
else:
	s = str(n)
	for i in range(len(s)):
		if int(s[i]) != 0:
			s1 = s[i]
			if int(s[i]) % 8 == 0:
				print('YES')
				print(s[i])
				c1 = -1
				break
		else:
			print('YES')
			print('0')
			c1 = -1
			break
		for j in range(i + 1, len(s)):
			s1 = s[i] + s[j]
			if int(s1) % 8 == 0:
				print('YES')
				if int(s[i]) == 0:
					print(s[j])
				else:
					print(s[i] + s[j])
					c1 = -1
					break
			for r in range(j + 1, len(s)):
				s1 = s[i] + s[j] + s[r]
				if int(s1) % 8 == 0:
					print('YES')
					if int(s[i]) == 0:
						if int(s[j]) == 0:
							print(s[r])
						else:
							print(s[j] + s[r])
					else:
						print(s[i] + s[j] + s[r])
					c1 = -1
					break
			if c1 == -1:
				break
		if c1 == -1:
			break
	if c1 != -1:
		print('NO')


def printans(i, j):
	if prev[i][j] == -1:
		print(arr[i], end='')
		return
	k = prev[i][j]
	printans(i - 1, k)
	if (k * 10 + arr[i]) % 8 == j:
		print(arr[i], end='')
arr = [int(x) for x in input()]
n = len(arr)
dp = [[0] * 8 for i in range(n)]
prev = [[-1] * 8 for i in range(n)]
dp[0][arr[0] % 8] = 1
for i in range(1, n):
	dp[i][arr[i] % 8] = 1
	for j in range(8):
		if dp[i - 1][j] and dp[i][(j * 10 + arr[i]) % 8] == 0:
			dp[i][(j * 10 + arr[i]) % 8] = 1
			prev[i][(j * 10 + arr[i]) % 8] = j
		if dp[i - 1][j] and (not dp[i][j]):
			dp[i][j] = 1
			prev[i][j] = j
ans = 'NO'
for i in range(n):
	if dp[i][0]:
		ans = 'YES'
		break
print(ans)
if ans == 'YES':
	printans(i, 0)
	print()


import os
import sys
from io import BytesIO, IOBase
from collections import defaultdict

def solution(num):
	n = len(num)
	if n <= 2:
		res = [num[0], num[1], num] if n == 2 else [num]
		for cur in res:
			if int(cur) % 8 == 0:
				write('YES')
				write(cur)
				return
		write('NO')
		return
	for i in range(n):
		for j in range(i + 1, n):
			for k in range(j + 1, n):
				possible = [num[i], num[j], num[k], num[i] + num[j], num[i] + num[k], num[j] + num[k], num[i] + num[j] + num[k]]
				for cur in possible:
					if int(cur) % 8 == 0:
						write('YES')
						write(cur)
						return
	write('NO')

def main():
	n = input()
	solution(n)
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))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, end='\n'):
	for x in args[:-1]:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(str(args[-1]))
	sys.stdout.write(end)

def r_array():
	return [int(x) for x in input().split()]

def r_int():
	return int(input())
main()


def solve(s):
	for i in range(0, len(s)):
		if int(s[i]) % 8 == 0:
			print('YES')
			print(s[i])
			return
	for i in range(0, len(s) - 1):
		for j in range(i + 1, len(s)):
			if int(s[i] + s[j]) % 8 == 0:
				print('YES')
				print(s[i] + s[j])
				return
	for i in range(0, len(s) - 2):
		for j in range(i + 1, len(s) - 1):
			for k in range(j + 1, len(s)):
				if int(s[i] + s[j] + s[k]) % 8 == 0:
					print('YES')
					print(s[i] + s[j] + s[k])
					return
	print('NO')
s = input()
solve(s)


def solve(nstr):
	if '8' in nstr:
		print('YES')
		print('8')
		return
	elif '0' in nstr:
		print('YES')
		print('0')
		return
	ind2 = nstr.rfind('2')
	ind4 = nstr.rfind('4')
	ind6 = nstr.rfind('6')
	if ind2 > 0:
		for ch in ['1', '5', '9']:
			if ch in nstr[1:ind2]:
				indch = nstr.rfind(ch, 1, ind2)
				for c in ['1', '3', '5', '7', '9']:
					if c in nstr[0:indch]:
						print('YES')
						print(c + ch + '2')
						return
		for ch in ['3', '7']:
			if ch in nstr[0:ind2]:
				print('YES')
				print(ch + '2')
				return
	if ind4 > 0:
		for ch in ['4']:
			if ch in nstr[1:ind4]:
				indch = nstr.rfind(ch, 1, ind4)
				for c in ['1', '3', '5', '7', '9']:
					if c in nstr[0:indch]:
						print('YES')
						print(c + ch + '4')
						return
		for ch in ['2', '6']:
			if ch in nstr[0:ind4]:
				print('YES')
				print(ch + '4')
				return
	if ind6 > 0:
		for ch in ['1', '5', '9']:
			if ch in nstr[0:ind6]:
				print('YES')
				print(ch + '6')
				return
		for ch in ['3', '7']:
			if ch in nstr[1:ind6]:
				indch = nstr.rfind(ch, 1, ind6)
				for c in ['1', '3', '5', '7', '9']:
					if c in nstr[0:indch]:
						print('YES')
						print(c + ch + '6')
						return
	print('NO')
	return
inp = input()
solve(inp)


def readint():
	return int(input())

def readfloat():
	return float(input())

def readarray(n, f=input):
	return [f() for i in range(n)]

def readlinearray(f=int):
	return list(map(f, input().split()))

def euclide(a, b):
	if a < 0:
		(g, x, y) = euclide(-a, b)
		return (g, -x, y)
	if b < 0:
		(g, x, y) = euclide(a, -b)
		return (g, x, -y)
	if b == 0:
		return (a, 1, 0)
	(g, x, y) = euclide(b, a % b)
	return (g, y, x - a // b * y)

def gen_primes(max):
	primes = [1] * (max + 1)
	for i in range(2, max + 1):
		if primes[i]:
			for j in range(i + i, max + 1, i):
				primes[j] = 0
	primes[0] = 0
	return [x for x in range(max + 1) if primes[x]]

def is_prime(N):
	if N % 2 == 0:
		return N == 2
	i = 3
	while i * i <= N:
		if N % i == 0:
			return False
		i += 2
	return True
n = input()
for i in range(0, 1000, 8):
	i = str(i)
	can = 0
	j = 0
	while j < len(n) and can < len(i):
		if i[can] == n[j]:
			can += 1
		j += 1
	if can == len(i):
		print('YES')
		print(i)
		exit()
print('NO')


from itertools import combinations
n = input()
l = len(n)
if n == '8' or n == '0':
	print('YES')
	print(n)
elif n in ['1', '2', '3', '4', '5', '6', '7', '9']:
	print('NO')
elif l == 2 or l == 3:
	word = list(map(str, n))
	for i in range(1, l + 1):
		x = list(combinations(word, i))
		for j in x:
			cur = ''.join((str(x) for x in j))
			cur = int(cur)
			if cur % 8 == 0:
				print('YES')
				print(cur)
				exit()
	print('NO')
else:
	for i in range(l):
		if int(n[i]) % 8 == 0:
			print('YES')
			print(n[i])
			exit()
	for i in range(l):
		for j in range(i + 1, l):
			if int(n[i] + n[j]) % 8 == 0:
				print('YES')
				print(n[i] + n[j])
				exit()
	for i in range(l):
		for j in range(i + 1, l):
			for k in range(j + 1, l):
				if int(n[i] + n[j] + n[k]) % 8 == 0:
					print('YES')
					print(n[i] + n[j] + n[k])
					exit()
	print('NO')


n = input()
lgn = len(n)
eights = [str(8 * x) for x in range(125)]

def match(eight):
	j = 0
	lge = len(eight)
	ok = 0
	for i in range(lgn):
		if j < lge and eight[j] == n[i]:
			ok += 1
			j += 1
	if ok == lge:
		return 1
	else:
		return 0
ok = 0
for i in range(125):
	if ok == 0 and match(eights[i]) == 1:
		ok = 1
		print('YES')
		print(eights[i])
if ok == 0:
	print('NO')


import sys
n = input()
for i in range(len(n)):
	if int(n[i]) % 8 == 0:
		print('YES')
		print(n[i])
		sys.exit()
for i in range(len(n)):
	for j in range(i + 1, len(n)):
		if int(n[i] + n[j]) % 8 == 0:
			print('YES')
			print(n[i] + n[j])
			sys.exit()
for i in range(len(n)):
	for j in range(i + 1, len(n)):
		for k in range(j + 1, len(n)):
			if int(n[i] + n[j] + n[k]) % 8 == 0:
				print('YES')
				print(n[i] + n[j] + n[k])
				sys.exit()
print('NO')


import sys
input = []
input_index = 0

def next(type, number=None):

	def next():
		global input, input_index
		while input_index == len(input):
			if sys.stdin:
				input = sys.stdin.readline().split()
				input_index = 0
			else:
				raise Exception()
		input_index += 1
		return input[input_index - 1]
	if number is None:
		result = type(next())
	else:
		result = [type(next()) for _ in range(number)]
	return result
s = next(str)
ns = {str(n) for n in range(0, 1000, 8)}
res = None
for i1 in range(len(s)):
	n1 = s[i1]
	if n1 in ns:
		res = n1
	else:
		for i2 in range(i1 + 1, len(s)):
			n2 = n1 + s[i2]
			if n2 in ns:
				res = n2
			else:
				for i3 in range(i2 + 1, len(s)):
					n3 = n2 + s[i3]
					if n3 in ns:
						res = n3
						break
			if res is not None:
				break
	if res is not None:
		break
if res is not None:
	print('YES')
	print(res)
else:
	print('NO')


(a, s) = ([str(8 * x) for x in range(125)], input())
for num in a:
	p = -1
	for d in num:
		p = s.find(d, p + 1)
		if p == -1:
			break
	else:
		print('YES\n{}'.format(num))
		break
else:
	print('NO')


val = input()
val = '00' + val
l = len(val)
for i in range(l):
	for j in range(i + 1, l):
		for k in range(j + 1, l):
			ans = val[i] + val[j] + val[k]
			if int(ans) % 8 == 0:
				print('YES')
				print(int(ans))
				exit()
print('NO')


s = []
for i in range(999):
	if i % 8 == 0:
		s.append(i)
a = list(input())
f = 0

def check(p):
	j = 0
	flag = 0
	for i in p:
		while j < len(a):
			if a[j] == i:
				flag += 1
				j += 1
				break
			j += 1
	if flag == len(p):
		return True
	return False
for i in s:
	if check(str(i)):
		f = 1
		print('YES')
		print(i)
		break
if f == 0:
	print('NO')


n = list(input())
ans = False
ne = 1
for i in range(len(n) - 1, -1, -1):
	for j in range(i - 1, -1, -1):
		s = int(n[j] + n[i])
		if s % 8 == 0:
			ans = True
			ne = s
			break
		for k in range(j - 1, -1, -1):
			s = int(n[k] + n[j] + n[i])
			if s % 8 == 0:
				ans = True
				ne = s
				break
if ans == True:
	print('YES')
	print(ne)
elif '0' in n:
	print('YES')
	print(0)
elif '8' in n:
	print('YES')
	print(8)
elif int(''.join(n)) % 8 == 0:
	print('YES')
	print(''.join(n))
else:
	print('NO')


s = input()
flag = 0
for i in range(len(s) - 1, -1, -1):
	tmp = int(s[i])
	if tmp % 8 == 0:
		print('YES')
		print(int(tmp))
		flag = 1
		break
	for j in range(i - 1, -1, -1):
		tmp = 10 * int(s[j]) + int(s[i])
		if tmp % 8 == 0:
			print('YES')
			print(int(tmp))
			flag = 1
			break
		for k in range(j - 1, -1, -1):
			if s[k] == '0':
				continue
			tmp = 100 * int(s[k]) + 10 * int(s[j]) + int(s[i])
			if tmp % 8 == 0:
				print('YES')
				print(int(tmp))
				flag = 1
				break
		if flag == 1:
			break
	if flag == 1:
		break
if flag == 0:
	print('NO')


if True:
	s = input()
	for ans in range(0, 1000, 8):
		i = -1
		for x in str(ans):
			i = s.find(x, i + 1)
			if i < 0:
				break
		else:
			print('YES')
			print(ans)
			break
	else:
		print('NO')
	exit()


digits = input()[::-1]
val = None
for i in range(0, 1000, 8):
	first = 0
	for j in reversed(str(i)):
		c = digits.find(j, first)
		if c == -1:
			break
		else:
			first = c + 1
	else:
		val = i
		break
print('YES' + '\n' + str(val) if val != None else 'NO')


n = input()
n = '00' + n
for i in range(len(n) - 2):
	for j in range(i + 1, len(n) - 1):
		for k in range(j + 1, len(n)):
			value = n[i] + n[j] + n[k]
			if int(value) % 8 == 0:
				print('YES')
				print(int(value))
				exit()
print('NO')


n = input()
ans = -1
for i in range(len(n)):
	if int(n[i]) % 8 == 0 and ans == -1:
		ans = n[i]
		break
	else:
		for j in range(i + 1, len(n)):
			if int(n[i] + n[j]) % 8 == 0 and ans == -1:
				ans = n[i] + n[j]
				break
			else:
				for k in range(j + 1, len(n)):
					if int(n[i] + n[j] + n[k]) % 8 == 0 and ans == -1:
						ans = n[i] + n[j] + n[k]
						break
if ans == -1:
	print('NO')
else:
	print('YES')
	print(ans)


import sys
s = sys.stdin.readline().strip()
n = len(s)
e = 0
for i in range(n):
	if (ord(s[i]) - ord('0')) % 8 == 0 and e == 0:
		print('YES')
		print(s[i])
		e = 1
		break
	for j in range(i + 1, n):
		if ((ord(s[i]) - ord('0')) * 10 + (ord(s[j]) - ord('0'))) % 8 == 0 and e == 0:
			print('YES')
			print(s[i] + s[j])
			e = 1
			break
		for k in range(j + 1, n):
			if ((ord(s[i]) - ord('0')) * 100 + (ord(s[j]) - ord('0')) * 10 + (ord(s[k]) - ord('0'))) % 8 == 0 and e == 0:
				print('YES')
				print(s[i] + s[j] + s[k])
				e = 1
				break
if e == 0:
	print('NO')


S = input()
N = len(S)
flag = 0
if S.count('0') > 0:
	print('YES')
	print(0)
	exit()
if S.count('8') > 0:
	print('YES')
	print(8)
	exit()
if N < 3:
	if int(S) % 8 == 0:
		print('YES')
		print(S)
	elif S.count('0') > 0:
		print('YES')
		print(0)
	elif S.count('8') > 0:
		print('YES')
		print(8)
	else:
		print('NO')
	exit()
for i in range(N - 2):
	if int(S[i]) % 8 == 0:
		print('YES')
		print(S[i])
		flag = 1
		break
	for j in range(i + 1, N - 1):
		if int(S[i] + S[j]) % 8 == 0:
			print('YES')
			print(S[i] + S[j])
			flag = 1
			break
		for k in range(j + 1, N):
			if int(S[i] + S[j] + S[k]) % 8 == 0:
				print('YES')
				print(S[i] + S[j] + S[k])
				flag = 1
				break
			elif int(S[j] + S[k]) % 8 == 0:
				print('YES')
				print(S[j] + S[k])
				flag = 1
				break
			elif int(S[i] + S[k]) % 8 == 0:
				print('YES')
				print(S[i] + S[k])
				flag = 1
				break
		if flag:
			break
	if flag:
		break
if not flag:
	print('NO')


s = input()
s = '00' + str(s)
l = len(s)
for i in range(l):
	for j in range(i + 1, l):
		for k in range(j + 1, l):
			new = s[i] + s[j] + s[k]
			if int(new) % 8 == 0:
				print('YES')
				print(int(new))
				exit()
print('NO')


num = input()

def problem1(num):
	num2 = num
	size = len(num2)
	num = int(num)
	opera = 0
	lista = []
	dicti = {}
	numero = ''
	if num % 8 == 0:
		print('YES')
		print(num)
		return
	for i in range(0, size):
		if str(num2[i]) in dicti:
			dicti[num2[i]] += 1
		else:
			dicti[num2[i]] = 1
		if '0' == str(num2[i]):
			print('YES')
			print('0')
			return
		if '8' == str(num2[i]):
			print('YES')
			print('8')
			return
	for x in range(100):
		opera += 8
		lista.append(str(opera))
	for j in lista:
		for i in j:
			if i in dicti:
				numero += i
				dicti[i] -= 1
			else:
				numero = ''
				break
		if len(numero) > 1:
			cont = 0
			for q in num2:
				if numero[cont] == q:
					cont += 1
					if cont == len(numero):
						print('YES')
						print(numero)
						return
	num = str(num)
	while len(num) > 1:
		num = num[0:len(num) - 1]
		if int(num) % 8 == 0:
			print('YES')
			print(num)
			return
	print('NO')
problem1(num)


n = input()
a = 0
if '8' in n:
	print('YES')
	print(8)
	a = 1
elif '0' in n:
	print('YES')
	print(0)
	a = 1
else:
	i = '16'
	while int(i) < 1000:
		if len(i) == 2:
			for j in range(len(n)):
				if n[j] == i[0]:
					for k in range(j + 1, len(n)):
						if n[k] == i[1]:
							print('YES')
							print(i)
							a = 1
							break
						else:
							pass
				else:
					pass
				if a == 1:
					break
				else:
					pass
		else:
			for j in range(len(n)):
				if n[j] == i[0]:
					for k in range(j + 1, len(n)):
						if n[k] == i[1]:
							for l in range(k + 1, len(n)):
								if n[l] == i[2]:
									a = 1
									print('YES')
									print(i)
									break
								else:
									pass
						else:
							pass
						if a == 1:
							break
						else:
							pass
				else:
					pass
				if a == 1:
					break
				else:
					pass
		if a == 1:
			break
		else:
			pass
		i = str(int(i) + 8)
if a == 0:
	print('NO')


s = input()
y = 'YES'
flag = True
if '8' in s:
	print(y)
	print('8')
	flag = False
if flag:
	if '0' in s:
		print(y)
		print('0')
		flag = False
if flag:
	for i in range(16, 100, 8):
		a = str(i)
		if s.find(a[0]) + 1 > 0 and s.find(a[1], s.find(a[0]) + 1) >= 0:
			print(y)
			print(a)
			flag = False
			break
if flag:
	for i in range(104, 999, 8):
		a = str(i)
		if s.find(a[0]) >= 0 and s.find(a[1], s.find(a[0]) + 1) >= 0 and (s.find(a[2], s.find(a[1], s.find(a[0]) + 1) + 1) > 0):
			print(y)
			print(a)
			flag = False
			break
if flag:
	print('NO')


def uni_c():
	for c in n:
		v = int(c)
		if v % 8 == 0:
			return v
	return -1

def two_c():
	for i in range(len(n)):
		for j in range(i + 1, len(n)):
			num = int(n[i]) * 10 + int(n[j])
			if num % 8 == 0:
				return num
	return -1

def three_c():
	for i in range(len(n)):
		for j in range(i + 1, len(n)):
			for k in range(j + 1, len(n)):
				num = int(n[i]) * 100 + int(n[j]) * 10 + int(n[k])
				if num % 8 == 0:
					return num
	return -1
n = input()
count = [0 for i in range(10)]
for digit in n:
	count[ord(digit) - ord('0')] += 1
ans = uni_c()
if ans != -1:
	print('YES')
	print(ans)
else:
	ans = two_c()
	if ans != -1:
		print('YES')
		print(ans)
	else:
		ans = three_c()
		if ans != -1:
			print('YES')
			print(ans)
		else:
			print('NO')


a = input()
answer = -1
flag = 0
if '0' in a:
	print('YES')
	print(0)
else:
	for i in range(0, len(a)):
		if int(a[i]) % 8 == 0:
			answer = a[i]
			flag = 1
			break
		for j in range(i + 1, len(a)):
			if int(a[i] + a[j]) % 8 == 0:
				answer = a[i] + a[j]
				flag = 1
				break
			for k in range(j + 1, len(a)):
				if int(a[i] + a[j] + a[k]) % 8 == 0:
					answer = a[i] + a[j] + a[k]
					flag = 1
					break
			if flag == 1:
				break
		if flag == 1:
			break
	if answer == -1:
		print('NO')
	else:
		print('YES')
		print(answer)


def solve():
	s = input()
	n = len(s)
	for i in range(n):
		if int(s[i]) % 8 == 0:
			print('YES')
			print(s[i])
			return 0
		for j in range(i + 1, n):
			if int(s[j]) % 8 == 0:
				print('YES')
				print(s[j])
				return 0
			if int(s[i] + s[j]) % 8 == 0:
				print('YES')
				print(s[i] + s[j])
				return 0
			for k in range(j + 1, n):
				if int(s[k]) % 8 == 0:
					print('YES')
					print(s[k])
					return 0
				if int(s[j] + s[k]) % 8 == 0:
					print('YES')
					print(s[j] + s[k])
					return 0
				if int(s[i] + s[k]) % 8 == 0:
					print('YES')
					print(s[i] + s[k])
					return 0
				temp = s[i] + s[j] + s[k]
				if int(temp) % 8 == 0:
					print('YES')
					print(temp)
					return 0
	print('NO')
	return 0
tt = solve()


def solve(s):
	for i in range(len(s)):
		a = int(s[i])
		if a % 2 != 0:
			continue
		if a % 8 == 0:
			print('YES')
			print(a)
			return
		for j in range(i + 1, len(s)):
			b = int(s[j]) * 10 + a
			if b % 4 != 0:
				continue
			if b % 8 == 0:
				print('YES')
				print(b)
				return
			for k in range(j + 1, len(s)):
				c = int(s[k]) * 100 + b
				if c % 8 != 0:
					continue
				if c % 8 == 0:
					print('YES')
					print(c)
					return
	print('NO')
	return
s = input()
s = s[::-1]
solve(s)


n = input()
l = len(n)
dp = [[False for _ in range(8)] for _ in range(l)]
prev = [['' for _ in range(8)] for _ in range(l)]
dp[0][int(n[0]) % 8] = True
prev[0][int(n[0]) % 8] = n[0]
for idx in range(1, l):
	dp[idx][int(n[idx]) % 8] = True
	prev[idx][int(n[idx]) % 8] = n[idx]
	for rem in range(8):
		if dp[idx - 1][rem]:
			dp[idx][rem] = True
			prev[idx][rem] = prev[idx - 1][rem]
			dp[idx][(10 * rem + int(n[idx])) % 8] = True
			prev[idx][(10 * rem + int(n[idx])) % 8] = prev[idx - 1][rem] + n[idx]
check = True
for idx in range(l):
	if dp[idx][0]:
		check = False
		print('YES')
		print(prev[idx][0])
		break
if check:
	print('NO')


n = input()
f = 0
for i in n:
	if i == '0':
		f = 1
		break
if f == 1:
	print('YES')
	print(0)
elif len(n) == 1:
	if int(n) % 8 == 0:
		print('YES')
		print(int(n))
	else:
		print('NO')
elif len(n) == 2:
	if int(n) % 8 == 0:
		print('YES')
		print(int(n))
	elif int(n[0]) % 8 == 0:
		print('YES')
		print(int(n[0]))
	elif int(n[1]) % 8 == 0:
		print('YES')
		print(int(n[i]))
	else:
		print('NO')
else:
	br = 0
	for i in range(len(n)):
		if br == 1:
			break
		if int(n[i]) % 8 == 0:
			print('YES')
			print(int(n[i]))
			br = 1
			break
		for j in range(i + 1, len(n)):
			temp = ''
			temp += n[i]
			temp += n[j]
			if int(temp) % 8 == 0:
				br = 1
				print('YES')
				print(temp)
				break
			for k in range(j + 1, len(n)):
				temp = ''
				temp += n[i]
				temp += n[j]
				temp += n[k]
				if int(temp) % 8 == 0:
					br = 1
					print('YES')
					print(temp)
					break
			if br == 1:
				break
		if br == 1:
			break
	if br == 0:
		print('NO')


n = input()
s = ''
flag = True
for i in range(len(n)):
	if int(n[i]) % 8 == 0:
		flag = False
		s = n[i]
for i in range(len(n)):
	for j in range(i + 1, len(n)):
		if int(n[i] + n[j]) % 8 == 0:
			flag = False
			s = n[i] + n[j]
for i in range(len(n)):
	for j in range(i + 1, len(n)):
		for k in range(j + 1, len(n)):
			if int(n[i] + n[j] + n[k]) % 8 == 0:
				s = n[i] + n[j] + n[k]
				flag = False
if flag:
	print('NO')
else:
	print('YES')
	print(int(s))


m = dict()

def divisible(n):
	if int(n) % 8 == 0:
		return int(n)
	elif m.get(n) == None:
		if len(n) > 1:
			a = []
			a.append(int(divisible(n[:-1])))
			a.append(int(divisible(n[:-2] + n[-1:])))
			if len(n) > 2:
				a.append(int(divisible(n[:-3] + n[-2:])))
			m[n] = max(a)
			return max(a)
		else:
			m[n] = -1
			return -1
	else:
		return m.get(n)
n = input()
a = divisible(n)
if a < 0:
	print('NO')
else:
	print('YES')
	print(a)


from sys import stdin, stdout
sol = None
n = input()
for i in range(len(n)):
	for j in range(i + 1, len(n)):
		for k in range(j + 1, len(n)):
			v = int(n[i] + n[j] + n[k])
			if v % 8 == 0:
				sol = v
		v = int(n[i] + n[j])
		if v % 8 == 0:
			sol = v
	v = int(n[i])
	if v % 8 == 0:
		sol = v
if sol == None:
	stdout.write('NO' + '\n')
else:
	stdout.write('YES' + '\n')
	stdout.write(str(sol) + '\n')


from itertools import combinations
num = input()
l = len(num)
done = False
for k in range(1, min(l + 1, 4)):
	for e in combinations(list(range(l)), k):
		s = ''.join([num[i] for i in e])
		if int(s) % 8 == 0:
			print('YES')
			print(s)
			done = True
			break
	if done:
		break
else:
	print('NO')


import math
import random
from collections import *
mod = 1000000007
r1 = lambda : int(input())
rm = lambda : map(int, input().split())
rms = lambda : map(str, input().split())
rls = lambda : list(rm())

def def_value():
	return 'nan'

def check(s1, s):
	for i in list(s1):
		x = s.find(i)
		if x != -1:
			if len(s) > 1:
				s = s[x + 1:]
			else:
				s = ''
		else:
			return False
	return True

def solve():
	s = input()
	n = len(s)
	flag = True
	mm = 10000000
	if mm > int(s):
		mm = int(s) + 1
	for i in range(0, mm, 8):
		if check(str(i), s):
			print('YES')
			flag = False
			print(i)
			break
	if flag:
		print('NO')
solve()


s = input()
le = len(s)
if '0' in s:
	print('YES')
	print(0)
elif '8' in s:
	print('YES')
	print(8)
else:
	for i in range(0, le):
		for j in range(i + 1, le):
			val = int(s[i] + s[j])
			if val % 8 == 0:
				print('YES')
				print(val)
				exit(0)
			for k in range(j + 1, le):
				val = int(s[i] + s[j] + s[k])
				if val % 8 == 0:
					print('YES')
					print(val)
					exit(0)
	print('NO')


s = input()
n = len(s)
for i in range(n):
	if int(s[i]) == 8 or int(s[i]) == 0:
		print('YES')
		print(s[i])
		exit()
if n >= 2:
	for i in range(n):
		for j in range(i + 1, n):
			if (int(s[i]) * 10 + int(s[j])) % 8 == 0:
				print('YES')
				print(s[i] + s[j])
				exit()
if n >= 3:
	for i in range(n):
		for j in range(i + 1, n):
			for r in range(j + 1, n):
				if (int(s[i]) * 100 + int(s[j]) * 10 + int(s[r])) % 8 == 0:
					print('YES')
					print(s[i] + s[j] + s[r])
					exit()
print('NO')


from pprint import pprint
num = list(map(int, input()))
dy = [[None for j in range(10)] for i in range(len(num) + 1)]
dy[0][0] = 0

def solve():
	for inum in range(len(num)):
		for idy in range(10):
			if dy[inum][idy] == None:
				continue
			curNum = idy * 10 + num[inum]
			mod = curNum % 8
			if not mod:
				print('YES')
				return dy[inum][idy] * 10 + num[inum]
			dy[inum + 1][mod] = dy[inum][idy] * 10 + num[inum]
			dy[inum + 1][idy] = dy[inum][idy]
	return 'NO'
print(solve())


def check(a):
	if len(a) < 3:
		return int(a) % 8 == 0
	code = lambda x: ord(x) - ord('0')
	val = 4 * code(a[-3]) + 2 * code(a[-2]) + code(a[-1])
	return val % 8 == 0

def main():
	s = input()
	m = len(s)
	r = ''
	if s.find('8') >= 0:
		print('YES\n8')
		return 0
	if s.find('0') >= 0:
		print('YES\n0')
		return 0
	if len(s) < 3:
		print('YES\n' + s if int(s) % 8 == 0 else 'NO')
		return 0
	for i in range(m):
		for j in range(i + 1, m):
			r = s[i] + s[j]
			if check(r):
				print('YES\n' + r)
				return 0
	for i in range(m):
		for j in range(i + 1, m):
			for k in range(j + 1, m):
				r = s[i] + s[j] + s[k]
				if check(r):
					print('YES\n' + r)
					return 0
	print('NO')
main()


s = input()
found = False
if '0' in s:
	sol = 0
	found = True
elif '8' in s:
	sol = 8
	found = True
if not found:
	d = {}
	for i in range(len(s)):
		c = int(s[i])
		if c not in d:
			d[c] = []
		d[c].append(i)
	for i in range(16, 100, 8):
		uni = i % 10
		dec = i // 10
		if uni in d and dec in d:
			if d[uni][-1] > d[dec][0]:
				sol = i
				found = True
				break
if not found:
	s_list = list(map(int, s))
	for i in range(len(s) - 1, 1, -1):
		if s_list[i] % 2 == 1:
			continue
		if found:
			break
		for j in range(i - 1, 0, -1):
			if found:
				break
			for k in range(j - 1, -1, -1):
				temp = s_list[k] * 100 + s_list[j] * 10 + s_list[i]
				if temp % 8 == 0:
					sol = temp
					found = True
					break
if found:
	print('YES')
	print(sol)
else:
	print('NO')


def int_it(num):
	return int(''.join(num))

def is_div(num):
	return num % 8 == 0

def is_even(num):
	return int(num) % 2 == 0
from pdb import set_trace

def find_div(number):
	for x in number:
		aux = []
		aux.append(x)
		if is_div(int(x)):
			print('YES')
			print(x)
			exit()
		for y in number[number.index(x) + 1:]:
			if not is_even(y):
				continue
			aux.append(y)
			if is_div(int_it(aux)):
				print('YES')
				print(int_it(aux))
				exit()
		for k in number[:number.index(x)]:
			if not is_div(int_it(list(k) + aux)):
				continue
			print('YES')
			print(int_it(list(k) + aux))
			exit()
		for j in number[:number.index(x)]:
			aux = list(j) + aux
			if is_div(int_it(aux)):
				print('YES')
				print(int_it(aux))
				exit()
g_number = [x for x in input()]
find_div(g_number)
print('NO')


s = input()
n = len(s)
poss = 0
ans = 0
for i in range(n):
	for j in range(i + 1, n):
		for k in range(j + 1, n):
			z = 100 * int(s[i]) + 10 * int(s[j]) + int(s[k])
			if z % 8 == 0:
				poss = 1
				ans = z
				break
		if poss == 1:
			break
	if poss == 1:
		break
for i in range(n):
	for j in range(i + 1, n):
		z = 10 * int(s[i]) + int(s[j])
		if z % 8 == 0:
			poss = 1
			ans = z
			break
	if poss == 1:
		break
for i in range(n):
	z = int(s[i])
	if z % 8 == 0:
		ans = z
		poss = 1
		break
if poss:
	print('YES')
	print(ans)
else:
	print('NO')


def verify(x):
	return x != -1
d = dict()

def solve(index, cur):
	if index == len(n):
		if cur % 8 == 0 and cur:
			return cur
		return -1
	if (index, cur) in d:
		return d[index, cur]
	x = solve(index + 1, cur)
	y = solve(index + 1, (cur * 10 + int(n[index])) % 1000)
	if verify(x):
		d[index, cur] = x
		return x
	if verify(y):
		d[index, cur] = y
		return y
	d[index, cur] = -1
	return -1
n = input()
if '0' in n:
	print('YES\n0')
	exit()
x = solve(0, 0)
if x != -1:
	print('YES')
	print(x)
else:
	print('NO')


n = input()

def f(n):
	for i in reversed(range(len(n))):
		ni = int(n[i])
		if ni % 8 == 0:
			return (True, '%d' % ni)
		if ni % 2 == 0:
			for j in reversed(range(i)):
				nj = int(n[j])
				if (10 * nj + ni) % 8 == 0:
					return (True, '%d%d' % (nj, ni))
				if (10 * nj + ni) % 4 == 0:
					for k in reversed(range(j)):
						nk = int(n[k])
						if (100 * nk + 10 * nj + ni) % 8 == 0:
							return (True, '%d%d%d' % (nk, nj, ni))
	return (False, '')
res = f(n)
if res[0]:
	print('YES')
	print(res[1])
else:
	print('NO')


n = list(input())
l = len(n)
for i in range(l):
	n[i] = int(n[i])
flag = 0
for i in range(l):
	if n[i] == 8 or n[i] == 0:
		print('YES')
		print(n[i])
		flag = 1
		break
if flag == 0:
	for i in range(l - 1):
		for j in range(i + 1, l):
			k = int(str(n[i]) + str(n[j]))
			if k % 8 == 0:
				print('YES')
				print(k)
				flag = 1
				break
		if flag == 1:
			break
if flag == 0:
	for i in range(l - 2):
		for j in range(i + 1, l - 1):
			for k in range(j + 1, l):
				ki = int(str(n[i]) + str(n[j]) + str(n[k]))
				if ki % 8 == 0:
					print('YES')
					print(ki)
					flag = 1
					break
			if flag == 1:
				break
		if flag == 1:
			break
if flag == 0:
	print('NO')


num = input()
num = '00' + num
for i in range(len(num) - 2):
	for j in range(i + 1, len(num) - 1):
		for k in range(j + 1, len(num)):
			val = int(num[i] + num[j] + num[k])
			if val % 8 == 0:
				print('YES')
				print(val)
				exit()
print('NO')


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
n = list(z())
for i in range(0, 1001, 8):
	t = list(str(i))
	k = 0
	c = 0
	for j in n:
		if t[k] == j:
			k += 1
			c += 1
			k = min(len(t) - 1, k)
	if c >= len(t):
		print('YES')
		print(i)
		exit()
print('NO')


def check_me(inp):
	for i in inp:
		if int(i) % 8 == 0:
			print('YES\n' + i)
			return
	for i in range(len(inp) - 1, 0, -1):
		for j in range(i - 1, -1, -1):
			curNumber = int(inp[j] + inp[i])
			if curNumber % 8 == 0:
				print('YES\n' + str(curNumber))
				return
	for i in range(len(inp) - 1, 1, -1):
		for j in range(i - 1, 0, -1):
			for k in range(j - 1, -1, -1):
				curNumber = int(inp[k] + inp[j] + inp[i])
				if curNumber % 8 == 0:
					print('YES\n' + str(curNumber))
					return
	print('NO')
inp = input().strip()
check_me(inp)


s = [j for j in input()]
n = len(s)
if '0' in s:
	print('YES')
	print(0)
elif int(''.join(s)) % 8 == 0:
	print('YES')
	print(''.join(s))
elif '8' in s:
	print('YES')
	print(8)
else:
	ans = []
	for i in range(n):
		for j in range(i + 1, n):
			if int(s[i] + s[j]) % 8 == 0:
				ans.append(int(s[i] + s[j]))
			for k in range(j + 1, n):
				if int(s[i] + s[j] + s[k]) % 8 == 0:
					ans.append(int(s[i] + s[j] + s[k]))
				if int(s[j] + s[k]) % 8 == 0:
					ans.append(int(s[j] + s[k]))
				if int(s[i] + s[k]) % 8 == 0:
					ans.append(int(s[i] + s[k]))
	if len(ans) == 0:
		print('NO')
	else:
		print('YES')
		print(ans[0])


num = input()
length = len(num)
done = False
result = 0
for i in range(0, length):
	result = int(num[i])
	if result % 8 == 0:
		print('YES')
		print(result)
		done = True
		break
if not done:
	result = 0
	for i in range(0, length - 1):
		if done:
			break
		result += int(num[i]) * 10
		for j in range(i + 1, length):
			if done:
				break
			result += int(num[j])
			if result % 8 == 0:
				print('YES')
				print(result)
				done = True
				break
			result -= int(num[j])
		result -= int(num[i]) * 10
if not done:
	result = 0
	for i in range(0, length - 2):
		if done:
			break
		result += int(num[i]) * 100
		for j in range(i + 1, length - 1):
			if done:
				break
			result += int(num[j]) * 10
			for k in range(j + 1, length):
				result += int(num[k])
				if result % 8 == 0:
					print('YES')
					print(result)
					done = True
					break
				result -= int(num[k])
			result -= int(num[j]) * 10
		result -= int(num[i]) * 100
if not done:
	print('NO')


s = input()
L = []
for i in range(0, 1000, 8):
	L.append(str(i))

def isSubSequence(str1, str2, m, n):
	j = 0
	i = 0
	while j < m and i < n:
		if str1[j] == str2[i]:
			j = j + 1
		i = i + 1
	return j == m
if len(s) < 3:
	if int(s) % 8 == 0:
		print('YES')
		print(s)
	elif isSubSequence('8', s, 1, len(s)):
		print('YES')
		print('8')
	elif isSubSequence('0', s, 1, len(s)):
		print('YES')
		print('0')
	else:
		print('NO')
elif int(s) % 8 == 0:
	print('YES')
	print(s)
elif isSubSequence('8', s, 1, len(s)):
	print('YES')
	print('8')
elif isSubSequence('0', s, 1, len(s)):
	print('YES')
	print('0')
else:
	k = -1
	for i in range(len(L)):
		if isSubSequence(L[i], s, len(L[i]), len(s)):
			k = i
			break
	if k != -1:
		print('YES')
		print(L[i])
	else:
		print('NO')


def main():
	S = input()
	for i in range(len(S)):
		if int(S[i]) % 8 == 0:
			print('YES')
			print(int(S[i]))
			return
	for i in range(len(S)):
		for j in range(i + 1, len(S)):
			if int(S[i] + S[j]) % 8 == 0:
				print('YES')
				print(int(S[i] + S[j]))
				return
	for i in range(len(S)):
		for j in range(i + 1, len(S)):
			for k in range(j + 1, len(S)):
				a = S[i] + S[j] + S[k]
				if int(a) % 8 == 0:
					print('YES')
					print(int(a))
					return
	print('NO')
main()


from sys import stdin, stdout
import math, sys, heapq
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
from os import path
import random
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

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

	def In():
		return map(int, input().split())
else:

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

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

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return -1

def cal(l, i, n, dp):
	if i >= len(l):
		if n % 8 == 0:
			return n
		else:
			return -1
	if n % 8 == 0:
		return n
	t1 = cal(l, i + 1, n, dp)
	t2 = cal(l, i + 1, n * 10 + int(l[i]), dp)
	if t1 != -1 or t2 != -1:
		if t1 != -1:
			dp[i] = t1
		if t2 != -1:
			dp[i] = t2
		return max(t1, t2)
	else:
		return -1

def main():
	try:
		l = list(input())
		ans = -1
		dp = []
		n = len(l)
		for x in range(n):
			temp = []
			for y in dp:
				z = y * 10 + int(l[x])
				if z < 1000:
					temp.append(z)
				if temp[-1] % 8 == 0:
					ans = temp[-1]
					break
			dp.append(int(l[x]))
			if int(l[x]) % 8 == 0:
				ans = int(l[x])
			if ans != -1:
				break
			dp += temp.copy()
		if ans != -1:
			yes()
			print(ans)
		else:
			no()
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(1):
	main()


s = input()
n = len(s)
fl = 0
for i in range(n):
	if int(s[i]) % 8 == 0:
		fl = 1
		print('YES')
		print(s[i])
		break
	for j in range(i + 1, n):
		if (10 * int(s[i]) + int(s[j])) % 8 == 0:
			fl = 1
			print('YES')
			print(s[i], s[j], sep='')
			break
		for k in range(j + 1, n):
			if (100 * int(s[i]) + 10 * int(s[j]) + int(s[k])) % 8 == 0:
				fl = 1
				print('YES')
				print(s[i], s[j], s[k], sep='')
				break
		if fl == 1:
			break
	if fl == 1:
		break
if fl == 0:
	print('NO')


from itertools import combinations

def is_divisible(s, k):
	best = [-1] * min(len(s), k)
	mx = 0
	for x in combinations(list(range(0, len(s))), min(len(s), k)):
		if int(''.join((s[i] for i in x))) % 8 == 0:
			length = len(s) - (x[-1] - x[0]) - (len(s) - x[-1] - 1) + len(x) - 1
			if length > mx:
				mx = length
				best = x
	if best[0] != -1 or k == 1:
		return best
	return is_divisible(s, min(len(s), k) - 1)

def solve():
	s = input()
	if len(s) == 1 and int(s) % 8 != 0:
		print('NO')
		return
	res = is_divisible(s, 3)
	if res[0] != -1:
		print('YES')
		if s[res[0]] == '0':
			print(s[res[0]])
		elif len(res) < 3:
			print(''.join((s[i] for i in res)))
		else:
			print(s[0:res[0] + 1] + ''.join((s[i] for i in res[1:])))
	else:
		print('NO')
solve()


def get_result(n):
	mult_of_8 = {}
	for i in range(0, 1000):
		if i % 8 == 0:
			mult_of_8[i] = 1
	size = len(n)
	for i in range(size - 1, -1, -1):
		if n[i] == '0' or n[i] == '2' or n[i] == '4' or (n[i] == '6') or (n[i] == '8'):
			if size - (size - i) - 1 < 0:
				v = int(n[i])
				if v in mult_of_8:
					print('YES')
					return v
			for j in range(size - (size - i) - 1, -1, -1):
				if size - (size - j) - 1 < 0:
					v = int(n[j]) * 10 + int(n[i]) * 1
					if v in mult_of_8:
						print('YES')
						return v
				for k in range(size - (size - j) - 1, -1, -1):
					v = int(n[k]) * 100 + int(n[j]) * 10 + int(n[i]) * 1
					if v in mult_of_8:
						print('YES')
						return v
				v = int(n[j]) * 10 + int(n[i]) * 1
				if v in mult_of_8:
					print('YES')
					return v
			v = int(n[i])
			if v in mult_of_8:
				print('YES')
				return v
	return 'NO'
n = input()
print(get_result(n))


def proveDivisible(n):
	if int(n) % 8 == 0:
		return 'YES\n' + n
	for i in range(len(n)):
		if int(n[i]) % 8 == 0:
			return 'YES\n' + n[i]
		for j in range(i + 1, len(n)):
			if int(n[i] + n[j]) % 8 == 0:
				return 'YES\n' + n[i] + n[j]
			for k in range(j + 1, len(n)):
				if int(n[i] + n[j] + n[k]) % 8 == 0:
					return 'YES\n' + n[i] + n[j] + n[k]
	return 'NO'
n = str(input())
print(proveDivisible(n))


def solve(n):
	for i in range(len(n)):
		if int(n[i]) % 8 is 0:
			return int(n[i])
	for i in range(len(n) - 1):
		for j in range(i + 1, len(n)):
			m = 10 * int(n[i]) + int(n[j])
			if m % 8 is 0:
				return m
	for i in range(len(n) - 2):
		for j in range(i + 1, len(n) - 1):
			for k in range(j + 1, len(n)):
				m = 100 * int(n[i]) + 10 * int(n[j]) + int(n[k])
				if m % 8 is 0:
					return m
	return -1
n = input()
sol = solve(n)
if sol is -1:
	print('NO')
else:
	print('YES')
	print(sol)


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
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 value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
n = input()
n = '0' * 2 + n
for i in range(len(n)):
	number = int(n[i])
	for j in range(i + 1, len(n)):
		number1 = number * 10 + int(n[j])
		for k in range(j + 1, len(n)):
			number2 = number1 * 10 + int(n[k])
			if number2 % 8 == 0:
				print('YES')
				print(number2)
				exit()
print('NO')


n = input()
l = list(n)
n = len(l)
for i in range(len(l)):
	l[i] = int(l[i])
ans = 0
if 8 in l:
	print('YES')
	print(8)
elif 0 in l:
	print('YES')
	print(0)
elif n < 3:
	if n == 2:
		if (l[0] * 10 + l[1]) % 8 == 0:
			print('YES')
			print(l[0] * 10 + l[1])
		elif l[1] == 0:
			print('YES')
			print(0)
		else:
			print('NO')
	if n == 1:
		if l[0] % 8 == 0:
			print('YES')
			print(l[0])
		else:
			print('NO')
else:
	for i in range(n - 2):
		for j in range(i + 1, n - 1):
			for k in range(j + 1, n):
				if (l[i] * 10 ** 2 + l[j] * (10 * 1) + l[k] * 1) % 8 == 0:
					ans += 1
					dig = l[i] * 10 ** 2 + l[j] * (10 * 1) + l[k] * 1
					break
				if (l[i] * 10 + l[j]) % 8 == 0:
					ans += 1
					dig = l[i] * 10 + l[j]
					break
				if (l[j] * 10 + l[k]) % 8 == 0:
					ans += 1
					dig = l[j] * 10 + l[k]
					break
				if (l[i] * 10 + l[k]) % 8 == 0:
					ans += 1
					dig = l[i] * 10 + l[k]
					break
	if ans > 0:
		print('YES')
		print(dig)
	else:
		print('NO')


import re
s = input()
for i in range(0, 993, 8):
	i = str(i)
	if re.search('.*'.join(i), s):
		print('YES')
		print(i)
		break
else:
	print('NO')


n = input()
if '0' in n:
	print('YES')
	print('0')
	exit()
if '8' in n:
	print('YES')
	print('8')
	exit()
if '2' in n:
	i = n.rindex('2')
	try:
		j = max([n[:i].rindex(c) for c in ['1', '3', '5', '7', '9'] if c in n[:i]])
		c = n[j]
		if c in ['3', '7']:
			print('YES')
			print(c + '2')
			exit()
		for v in ['1', '3', '5', '7', '9']:
			if v in n[:j]:
				print('YES')
				print(v + c + '2')
				exit()
	except ValueError:
		pass
if '4' in n:
	i = n.rindex('4')
	if '2' in n and n.index('2') < i:
		print('YES')
		print('24')
		exit()
	if '6' in n and n.index('6') < i:
		print('YES')
		print('64')
		exit()
	if '4' in n[:i]:
		try:
			j = min([n.index(c) for c in ['1', '3', '5', '7', '9'] if c in n])
			if j < n[:i].rindex('4'):
				print('YES')
				print(n[j] + '44')
				exit()
		except ValueError:
			pass
if '6' in n:
	i = n.rindex('6')
	try:
		j = max([n[:i].rindex(c) for c in ['1', '3', '5', '7', '9'] if c in n[:i]])
		c = n[j]
		if c not in ['3', '7']:
			print('YES')
			print(c + '6')
			exit()
		for v in ['1', '3', '5', '7', '9']:
			if v in n[:j]:
				print('YES')
				print(v + c + '6')
				exit()
	except ValueError:
		pass
print('NO')


import re
n = input()
divide = []
for i in range(100, 1000):
	if i % 8 == 0:
		f = str(i // 100)
		s = str(i % 100 // 10)
		t = str(i % 10)
		m = f + '[0-9]*' + s + '[0-9]*' + t
		divide.append(m)
for i in range(10, 100):
	if i % 8 == 0:
		f = str(i // 10)
		s = str(i % 10)
		m = f + '[0-9]*' + s
		divide.append(m)
for i in range(0, 10):
	if i % 8 == 0:
		i = str(i)
		m = i
		divide.append(m)
judge = False
for i in divide:
	if re.search(i, n) != None:
		judge = True
		break
if judge == True:
	print('YES')
	print(''.join(i.split('[0-9]*')))
else:
	print('NO')


import time
s = input()
flag = False
ans = ''
start = time.time()
for i in s:
	if i == '8' or i == '0':
		ans = i
		break
if len(s) >= 2 and ans == '':
	for i in range(len(s) - 1):
		for j in range(i + 1, len(s)):
			if divmod(int(s[i] + s[j]), 8)[1] == 0:
				ans = s[i] + s[j]
				break
		if ans != '':
			break
if len(s) >= 3 and ans == '':
	for i in range(len(s) - 2):
		for j in range(i + 1, len(s) - 1):
			for k in range(j + 1, len(s)):
				if divmod(int(s[i] + s[j] + s[k]), 8)[1] == 0:
					ans = s[i] + s[j] + s[k]
					break
			if ans != '':
				break
		if ans != '':
			break
if ans == '':
	print('NO')
else:
	print('YES')
	print(ans)
finish = time.time()


s = input()

def subseq(s, sub):
	last = -1
	for ch in sub:
		last = s.find(ch, last + 1)
		if last < 0:
			return False
	return True
for e in range(0, 1001, 8):
	if subseq(s, str(e)):
		print('YES')
		print(e)
		exit(0)
print('NO')


import sys
import string
from collections import Counter, defaultdict
from math import fsum, sqrt, gcd, ceil, factorial
from itertools import combinations, permutations
flush = lambda : sys.stdout.flush
comb = lambda x, y: factorial(x) // factorial(y) // factorial(x - y)
ip = lambda : input()
ii = lambda : int(input())
r = lambda : map(int, input().split())
rr = lambda : list(r())
s = input()
x = enumerate(s)
ans = ''
for i in range(len(s)):
	if int(s[i]) % 8 == 0:
		exit(print('YES', s[i], sep='\n'))
	for j in range(i + 1, len(s)):
		if int(s[i] + s[j]) % 8 == 0:
			exit(print('YES', s[i] + s[j], sep='\n'))
		for k in range(j + 1, len(s)):
			if int(s[i] + s[j] + s[k]) % 8 == 0:
				exit(print('YES', s[i] + s[j] + s[k], sep='\n'))
print('NO')


import math
import sys
chain = input()
chainLen = len(chain)
aux = 0
while aux < 1000:
	chain2 = str(aux)
	chainLen2 = len(chain2)
	check = 0
	flag = 0
	for i in range(0, chainLen):
		if chain2[check] == chain[i]:
			check += 1
		if check == chainLen2:
			flag = 1
			break
	if flag == 1:
		ans = aux
		break
	aux += 8
if flag == 1:
	print('YES')
	print(ans)
else:
	print('NO')


import re
found_num = -1
num = input()
for i in range(0, 10000, 8):
	regEx = '.*'.join(list(str(i)))
	if re.search(regEx, num):
		found_num = i
		break
if found_num != -1:
	print('YES')
	print(found_num)
else:
	print('NO')


class Solver:

	def __init__(self):
		self.n = None

	def main(self):
		self.n = input().strip()
		l = len(self.n)
		for i in range(l):
			i1 = int(self.n[i])
			if i1 % 8 == 0:
				print('Yes\n{}'.format(i1))
				return
			for j in range(i + 1, l):
				i2 = int(self.n[i] + self.n[j])
				if i2 % 8 == 0 and i2 != 0:
					print('Yes\n{}'.format(i2))
					return
				for k in range(j + 1, l):
					i3 = int(self.n[i] + self.n[j] + self.n[k])
					if i3 % 8 == 0 and i3 != 0:
						print('Yes\n{}'.format(i3))
						return
		print('No')
Solver().main()


def f(s):
	before = [None] * 10
	digits = [False] * 10
	until = [None] * 10
	before[0] = [True, False, False, False, False, False, False, False, False, False]
	until[0] = True
	digits[0] = True
	for c in s:
		c = ord(c) - ord('0')
		for (b, bval) in enumerate(digits):
			if bval is True:
				for (a, aval) in enumerate(before[b]):
					if aval is True:
						num = a * 100 + b * 10 + c
						if num % 8 == 0:
							return (a, b, c)
		digits[c] = True
		before[c] = list(until)
		if not until[c]:
			until[c] = True
	return None
assert f('11111111111111111111112111111111') == (1, 1, 2)
assert f('8') == (0, 0, 8)
assert f('3454') == (3, 4, 4)
assert f('10') == (0, 0, 0)
assert f('111111') is None
S = input()
ans = f(S)
if ans is None:
	print('NO')
else:
	print('YES')
	print(int(''.join([str(x) for x in ans])))


D = [[str(i * 8), 0, len(str(i * 8))] for i in range(200)]
s = input()
div = False
for c in s:
	if div:
		break
	for d in D:
		if c == d[0][d[1]]:
			d[1] += 1
			if d[1] == d[2]:
				print('YES')
				print(d[0])
				div = True
				break
if not div:
	print('NO')


s = input()
n = len(s)
if '0' in s:
	print('YES')
	print(0)
	exit(0)
for i in range(n):
	for j in range(i + 1, n):
		for k in range(j + 1, n):
			t = int(s[i] + s[j] + s[k])
			if t % 8 == 0:
				print('YES')
				print(t)
				exit(0)
		t = int(s[i] + s[j])
		if t % 8 == 0:
			print('YES')
			print(t)
			exit(0)
	t = int(s[i])
	if t % 8 == 0:
		print('YES')
		print(t)
		exit(0)
print('NO')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	s = S()
	l = len(s)
	for i in range(l):
		si = s[i]
		if int(si) % 8 == 0:
			return 'YES\n{}'.format(si)
		for j in range(i + 1, l):
			sj = si + s[j]
			if int(sj) % 8 == 0:
				return 'YES\n{}'.format(sj)
			for k in range(j + 1, l):
				sk = sj + s[k]
				if int(sk) % 8 == 0:
					return 'YES\n{}'.format(sk)
	return 'NO'
print(main())


def findDiv(div):
	for i in divs:
		if str(i) in div:
			return i
	return -1
n = input()
n = list(n)
divs = [8 * i for i in range(26)]
can = -1
while int(n[len(n) - 1]) % 2 != 0 and len(n) > 2:
	n.pop()
can = findDiv(''.join(n))
if int(''.join(n)) % 8 == 0:
	print('YES\n{}'.format(''.join(n)))
elif can != -1:
	print('YES\n{}'.format(can))
else:
	aux = []
	num = len(n) - 1
	while num > 0:
		aux = n[:]
		aux.pop(num)
		if int(''.join(aux)) % 8 == 0:
			can = ''.join(aux)
			break
		else:
			can = findDiv(''.join(aux))
			if can != -1:
				break
		num -= 1
	if can != -1:
		print('YES \n{}'.format(can))
	else:
		print('NO')


def isSubSequence(subString, string, m=-1, n=-1):
	if m == -1:
		m = len(subString)
	if n == -1:
		n = len(string)
	if m == 0:
		return True
	if n == 0:
		return False
	if subString[m - 1] == string[n - 1]:
		return isSubSequence(subString, string, m - 1, n - 1)
	return isSubSequence(subString, string, m, n - 1)
line = input()
possibilities = [str(8 * k) for k in range(125)]
for e in possibilities:
	if isSubSequence(e, line):
		print('YES\n' + e)
		exit()
print('NO')


def diveight(n):
	for i in range(len(n) - 1, -1, -1):
		x1 = int(n[i])
		if x1 % 8 == 0:
			return x1
		for j in range(i - 1, -1, -1):
			x2 = x1 + int(n[j]) * 10
			if x2 % 8 == 0:
				return x2
			for k in range(j - 1, -1, -1):
				x3 = x2 + int(n[k]) * 100
				if x3 % 8 == 0:
					return x3
	return -1
n = input()
x = diveight(n)
if x >= 0:
	print('YES')
	print(x)
else:
	print('NO')


R = lambda : map(int, input().split())
ds = list(map(int, input()))
for i in range(len(ds)):
	if ds[i] % 8 == 0:
		print('YES\n' + str(ds[i]))
		exit(0)
	for j in range(i):
		num = 10 * ds[j] + ds[i]
		if num % 8 == 0:
			print('YES\n' + str(num))
			exit(0)
		for k in range(j):
			res = 100 * ds[k] + 10 * ds[j] + ds[i]
			if res % 8 == 0:
				print('YES\n' + str(res))
				exit(0)
print('NO')


n = input()
n = '00' + n
for i in range(len(n)):
	for j in range(i + 1, len(n)):
		for k in range(j + 1, len(n)):
			a = (ord(n[i]) - 48) * 100 + (ord(n[j]) - 48) * 10 + (ord(n[k]) - 48)
			if a % 8 == 0:
				print('YES')
				print(a)
				exit(0)
print('NO')


n = input()
f = 0
for i in range(len(n)):
	if int(n[i]) % 8 == 0:
		print('YES')
		print(n[i])
		f = 1
		break
if f == 0:
	for i in range(len(n)):
		if f == 1:
			break
		for j in range(i + 1, len(n)):
			if int(n[i] + n[j]) % 8 == 0:
				print('YES')
				print(n[i] + n[j])
				f = 1
				break
if f == 0:
	for k in range(len(n)):
		if f == 1:
			break
		for i in range(k + 1, len(n)):
			if f == 1:
				break
			for j in range(i + 1, len(n)):
				if int(n[k] + n[i] + n[j]) % 8 == 0:
					print('YES')
					print(n[k] + n[i] + n[j])
					f = 1
					break
if f == 0:
	print('NO')


from itertools import combinations as comb
s = input()
n = len(s)
res = 0
found = False
if n <= 2:
	if int(s) % 8 == 0:
		res = s
		found = True
	elif n == 2:
		if int(s[0]) % 8 == 0:
			res = s[0]
			found = True
		elif int(s[1]) % 8 == 0:
			res = s[1]
			found = True
else:
	arr = [i for i in range(n)]
	for index in arr:
		num = int(s[index])
		if num % 8 == 0:
			found = True
			res = num
			break
	if not found:
		for index in comb(arr, 2):
			(a, b) = index
			num = int(s[a] + s[b])
			if num % 8 == 0:
				found = True
				res = num
				break
	if not found:
		for index in comb(arr, 3):
			(a, b, c) = index
			num = int(s[a] + s[b] + s[c])
			if num % 8 == 0:
				found = True
				res = num
				break
if not found:
	print('NO')
else:
	print('YES')
	print(res)


def sub_3(num_list, n):
	for i in range(n):
		sub_num = num_list[i]
		if sub_num % 8 == 0:
			return sub_num
		for j in range(i + 1, n):
			sub_num2 = sub_num * 10 + num_list[j]
			if sub_num2 % 8 == 0:
				return sub_num2
			for k in range(j + 1, n):
				sub_num3 = sub_num2 * 10 + num_list[k]
				if sub_num3 % 8 == 0:
					return sub_num3
	return -1
num_list = list(map(int, input()))
n = len(num_list)
result = sub_3(num_list, n)
if result == -1:
	print('NO')
else:
	print('YES')
	print(result)


s = input('')
x = int(s)
s = list(s)
n = len(s)
for i in range(n):
	s[i] = int(s[i])
if x % 8 == 0:
	print('YES')
	print(x)
elif s.count(8) != 0:
	print('YES')
	print(8)
elif s.count(0) != 0:
	print('YES')
	print(0)
else:
	sol = -1
	flag = 0
	for i in range(n):
		for j in range(i + 1, n):
			num = int(str(s[i]) + str(s[j]))
			if num % 8 == 0:
				sol = num
				flag = 1
				break
		if flag:
			break
	if sol != -1:
		print('YES')
		print(sol)
	else:
		for i in range(n):
			for j in range(i + 1, n):
				for k in range(j + 1, n):
					num = int(str(s[i]) + str(s[j]) + str(s[k]))
					if num % 8 == 0:
						sol = num
						flag = 1
						break
				if flag:
					break
			if flag:
				break
		if sol != -1:
			print('YES')
			print(sol)
		else:
			print('NO')


s = input()
for i in range(0, 1000, 8):
	x = 0
	for j in str(i):
		x = s.find(j, x)
		if x == -1:
			break
		x += 1
	if x != -1:
		print('YES')
		print(str(i))
		exit()
print('NO')


import sys
import itertools
numInp = [int(x) for x in input()]
aux = numInp[:]
num = 0
newNum = 0
message = False
list1 = itertools.combinations(numInp, 1)
list2 = itertools.combinations(numInp, 2)
list3 = itertools.combinations(numInp, 3)
for combinations in list1:
	if combinations[0] % 8 == 0:
		ans = combinations[0]
		message = True
if message == False:
	for combinations in list2:
		joinNum = 0
		for numbers in range(0, len(combinations)):
			joinNum = joinNum * 10 + combinations[numbers]
		if joinNum % 8 == 0:
			ans = joinNum
			print('YES')
			print(ans)
			sys.exit(0)
			break
		else:
			message = False
	if message == False:
		for combinations in list3:
			joinNum = 0
			for numbers in range(0, len(combinations)):
				joinNum = joinNum * 10 + combinations[numbers]
			if joinNum % 8 == 0:
				ans = joinNum
				print('YES')
				print(ans)
				sys.exit(0)
				break
			else:
				message == False
		if message == False:
			print('NO')
elif message == True:
	print('Yes')
	print(ans)


s = input()
while len(s) > 0 and int(s[-1]) % 2 == 1:
	s = s[:-1]
while len(s) > 1 and int(s[-2:]) % 4 != 0:
	s = s[:len(s) - 2] + s[len(s) - 1:]
while len(s) > 2 and int(s[-3:]) % 8 != 0:
	s = s[:len(s) - 3] + s[len(s) - 2:]
if len(s) > 0 and int(s[-3:]) % 8 == 0:
	print('YES')
	print(s)
else:
	print('NO')


from itertools import combinations
s = input()
l = list(combinations(s, 3)) + list(combinations(s, 2)) + list(combinations(s, 1))
f = True
for i in range(len(l)):
	n = int(''.join(l[i]))
	if n % 8 == 0:
		print('YES')
		print(n)
		f = False
		break
if f:
	print('NO')


n = str(input())
n += '1' * (3 - len(n))
f = False
m = len(n)
for a in range(-2, m - 2):
	if f:
		break
	for b in range(a + 1, m - 1):
		if f:
			break
		for c in range(b + 1, m):
			k = ''
			if a >= 0:
				k += n[a]
			if b >= 0:
				k += n[b]
			k += n[c]
			if int(k) % 8 == 0:
				print('YES', int(k), sep='\n')
				f = True
				break
if not f:
	print('NO')


import re

def main():
	mode = 'filee'
	if mode == 'file':
		f = open('test.txt', 'r')
	get = lambda : [int(x) for x in (f.readline() if mode == 'file' else input()).split()]
	n = input()
	for i in range(0, 125):
		x = i * 8
		x = list(str(x))
		x = '.*'.join(x)
		if re.search(x, n) != None:
			print('YES', i * 8)
			return
	print('NO')
	if mode == 'file':
		f.close()
main()


n = input().strip()
ll = []
for i in range(16, 1001, 8):
	ll.append(str(i))
if '0' in n:
	print('YES\n0')
elif '8' in n:
	print('YES\n8')
else:
	f = False
	p = n
	for i in ll:
		n = p
		q = ''
		for j in range(len(i)):
			l = n.find(i[j])
			if l != -1:
				q += i[j]
				n = n[l + 1:]
			else:
				break
		if len(q) == len(i):
			f = True
			print('YES\n' + q)
			break
	print('NO' if f == False else '')


from itertools import combinations

def solve():
	n = '00' + input()
	for s in (int(n[i] + n[j] + n[k]) for (i, j, k) in combinations(range(len(n)), 3)):
		if s % 8 == 0:
			print('YES\n{}'.format(s))
			exit(0)
	print('NO')
solve()


s = input()
a = 'NO'
for i in [str(i) for i in range(1000) if i % 8 == 0]:
	t = -1
	for c in i:
		t = s.find(c, t + 1)
		if t == -1:
			break
	if t != -1:
		a = 'YES\n' + i
print(a)


line = '00' + str(input())
size = len(line)
res = 0
flag = False
for i in range(0, size):
	for j in range(i + 1, size):
		for k in range(j + 1, size):
			res = int(line[i] + line[j] + line[k])
			if res % 8 == 0:
				flag = True
				break
		if flag:
			break
	if flag:
		break
if flag:
	print('YES')
	print(res)
else:
	print('NO')


def checker(text):
	n = text
	if any((n[i] == '0' for i in range(len(n)))):
		print('YES')
		print('0')
		return
	elif any((n[i] == '8' for i in range(len(n)))):
		print('YES')
		print('8')
		return
	else:
		for i in range(len(n) - 1, 0, -1):
			if int(n[i]) % 2 == 0:
				for j in range(i - 1, -1, -1):
					if int(n[j] + n[i]) % 8 == 0:
						print('YES')
						print(n[j] + n[i])
						return
					for k in range(j - 1, -1, -1):
						if int(n[k] + n[j] + n[i]) % 8 == 0:
							print('YES')
							print(n[k] + n[j] + n[i])
							return
		print('NO')
		return
checker(input())


s = input()
if int(s) % 8 == 0:
	print('YES')
	print(s)
elif s.count('0') != 0:
	print('YES')
	print('0')
elif s.count('8') != 0:
	print('YES')
	print('8')
else:
	bdr = 0
	res = ''
	for k in range(2, 125):
		j = 8 * k
		t = s
		i = str(j)
		p = ''
		if len(i) == 2 and int(i) < int(s):
			i0 = i[0]
			i1 = i[1]
			x1 = s.find(i0)
			if x1 != -1 and x1 != len(s) - 1:
				t = s[x1 + 1:len(s)]
				if t.find(i1) != -1:
					bdr = 1
					res = i
					break
		if len(i) == 3 and int(i) < int(s):
			i0 = i[0]
			i1 = i[1]
			i2 = i[2]
			x1 = s.find(i0)
			if x1 != -1 and x1 != len(s) - 1:
				t = s[x1 + 1:len(s)]
				x2 = t.find(i1)
				if x2 != len(s) - 1 and x2 != -1:
					p = t[x2 + 1:len(s)]
					if p.find(i2) != -1:
						bdr = 1
						res = i
						break
	if bdr == 1:
		print('YES')
		print(res)
	else:
		print('NO')


seqs = ['%03d' % (8 * n) for n in range(1000 // 8)]
num = '00' + input()
ans = None
for s in seqs:
	a = num.find(s[0])
	if a != -1:
		b = num[a + 1:].find(s[1])
		if b != -1:
			b += a + 1
			c = num[b + 1:].find(s[2])
			if c != -1:
				c += b + 1
				ans = num[a] + num[b] + num[c]
				while len(ans) > 1 and ans[0] == '0':
					ans = ans[1:]
				break
if ans is not None:
	print('YES')
	print(ans)
else:
	print('NO')


def ans(s):
	if '8' in s:
		print('YES')
		print('8')
		return None
	elif '0' in s:
		print('YES')
		print('0')
		return None
	else:
		for i in range(len(s)):
			for j in range(i + 1, len(s)):
				num = int(s[i] + s[j])
				if num % 8 == 0:
					print('YES')
					print(num)
					return None
				for k in range(j + 1, len(s)):
					num = int(s[i] + s[j] + s[k])
					if num % 8 == 0:
						print('YES')
						print(num)
						return None
	print('NO')
s = input()
ans(s)


dig = {}
for i in range(0, 1000, 8):
	dig[i] = list(map(int, list(str(i))))
num = int(input())
found = False
if num == 0:
	print('YES\n0')
	found = True
while num and (not found):
	d = num % 10
	num //= 10
	for (k, v) in dig.items():
		if v[-1] == d:
			v.pop(-1)
			if len(v) == 0:
				print('YES\n{}'.format(k))
				found = True
				break
print('NO' if not found else '')


import re
a = ['[0-9]*0[0-9]*', '[0-9]*8[0-9]*', '[0-9]*1[0-9]*6[0-9]*', '[0-9]*2[0-9]*4[0-9]*', '[0-9]*3[0-9]*2[0-9]*', '[0-9]*4[0-9]*0[0-9]*', '[0-9]*4[0-9]*8[0-9]*', '[0-9]*5[0-9]*6[0-9]*', '[0-9]*6[0-9]*4[0-9]*', '[0-9]*7[0-9]*2[0-9]*', '[0-9]*8[0-9]*0[0-9]*', '[0-9]*8[0-9]*8[0-9]*', '[0-9]*9[0-9]*6[0-9]*', '[0-9]*1[0-9]*0[0-9]*4[0-9]*', '[0-9]*1[0-9]*1[0-9]*2[0-9]*', '[0-9]*1[0-9]*2[0-9]*0[0-9]*', '[0-9]*1[0-9]*2[0-9]*8[0-9]*', '[0-9]*1[0-9]*3[0-9]*6[0-9]*', '[0-9]*1[0-9]*4[0-9]*4[0-9]*', '[0-9]*1[0-9]*5[0-9]*2[0-9]*', '[0-9]*1[0-9]*6[0-9]*0[0-9]*', '[0-9]*1[0-9]*6[0-9]*8[0-9]*', '[0-9]*1[0-9]*7[0-9]*6[0-9]*', '[0-9]*1[0-9]*8[0-9]*4[0-9]*', '[0-9]*1[0-9]*9[0-9]*2[0-9]*', '[0-9]*2[0-9]*0[0-9]*0[0-9]*', '[0-9]*2[0-9]*0[0-9]*8[0-9]*', '[0-9]*2[0-9]*1[0-9]*6[0-9]*', '[0-9]*2[0-9]*2[0-9]*4[0-9]*', '[0-9]*2[0-9]*3[0-9]*2[0-9]*', '[0-9]*2[0-9]*4[0-9]*0[0-9]*', '[0-9]*2[0-9]*4[0-9]*8[0-9]*', '[0-9]*2[0-9]*5[0-9]*6[0-9]*', '[0-9]*2[0-9]*6[0-9]*4[0-9]*', '[0-9]*2[0-9]*7[0-9]*2[0-9]*', '[0-9]*2[0-9]*8[0-9]*0[0-9]*', '[0-9]*2[0-9]*8[0-9]*8[0-9]*', '[0-9]*2[0-9]*9[0-9]*6[0-9]*', '[0-9]*3[0-9]*0[0-9]*4[0-9]*', '[0-9]*3[0-9]*1[0-9]*2[0-9]*', '[0-9]*3[0-9]*2[0-9]*0[0-9]*', '[0-9]*3[0-9]*2[0-9]*8[0-9]*', '[0-9]*3[0-9]*3[0-9]*6[0-9]*', '[0-9]*3[0-9]*4[0-9]*4[0-9]*', '[0-9]*3[0-9]*5[0-9]*2[0-9]*', '[0-9]*3[0-9]*6[0-9]*0[0-9]*', '[0-9]*3[0-9]*6[0-9]*8[0-9]*', '[0-9]*3[0-9]*7[0-9]*6[0-9]*', '[0-9]*3[0-9]*8[0-9]*4[0-9]*', '[0-9]*3[0-9]*9[0-9]*2[0-9]*', '[0-9]*4[0-9]*0[0-9]*0[0-9]*', '[0-9]*4[0-9]*0[0-9]*8[0-9]*', '[0-9]*4[0-9]*1[0-9]*6[0-9]*', '[0-9]*4[0-9]*2[0-9]*4[0-9]*', '[0-9]*4[0-9]*3[0-9]*2[0-9]*', '[0-9]*4[0-9]*4[0-9]*0[0-9]*', '[0-9]*4[0-9]*4[0-9]*8[0-9]*', '[0-9]*4[0-9]*5[0-9]*6[0-9]*', '[0-9]*4[0-9]*6[0-9]*4[0-9]*', '[0-9]*4[0-9]*7[0-9]*2[0-9]*', '[0-9]*4[0-9]*8[0-9]*0[0-9]*', '[0-9]*4[0-9]*8[0-9]*8[0-9]*', '[0-9]*4[0-9]*9[0-9]*6[0-9]*', '[0-9]*5[0-9]*0[0-9]*4[0-9]*', '[0-9]*5[0-9]*1[0-9]*2[0-9]*', '[0-9]*5[0-9]*2[0-9]*0[0-9]*', '[0-9]*5[0-9]*2[0-9]*8[0-9]*', '[0-9]*5[0-9]*3[0-9]*6[0-9]*', '[0-9]*5[0-9]*4[0-9]*4[0-9]*', '[0-9]*5[0-9]*5[0-9]*2[0-9]*', '[0-9]*5[0-9]*6[0-9]*0[0-9]*', '[0-9]*5[0-9]*6[0-9]*8[0-9]*', '[0-9]*5[0-9]*7[0-9]*6[0-9]*', '[0-9]*5[0-9]*8[0-9]*4[0-9]*', '[0-9]*5[0-9]*9[0-9]*2[0-9]*', '[0-9]*6[0-9]*0[0-9]*0[0-9]*', '[0-9]*6[0-9]*0[0-9]*8[0-9]*', '[0-9]*6[0-9]*1[0-9]*6[0-9]*', '[0-9]*6[0-9]*2[0-9]*4[0-9]*', '[0-9]*6[0-9]*3[0-9]*2[0-9]*', '[0-9]*6[0-9]*4[0-9]*0[0-9]*', '[0-9]*6[0-9]*4[0-9]*8[0-9]*', '[0-9]*6[0-9]*5[0-9]*6[0-9]*', '[0-9]*6[0-9]*6[0-9]*4[0-9]*', '[0-9]*6[0-9]*7[0-9]*2[0-9]*', '[0-9]*6[0-9]*8[0-9]*0[0-9]*', '[0-9]*6[0-9]*8[0-9]*8[0-9]*', '[0-9]*6[0-9]*9[0-9]*6[0-9]*', '[0-9]*7[0-9]*0[0-9]*4[0-9]*', '[0-9]*7[0-9]*1[0-9]*2[0-9]*', '[0-9]*7[0-9]*2[0-9]*0[0-9]*', '[0-9]*7[0-9]*2[0-9]*8[0-9]*', '[0-9]*7[0-9]*3[0-9]*6[0-9]*', '[0-9]*7[0-9]*4[0-9]*4[0-9]*', '[0-9]*7[0-9]*5[0-9]*2[0-9]*', '[0-9]*7[0-9]*6[0-9]*0[0-9]*', '[0-9]*7[0-9]*6[0-9]*8[0-9]*', '[0-9]*7[0-9]*7[0-9]*6[0-9]*', '[0-9]*7[0-9]*8[0-9]*4[0-9]*', '[0-9]*7[0-9]*9[0-9]*2[0-9]*', '[0-9]*8[0-9]*0[0-9]*0[0-9]*', '[0-9]*8[0-9]*0[0-9]*8[0-9]*', '[0-9]*8[0-9]*1[0-9]*6[0-9]*', '[0-9]*8[0-9]*2[0-9]*4[0-9]*', '[0-9]*8[0-9]*3[0-9]*2[0-9]*', '[0-9]*8[0-9]*4[0-9]*0[0-9]*', '[0-9]*8[0-9]*4[0-9]*8[0-9]*', '[0-9]*8[0-9]*5[0-9]*6[0-9]*', '[0-9]*8[0-9]*6[0-9]*4[0-9]*', '[0-9]*8[0-9]*7[0-9]*2[0-9]*', '[0-9]*8[0-9]*8[0-9]*0[0-9]*', '[0-9]*8[0-9]*8[0-9]*8[0-9]*', '[0-9]*8[0-9]*9[0-9]*6[0-9]*', '[0-9]*9[0-9]*0[0-9]*4[0-9]*', '[0-9]*9[0-9]*1[0-9]*2[0-9]*', '[0-9]*9[0-9]*2[0-9]*0[0-9]*', '[0-9]*9[0-9]*2[0-9]*8[0-9]*', '[0-9]*9[0-9]*3[0-9]*6[0-9]*', '[0-9]*9[0-9]*4[0-9]*4[0-9]*', '[0-9]*9[0-9]*5[0-9]*2[0-9]*', '[0-9]*9[0-9]*6[0-9]*0[0-9]*', '[0-9]*9[0-9]*6[0-9]*8[0-9]*', '[0-9]*9[0-9]*7[0-9]*6[0-9]*', '[0-9]*9[0-9]*8[0-9]*4[0-9]*', '[0-9]*9[0-9]*9[0-9]*2[0-9]*']
m = input()
for i in a:
	if re.search(i, m) != None:
		print('YES\n' + i.replace('[0-9]*', ''))
		exit()
print('NO')


s = input()
n = len(s)
for i in range(n):
	if int(s[i]) % 8 == 0:
		print('YES', s[i], sep='\n')
		exit(0)
	for j in range(i + 1, n):
		son = int(s[i] + s[j])
		if son % 8 == 0:
			print('YES', son, sep='\n')
			exit(0)
		for k in range(j + 1, n):
			hozi = son * 10 + int(s[k])
			if hozi % 8 == 0:
				print('YES', hozi, sep='\n')
				exit(0)
print('NO')


l = input()
a = 0
m = [int(l[x]) for x in range(len(l))]
for x in range(len(m)):
	if m[x] in [0, 8]:
		a = 1
		b = m[x]
		break
	else:
		pass
if a != 1:
	for x in range(len(m)):
		for y in range(x + 1, len(m)):
			if (10 * m[x] + m[y]) % 8 == 0:
				a = 1
				b = 10 * m[x] + m[y]
				break
			else:
				pass
else:
	pass
if a != 1:
	for x in range(len(m)):
		for y in range(x + 1, len(m)):
			for z in range(y + 1, len(m)):
				if (4 * m[x] + 2 * m[y] + m[z]) % 8 == 0:
					a = 1
					b = 100 * m[x] + 10 * m[y] + m[z]
					break
				else:
					pass
else:
	pass
if a == 1:
	print('YES')
	print(b)
else:
	print('NO')


def subseq(s1, s2, m, n):
	if n == 0:
		return True
	if m == 0:
		return False
	if s1[m - 1] == s2[n - 1]:
		return subseq(s1, s2, m - 1, n - 1)
	return subseq(s1, s2, m - 1, n)
mults_of_eight = map(str, [i * 8 for i in range(125)])
s = input()
for m in mults_of_eight:
	if subseq(s, m, len(s), len(m)):
		print('YES')
		print(m)
		break
else:
	print('NO')


s = input()
n = len(s)
ans = -1
if n >= 3:
	for i in range(n):
		c = int(s[i])
		if c % 8 == 0:
			ans = c
		for j in range(i + 1, n):
			c = int(s[i] + s[j])
			if c % 8 == 0:
				ans = c
			for k in range(j + 1, n):
				c = int(s[i] + s[j] + s[k])
				if c % 8 == 0:
					ans = c
elif n == 1:
	if int(s) % 8 == 0:
		ans = int(s)
elif int(s) % 8 == 0:
	ans = int(s)
elif int(s[0]) % 8 == 0:
	ans = int(s[0])
elif int(s[1]) % 8 == 0:
	ans = int(s[1])
if ans != -1:
	print('YES')
	print(ans)
else:
	print('NO')


import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *

class Scanner:

	@staticmethod
	def int():
		return int(sys.stdin.readline().rstrip())

	@staticmethod
	def string():
		return sys.stdin.readline().rstrip()

	@staticmethod
	def map_int():
		return [int(x) for x in Scanner.string().split()]

	@staticmethod
	def string_list(n):
		return [input() for i in range(n)]

	@staticmethod
	def int_list_list(n):
		return [Scanner.map_int() for i in range(n)]

	@staticmethod
	def int_cols_list(n):
		return [int(input()) for i in range(n)]

class Math:

	@staticmethod
	def gcd(a, b):
		if b == 0:
			return a
		return Math.gcd(b, a % b)

	@staticmethod
	def lcm(a, b):
		return a * b // Math.gcd(a, b)

	@staticmethod
	def divisor(n):
		res = []
		i = 1
		for i in range(1, int(n ** 0.5) + 1):
			if n % i == 0:
				res.append(i)
				if i != n // i:
					res.append(n // i)
		return res

	@staticmethod
	def round_up(a, b):
		return -(-a // b)

	@staticmethod
	def is_prime(n):
		if n < 2:
			return False
		if n == 2:
			return True
		if n % 2 == 0:
			return False
		d = int(n ** 0.5) + 1
		for i in range(3, d + 1, 2):
			if n % i == 0:
				return False
		return True

class PriorityQueue:

	def __init__(self, l=[]):
		self.q = l
		heapq.heapify(self.q)
		return

	def push(self, n):
		heapq.heappush(self.q, n)
		return

	def pop(self):
		return heapq.heappop(self.q)

def pop_count(x):
	x = x - (x >> 1 & 6148914691236517205)
	x = (x & 3689348814741910323) + (x >> 2 & 3689348814741910323)
	x = x + (x >> 4) & 1085102592571150095
	x = x + (x >> 8)
	x = x + (x >> 16)
	x = x + (x >> 32)
	return x & 127
MOD = int(1000000000.0) + 7
INF = int(1000000000000000.0)

def main():
	S = Scanner.string()
	for i in range(len(S)):
		l = int(S[i])
		if l % 8 == 0:
			print('YES')
			print(l)
			return
		for j in range(i + 1, len(S)):
			l = int(S[i] + S[j])
			if l % 8 == 0:
				print('YES')
				print(l)
				return
			for k in range(j + 1, len(S)):
				l = int(S[i] + S[j] + S[k])
				if l % 8 == 0:
					print('YES')
					print(l)
					return
	print('NO')
main()


a = input()
if '0' in a:
	print('YES')
	print('0')
	exit()
elif '8' in a:
	print('YES')
	print('8')
	exit()
else:
	for i in range(len(a)):
		for x in range(i + 1, len(a)):
			p = int(a[i] + a[x])
			if p % 8 == 0:
				print('YES')
				print(p)
				exit()
			for z in range(x + 1, len(a)):
				c = int(a[i] + a[x] + a[z])
				if c % 8 == 0:
					print('YES')
					print(c)
					exit()
print('NO')


n = input()

def pan(n):
	for i in n:
		if i == '0':
			print('YES')
			print('0')
			return
		elif i == '8':
			print('YES')
			print('8')
			return
	for i in range(len(n) - 1, -1, -1):
		if int(n[i]) % 2 == 0:
			for j in range(i - 1, -1, -1):
				if int(n[j] + n[i]) % 8 == 0:
					print('YES')
					print(n[j] + n[i])
					return
				elif int(n[j] + n[i]) % 4 == 0:
					for k in range(j - 1, -1, -1):
						if int(n[k] + n[j] + n[i]) % 8 == 0:
							print('YES')
							print(n[k] + n[j] + n[i])
							return
	print('NO')
pan(n)


def main():
	s = '00' + input()
	l = len(s)
	for i in range(l - 2):
		for j in range(i + 1, l - 1):
			for k in range(j + 1, l):
				rezwan = int(s[i] + s[j] + s[k])
				if rezwan % 8 == 0:
					return print('YES\n', rezwan)
	return print('NO\n')
main()


def lcs(X, Y):
	m = len(X)
	n = len(Y)
	L = [[None] * (n + 1) for i in range(m + 1)]
	for i in range(m + 1):
		for j in range(n + 1):
			if i == 0 or j == 0:
				L[i][j] = 0
			elif X[i - 1] == Y[j - 1]:
				L[i][j] = L[i - 1][j - 1] + 1
			else:
				L[i][j] = max(L[i - 1][j], L[i][j - 1])
	return L[m][n]
p = []
for i in range(8, 999):
	if i % 8 == 0:
		p.append(i)
n = input()
t = [int(i) for i in n]
if '0' in n:
	print('YES')
	print(0)
elif sum(t) == 8:
	print('YES')
	print(int(n))
else:
	f = 0
	for i in range(len(p)):
		if lcs(str(p[i]), n) == len(str(p[i])):
			f = 1
			print('YES')
			print(p[i])
			break
	if f != 1:
		print('NO')


import sys
input = sys.stdin.readline

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0, hi=None):
	if hi == None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p + p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

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

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math
from bisect import bisect_left

def solve():
	n = input()
	ans = 0
	for x in range(0, 1000, 8):
		i = -1
		for c in str(x):
			i = n.find(c, i + 1)
			if i < 0:
				break
		else:
			print('YES')
			print(x)
			break
	else:
		print('NO')
for _ in range(1):
	solve()


s = input()

def issubseq_s(z):
	j = 0
	for i in s:
		if i == z[j]:
			j += 1
		if j == len(z):
			return 1
	return 0
for x in range(0, 1000, 8):
	t = str(x)
	if issubseq_s(t):
		print('YES')
		print(x)
		quit()
print('NO')


s = input()
if '8' in s:
	print('YES')
	print(8)
elif '0' in s:
	print('YES')
	print(0)
else:
	l = len(s)
	f = False
	for i in range(l - 1):
		if f:
			break
		for j in range(i + 1, l):
			if int(s[i] + s[j]) % 8 == 0:
				f = int(s[i] + s[j])
			if f:
				break
			for k in range(j + 1, l):
				if int(s[i] + s[j] + s[k]) % 8 == 0:
					f = s[i] + s[j] + s[k]
					break
	if f:
		print('YES')
		print(f)
	else:
		print('NO')


s = input()
a = int(s)
if a % 8 == 0:
	print('YES')
	print(a)
else:
	n = len(s)
	if n == 1:
		if a % 8 == 0:
			print('YES')
			print(a)
		else:
			print('NO')
	elif n == 2:
		if '0' in s:
			print('YES')
			print(0)
		elif '8' in s:
			print('YES')
			print(8)
		else:
			print('NO')
	elif '0' in s:
		print('YES')
		print(0)
	elif '8' in s:
		print('YES')
		print(8)
	else:
		f = 0
		for i in range(n - 2):
			for j in range(i + 1, n - 1):
				for k in range(j + 1, n):
					temp = int(s[i]) * 100 + int(s[j]) * 10 + int(s[k])
					if temp % 8 == 0:
						f = 1
						break
				if f == 1:
					break
			if f == 1:
				break
		if f == 1:
			print('YES')
			print(temp)
		else:
			for i in range(n - 1):
				for j in range(i + 1, n):
					temp = int(s[i]) * 10 + int(s[j])
					if temp % 8 == 0:
						f = 1
						break
				if f == 1:
					break
			if f == 1:
				print('YES')
				print(temp)
			else:
				print('NO')


totaliters = 0

def removeEle(string, index):
	return string[:index] + string[index + 1:]
dptable = {}

def byEight(num):
	global totaliters
	if num in dptable:
		return dptable[num]
	if num % 8 == 0:
		dptable[num] = (num, True)
		return (num, True)
	else:
		totaliters += 1
		if num < 10:
			dptable[num] = (-1, False)
			return (-1, False)
		index = 0
		number = str(num)
		if totaliters > 100000:
			print('NO')
			exit()
		for _char in number:
			temp = byEight(int(removeEle(number, index)))
			if temp[1]:
				dptable[num] = temp
				return temp
			index += 1
		dptable[num] = (-1, False)
		return (-1, False)
case = input()
if '0' in case:
	print('YES')
	print('0')
	exit()
for x in range(len(case))[::-1]:
	if int(case[x]) % 2 != 0:
		continue
	case = case[:x + 1]
	break
superodd = True
for char in case:
	if int(char) % 2 == 0:
		superodd = False
		break
if superodd:
	print('NO')
	exit()
answer = byEight(int(case))
if answer[1]:
	print('YES')
	print(answer[0])
else:
	print('NO')


import math
m = 1000000007

def fact(n):
	ans = 1
	for i in range(1, n + 1):
		ans = ans % m * (i % m) % m
	return ans

def power_2(n):
	ans = 1
	for i in range(n):
		ans = ans % m * 2 % m
	return ans
s = input()
a = []
for i in range(0, 125):
	a.append(str(8 * i))
for i in range(0, len(a)):
	cnt = 0
	p = ''
	for j in range(0, len(s)):
		if cnt == 0 and a[i][0] == s[j]:
			cnt += 1
			p += s[j]
		elif len(a[i]) >= 2 and cnt == 1 and (a[i][1] == s[j]):
			cnt += 1
			p += s[j]
		elif len(a[i]) >= 3 and cnt == 2 and (a[i][2] == s[j]):
			p += s[j]
			cnt += 1
	if p == a[i]:
		print('YES')
		print(a[i])
		exit()
print('NO')


s = input()
(t, f) = ('00' + s, 1)
for i in range(len(t) - 2):
	for j in range(i + 1, len(t) - 1):
		for y in range(j + 1, len(t)):
			if int(t[i] + t[j] + t[y]) % 8 == 0 and f:
				print('YES')
				print(int(t[i] + t[j] + t[y]))
				f = 0
if f:
	print('NO')


MOD = 1000000007
MOD2 = 998244353
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
s = si()
n = len(s)
for i in range(n):
	for j in range(i + 1, n):
		for k in range(j + 1, n):
			l = [s[i] + s[j] + s[k], s[i] + s[j], s[j] + s[k], s[i] + s[k], s[i], s[j], s[k]]
			for x in l:
				if int(x) % 8 == 0:
					print('YES')
					print(int(x))
					exit()
if s[0] in '08':
	print('YES')
	print(s[0])
elif n > 1 and s[1] in '08':
	print('YES')
	print(s[1])
elif n > 1 and int(s) % 8 == 0:
	print('YES')
	print(s)
else:
	print('NO')


n = input()
m8 = []
num = 0
while num < 1000:
	m8.append(str(num))
	num += 8

def is_subseq(a, b):
	idx = 0
	sidx = 0
	res = False
	while idx < len(b) and sidx < len(a):
		if b[idx] == a[sidx]:
			sidx += 1
			if sidx == len(a):
				res = True
		idx += 1
	return res
res = False
resn = -1
for i in m8:
	if is_subseq(i, n):
		res = True
		resn = i
if res:
	print('YES')
	print(resn)
else:
	print('NO')


from itertools import combinations
from typing import Optional

def main() -> None:
	solution = solve()
	if solution is None:
		print('NO')
	else:
		print('YES')
		print(solution)

def solve() -> Optional[int]:
	num_str = input()
	for k in range(1, 4):
		for comb_tuple in combinations(num_str, k):
			comb = int(''.join(comb_tuple))
			if comb % 8 == 0:
				return comb
	return None
main()


x = int(input())
s = str(x)
n = len(s)
ans = ''
final = 0
flag = 0
for i in range(n):
	ans = ''
	ans += s[i]
	if int(ans) % 8 == 0:
		flag = 1
		final = int(ans)
		break
	for j in range(i + 1, n):
		ans = s[i]
		if i != j:
			temp = ans + s[j]
			if int(temp) % 8 == 0:
				flag = 1
				final = int(temp)
				break
			ans = temp
			for k in range(j + 1, n):
				if j != k and k != i:
					temp = ans + s[k]
					if int(temp) % 8 == 0:
						flag = 1
						final = int(temp)
						break
			if flag == 1:
				break
		ans = s[i]
		if flag == 1:
			break
	if flag == 1:
		break
if flag == 1:
	print('YES')
	print(final)
else:
	print('NO')


n = input()
l = len(n)
f = 0
for i in range(l):
	if int(n[i]) % 8 == 0:
		f = 1
		print('YES')
		print(n[i])
		break
if f == 0 and l > 1:
	for i in range(l - 1):
		for j in range(i + 1, l):
			if n[i] != '0' and (10 * int(n[i]) + int(n[j])) % 8 == 0:
				print('YES')
				print(10 * int(n[i]) + int(n[j]))
				f = 1
				break
		if f == 1:
			break
if f == 0 and l > 2:
	flg = 0
	for i in range(l - 2):
		for j in range(i + 1, l - 1):
			for k in range(j + 1, l):
				if n[i] != '0' and (100 * int(n[i]) + 10 * int(n[j]) + int(n[k])) % 8 == 0:
					print('YES')
					print(100 * int(n[i]) + 10 * int(n[j]) + int(n[k]))
					f = 1
					flg = 1
					break
			if flg == 1:
				break
		if flg == 1:
			break
if f == 0:
	print('NO')


import re
myString = input()
for i in range(0, 1000, 8):
	if re.search('.*'.join(list(str(i))), myString):
		print('YES')
		print(i)
		quit()
print('NO')


from itertools import combinations
number = '00' + input()
for w in (int(number[i] + number[j] + number[k]) for (i, j, k) in combinations(range(len(number)), 3)):
	if w % 8 == 0:
		print('YES\n{}'.format(w))
		exit(0)
print('NO')


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
from queue import PriorityQueue
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
from itertools import permutations
n = list(input())
if int(''.join(n)) % 8 == 0:
	print('YES')
	print(''.join(n))
	exit()
for i in range(len(n)):
	a = n[i]
	if int(a) % 8 == 0:
		print('YES')
		print(a)
		exit()
	for j in range(i + 1, len(n)):
		b = n[j]
		if int(a + b) % 8 == 0:
			if a != '0':
				print('YES')
				print(a + b)
				exit()
		for k in range(j + 1, len(n)):
			c = n[k]
			if int(a + b + c) % 8 == 0:
				if a != '0':
					print('YES')
					print(a + b + c)
					exit()
print('NO')


a = list(input()[::-1])
m = [False, 0]
if '0' in a:
	m[0] = True
	m[1] = 0
if '8' in a:
	m[0] = True
	m[1] = 8
for x in range(len(a)):
	if m[0]:
		break
	if int(a[x]) % 2 == 0:
		if a[x] == '0' or a[x] == '8':
			m[0] = True
			break
		for y in range(x + 1, len(a)):
			if m[0]:
				break
			s = a[y] + a[x]
			if int(s) % 8 == 0:
				m[1] = s
				m[0] = True
				break
			if int(s) % 4 == 0:
				for z in range(y + 1, len(a)):
					t = int(a[z] + s)
					if t % 8 == 0:
						m[1] = t
						m[0] = True
						break
if m[0]:
	print('YES')
	print(m[1])
else:
	print('NO')


n = input()
len_n = len(n)
flag = False
result = ''
for i in range(len_n):
	a = n[i]
	if int(a) % 8 == 0:
		flag = True
		result = a
		break
	for j in range(i + 1, len_n):
		b = a + n[j]
		if int(b) % 8 == 0:
			flag = True
			result = b
			break
		for k in range(j + 1, len_n):
			c = b + n[k]
			if int(c) % 8 == 0:
				flag = True
				result = c
				break
if flag == True:
	print('YES')
	print(result)
else:
	print('NO')


def solve(s, res):
	n = len(s)
	a = set([s[i] for i in range(n)])
	a1 = a & res
	if len(a1) > 0:
		return a1.pop()
	b = set([s[i] + s[j] for i in range(n) for j in range(i + 1, n)])
	b1 = b & res
	if len(b1) > 0:
		return b1.pop()
	c = set([s[i] + s[j] + s[k] for i in range(n) for j in range(i + 1, n) for k in range(j + 1, n)])
	c1 = c & res
	if len(c1) > 0:
		return c1.pop()
n = input()
res = set([str(x) for x in range(1001) if x % 8 == 0])
ans = solve(n, res)
flag = ans is not None
print('YES' if flag else 'NO')
if flag:
	print(ans)


lectura = input()
conclusion = 'NO'
for multiplos8 in [str(i) for i in range(1000) if i % 8 == 0]:
	marcador = -1
	for intento2 in multiplos8:
		marcador = lectura.find(intento2, marcador + 1)
		if marcador == -1:
			break
	if marcador != -1:
		conclusion = 'YES' + '\n' + str(multiplos8)
print(conclusion)


def isSubseq(s, x):
	(i, j) = (0, 0)
	while True:
		if j == len(x):
			return True
		if i == len(s):
			return False
		if s[i] == x[j]:
			j += 1
		i += 1
n = input().strip()
if len(n) == 1:
	if n == '8' or n == '0':
		print('YES')
		print(n)
	else:
		print('NO')
elif len(n) == 2:
	if int(n) % 8 == 0:
		print('YES')
		print(n)
	elif '8' in n:
		print('YES')
		print(8)
	elif '0' in n:
		print('YES')
		print(0)
	else:
		print('NO')
else:
	poss = [str(i) for i in range(0, 1000, 8)]
	found = False
	for x in poss:
		if len(x) > len(n):
			break
		if isSubseq(n, x):
			found = True
			print('YES')
			print(x)
			break
	if not found:
		print('NO')


s = input()
a = [int(x) for x in s]
n = len(s)
for i in range(n):
	if a[i] % 8 == 0:
		print('YES')
		print(a[i])
		exit()
ans = []
for i in range(n):
	for j in range(i + 1, n):
		if (a[i] * 10 + a[j]) % 8 == 0:
			print('YES')
			print(a[i] * 10 + a[j])
			exit()
		for k in range(j + 1, n):
			if (a[i] * 100 + a[j] * 10 + a[k]) % 8 == 0:
				print('YES')
				print(a[i] * 100 + a[j] * 10 + a[k])
				exit()
print('NO')


n = input()
m = len(n)
if '0' in n:
	print('YES')
	print(0)
elif '8' in n:
	print('YES')
	print(8)
else:
	f = 0
	for i in range(m):
		for j in range(i + 1, m):
			if int(n[i] + n[j]) % 8 == 0:
				f = 1
				out = int(n[i] + n[j])
				break
	if f == 1:
		print('YES')
		print(out)
	else:
		f = 0
		for i in range(m):
			for j in range(i + 1, m):
				for k in range(j + 1, m):
					if int(n[i] + n[j] + n[k]) % 8 == 0:
						out = int(n[i] + n[j] + n[k])
						f = 1
						break
		if f == 1:
			print('YES')
			print(out)
		else:
			print('NO')


s = list(map(int, list(str(input()))))
first = {i: len(s) for i in range(10)}
last = {i: -1 for i in range(10)}
prefixes = {i: list((len(s) for i in range(len(s)))) for i in range(10)}
for (i, ch) in enumerate(s):
	first[ch] = min(first[ch], i)
	last[ch] = max(last[ch], i)
	for c in range(10):
		if i > 0:
			prefixes[c][i] = prefixes[c][i - 1]
	prefixes[ch][i] += 1
for i in range(0, 1000):
	if i % 8:
		continue
	q = list(map(int, list(str(i))))
	if len(q) == 1 and first[q[0]] != len(s):
		print('YES')
		print(i)
		exit(0)
	if len(q) == 2 and first[q[0]] < last[q[1]]:
		print('YES')
		print(i)
		exit(0)
	if (len(q) == 3 and first[q[0]] < last[q[2]]) and prefixes[q[1]][last[q[2]] - 1] > prefixes[q[1]][first[q[0]]]:
		print('YES')
		print(i)
		exit(0)
print('NO')


n = input()
st = 0
nd = 1000
ic = 8
for x in range(st, nd, ic):
	i = -1
	for y in str(x):
		i = n.find(y, i + 1)
		if i < 0:
			break
	else:
		print('YES')
		print(x)
		break
else:
	print('NO')


def check(s, a):
	if s in a:
		print('YES')
		print(int(s))
		return 1
	else:
		return 0
a = input()
l = len(a)
flag = 0
s = ['8', '16', '24', '32', '40', '48', '56', '64', '72', '80', '88', '96', '0']
i = 0
while flag != 1 and i != 13:
	flag = check(s[i], a)
	i += 1
if flag == 0:
	for i in range(l - 2):
		for j in range(i + 1, l - 1):
			for k in range(j + 1, l):
				temp = int(a[i]) * 100 + int(a[j]) * 10 + int(a[k])
				if divmod(temp, 8)[1] == 0:
					flag = 1
					print('YES')
					print(temp)
					break
				else:
					continue
			else:
				continue
			break
		else:
			continue
		break
if flag == 0:
	for i in range(l - 1):
		for j in range(i + 1, l):
			temp = int(a[i]) * 10 + int(a[j])
			if divmod(temp, 8)[1] == 0:
				print('YES')
				print(temp)
				flag = 1
				break
if flag == 0:
	print('NO')


answer = ''

def exists(a, b):
	pos = 0
	global answer
	answer = ''
	for ch in a:
		if int(ch) % 8 == 0:
			digit = 0
		elif int(ch) % 4 == 0:
			digit = 4
		elif int(ch) % 2 == 0:
			digit = 2
		elif int(ch) % 2 != 0:
			digit = 1
		if pos < len(b) and str(digit) == b[pos]:
			answer = answer + ch
			pos += 1
	if pos == len(b):
		return True
	else:
		return False

def exists2(a, b):
	global answer
	answer = ''
	pos = 0
	for ch in a:
		if pos < len(b) and ch == b[pos]:
			answer = answer + ch
			pos += 1
	return pos == len(b)
number = input()
if exists(number, '0'):
	print('YES')
	print(answer)
elif exists(number, '24'):
	print('YES')
	print(answer)
elif exists2(number, '16'):
	print('YES')
	print(answer)
elif exists2(number, '32'):
	print('YES')
	print(answer)
elif exists2(number, '56'):
	print('YES')
	print(answer)
elif exists(number, '112'):
	print('YES')
	print(answer)
elif exists(number, '144'):
	print('YES')
	print(answer)
else:
	print('NO')


__author__ = 'Ismail_A'

def read():
	inputs = input().strip()
	return list(map(int, inputs.split()))

def read_pair():
	return map(int, input().split(' '))

def sorry_togda():
	return print('NO')
a = input()
vse_bitti = False
for i in range(len(a)):
	for j in range(i + 1, len(a)):
		for k in range(j + 1, len(a)):
			if (int(a[i]) * 100 + int(a[j]) * 10 + int(a[k])) % 8 == 0 and a[i] != '0' and (not vse_bitti):
				print('YES')
				print(str(a[i]) + str(a[j]) + str(a[k]))
				vse_bitti = True
if not vse_bitti:
	for i in range(len(a)):
		for j in range(i + 1, len(a)):
			if (int(a[i]) * 10 + int(a[j])) % 8 == 0 and a[i] != '0' and (not vse_bitti):
				print('YES')
				print(str(a[i]) + str(a[j]))
				vse_bitti = True
if not vse_bitti:
	for i in range(len(a)):
		if int(a[i]) % 8 == 0 and (not vse_bitti):
			print('YES')
			print(a[i])
			vse_bitti = True
if not vse_bitti:
	sorry_togda()


t = input()
if '0' in t:
	print('YES')
	print(0)
elif len(t) == 1:
	if t == '8':
		print('YES')
		print(8)
	else:
		print('NO')
elif len(t) == 2:
	if '8' in t:
		print('YES')
		print(8)
	elif int(t) % 8 == 0:
		print('YES')
		print(t)
	else:
		print('NO')
elif '8' in t:
	print('YES')
	print(8)
else:
	h = 0
	for j in range(8, 10000000, 8):
		a = str(j)
		u = ''
		s = 0
		for k in t:
			if s < len(a):
				if k == a[s]:
					u += k
					s += 1
		if u == a:
			print('YES')
			print(a)
			h += 1
			break
	if h == 0:
		print('NO')


s = str(input())
n = len(s)
a = []
l = ''
k = 0
for i in range(0, n):
	a += s[i]
for i in range(0, n):
	for j in range(i + 1, n):
		if i < n and j < n:
			l = s[i] + s[j]
			a += [l]
for i in range(0, n):
	for j in range(i + 1, n):
		for c in range(j + 1, n):
			if i < n and j < n and (c < n):
				l = s[i] + s[j] + s[c]
				a += [l]
for i in a:
	if int(i) % 8 == 0:
		print('YES')
		print(i)
		k = 1
		break
if k == 0:
	print('NO')


k = int(input())
a = '00' + str(k)
f = 0
for i in range(len(a)):
	for j in range(i + 1, len(a)):
		for k in range(j + 1, len(a)):
			s = int(a[i] + a[j] + a[k])
			if s % 8 == 0:
				print('YES')
				f = 1
				print(s)
				break
		if f == 1:
			break
	if f == 1:
		break
if f == 0:
	print('NO')


import re
n = input()
for i in range(0, 1000, 8):
	regex = '.*'.join(list(str(i)))
	if re.search(regex, n):
		print('YES')
		print(i)
		break
else:
	print('NO')


def FindNumber(n):
	for i in range(0, len(n)):
		if int(n[i]) % 8 == 0:
			return int(n[i])
		if i < len(n) - 1:
			for j in range(i + 1, len(n)):
				if int(n[i] + n[j]) % 8 == 0:
					return int(n[i] + n[j])
				if int(n[j]) % 8 == 0:
					return int(n[j])
				if i < len(n) - 2 or j < len(n) - 1:
					for k in range(j + 1, len(n)):
						if int(n[k]) % 8 == 0:
							return int(n[k])
						if int(n[i] + n[k]) % 8 == 0:
							return int(n[i] + n[k])
						if int(n[j] + n[k]) % 8 == 0:
							return int(n[j] + n[k])
						if int(n[i] + n[j] + n[k]) % 8 == 0:
							return int(n[i] + n[j] + n[k])
	return 'NO'
n = input()
result = FindNumber(n)
if result == 'NO':
	print(result)
else:
	print('YES')
	print(result)


arr = list(map(int, list(input())))
found = False
i = len(arr) - 1
while i >= 0 and (not found):
	if arr[i] == 0 or arr[i] == 8:
		print('YES')
		print(0 if arr[i] == 0 else 8)
		found = True
	i -= 1
i = len(arr) - 1
while not found and i >= 0:
	if arr[i] % 2 == 0:
		for j in range(i):
			if (10 * arr[j] + arr[i]) % 8 == 0:
				print('YES')
				print(10 * arr[j] + arr[i])
				found = True
				break
			for k in range(j):
				if (100 * arr[k] + 10 * arr[j] + arr[i]) % 8 == 0:
					print('YES')
					print(100 * arr[k] + 10 * arr[j] + arr[i])
					found = True
					break
			if found == True:
				break
	i -= 1
if found == False:
	print('NO')


from sys import stdin, stdout
n = str(input())
flag = False
for i in range(len(n)):
	if int(n[i]) % 8 == 0:
		flag = True
		s = n[i]
		break
if not flag:
	for i in range(len(n) - 1):
		for j in range(i + 1, len(n)):
			if int(n[i] + n[j]) % 8 == 0:
				s = n[i] + n[j]
				flag = True
				break
		if flag:
			break
if not flag:
	s = ''
	for i in range(len(n) - 2):
		for j in range(i + 1, len(n) - 1):
			for z in range(j + 1, len(n)):
				s = n[i] + n[j] + n[z]
				if int(s) % 8 == 0:
					flag = True
					break
			if flag:
				break
		if flag:
			break
if flag:
	print('YES')
	print(s)
else:
	print('NO')


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
import sys
sys.setrecursionlimit(5000)
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
s = input()
n = len(s)
for i in range(n):
	if int(s[i]) % 8 == 0:
		print('YES')
		print(s[i])
		exit()
	for j in range(i + 1, n):
		if int(s[i] + s[j]) % 8 == 0:
			print('YES')
			print(s[i] + s[j])
			exit()
		for k in range(j + 1, n):
			if int(s[i] + s[j] + s[k]) % 8 == 0:
				print('YES')
				print(s[i] + s[j] + s[k])
				exit()
print('NO')


lst = input()

def f(lst):
	(b2, b4, b6, b12, b52, b92, b44, b36, b76) = (False, False, False, False, False, False, False, False, False)
	for k in range(len(lst) - 1, -1, -1):
		a = int(lst[k])
		if a in [0, 8]:
			return 'YES\n' + str(a)
		elif a == 2:
			b2 = True
			if b4:
				return 'YES\n24'
		elif a == 4:
			if b4:
				b44 = True
			b4 = True
		elif a == 6:
			b6 = True
			if b4 == True:
				return 'YES\n64'
		elif a == 1:
			if b12:
				return 'YES\n112'
			if b44:
				return 'YES\n144'
			if b6:
				return 'YES\n16'
			if b52:
				return 'YES\n152'
			if b92:
				return 'YES\n192'
			if b2:
				b12 = True
		elif a == 5:
			if b6:
				return 'YES\n56'
			if b52:
				return 'YES\n552'
			if b92:
				return 'YES\n592'
			if b44:
				return 'YES\n544'
			if b12:
				return 'YES\n512'
			if b2:
				b52 = True
		elif a == 9:
			if b6:
				return 'YES\n96'
			if b52:
				return 'YES\n952'
			if b92:
				return 'YES\n992'
			if b44:
				return 'YES\n944'
			if b12:
				return 'YES\n912'
			if b2:
				b92 = True
		elif a == 3:
			if b2:
				return 'YES\n32'
			if b44:
				return 'YES\n344'
			if b76:
				return 'YES\n376'
			if b36:
				return 'YES\n336'
			if b6:
				b36 = True
		elif a == 7:
			if b2:
				return 'YES\n72'
			if b44:
				return 'YES\n744'
			if b76:
				return 'YES\n776'
			if b36:
				return 'YES\n736'
			if b6:
				b76 = True
	return 'NO'
print(f(lst))


from collections import defaultdict, Counter
from functools import lru_cache
from heapq import heappush, heappop
from math import gcd, floor, ceil
from sys import stdin, stdout

def ilist():
	return [int(x) for x in stdin.readline().strip().split(' ')]

def iint():
	return int(stdin.readline().strip())

def istr():
	return stdin.readline().strip()

def solve(n):
	for i in range(len(n)):
		if int(n[i]) % 8 == 0:
			print('YES')
			print(int(n[i]))
			return
	for i in range(len(n)):
		for j in range(i + 1, len(n)):
			if int(n[i] + n[j]) % 8 == 0:
				print('YES')
				print(int(n[i] + n[j]))
				return
	for i in range(len(n)):
		for j in range(i + 1, len(n)):
			for k in range(j + 1, len(n)):
				if int(n[i] + n[j] + n[k]) % 8 == 0:
					print('YES')
					print(int(n[i] + n[j] + n[k]))
					return
	print('NO')
n = istr()
solve(n)


def f(n, memo, index=0, currnum=0):
	key = (index, currnum)
	if key in memo:
		return memo[key]
	if currnum % 8 == 0 and currnum > 0:
		return (True, currnum)
	if currnum > 999 or index >= len(n):
		return (False, -1)
	a = f(n, memo, index + 1, currnum * 10 + int(n[index]))
	if a[0]:
		to_return = a
	else:
		b = f(n, memo, index + 1, currnum)
		if b[0]:
			to_return = b
		else:
			to_return = (False, -1)
	memo[key] = to_return
	return to_return
n = input()
if '0' in n:
	print('Yes')
	print(0)
else:
	memo = dict()
	d = dict()
	d[True] = 'Yes'
	d[False] = 'No'
	res = f(n, memo)
	print(d[res[0]])
	if res[0]:
		print(res[1])


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
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')
s = input()
if len(s) < 2:
	s = int(s)
	if s % 8 == 0:
		print('YES')
		print(s)
	else:
		print('NO')
else:
	res = -1
	n = len(s)
	for i in range(0, n - 2):
		a = int(s[i])
		for j in range(i + 1, n - 1):
			b = int(s[j])
			for k in range(j + 1, n):
				c = int(s[k])
				num = a * 100 + b * 10 + c
				if num % 8 == 0:
					res = num
					n = -1
	n = len(s)
	for i in s:
		if int(i) % 8 == 0:
			res = int(i)
			break
	for i in range(0, n - 1):
		a = int(s[i])
		for j in range(i + 1, n):
			b = int(s[j])
			num = a * 10 + b
			if num % 8 == 0:
				res = num
				n = -1
	if res == -1:
		print('NO')
	else:
		print('YES')
		print(res)


def doit(n):
	s = n
	for i in range(len(n)):
		if int(s[i]) % 8 == 0:
			n = s[i]
			return n
		for j in range(i + 1, len(n)):
			if (int(s[i]) * 10 + int(s[j])) % 8 == 0:
				n = s[i] + s[j]
				return n
			for k in range(j + 1, len(n)):
				if ((int(s[i]) * 10 + int(s[j])) * 10 + int(s[k])) % 8 == 0:
					n = s[i] + s[j] + s[k]
					return n
	return -1
s = doit(input())
if s == -1:
	print('No')
else:
	print('Yes')
	print(s)


def main():
	n = str(input())
	for i in range(len(n)):
		curr = n[i]
		if int(curr) % 8 == 0:
			print('YES')
			print(curr)
			return
		for j in range(i + 1, len(n)):
			curr += n[j]
			if int(curr) % 8 == 0:
				print('YES')
				print(curr)
				return
			for k in range(j + 1, len(n)):
				curr += n[k]
				if int(curr) % 8 == 0:
					print('YES')
					print(curr)
					return
				curr = curr[:-1]
			curr = n[i]
	if len(n) == 1:
		if int(n) % 8 == 0:
			print('YES')
			print(n)
		else:
			print('NO')
		return
	if len(n) < 3:
		if int(n[0]) % 8 == 0:
			print('YES')
			print(n[0])
		elif int(n[1]) % 8 == 0:
			print('YES')
			print(n[1])
		elif int(n) % 8 == 0:
			print('YES')
			print(n)
		else:
			print('NO')
		return
	print('NO')
main()


from collections import *
from random import *
from bisect import *
import sys
input = sys.stdin.readline

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

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

def inp():
	return int(input())
s = input().rstrip('\n')
r = ''
for i in range(len(s)):
	t = s[i]
	if int(t) % 8 == 0:
		r = t
	for j in range(i + 1, len(s)):
		t = s[i] + s[j]
		if int(t) % 8 == 0:
			r = t
		for k in range(j + 1, len(s)):
			t = s[i] + s[j] + s[k]
			if int(t) % 8 == 0:
				r = t
if len(r):
	print('YES')
	print(r)
else:
	print('NO')


import math, sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda : int(input())
li = lambda : list(map(int, input().split()))

def ind(s, i, h):
	for j in range(h, len(s)):
		if s[j] == i:
			return j
	return int(len(s))

def case():
	s = input().strip()
	k = 0
	while True:
		p = str(k * 8)
		inx = 0
		flag = 1
		for j in p:
			q = ind(s, j, inx)
			if q != len(s):
				inx = q + 1
			else:
				flag = 0
				break
		if flag:
			print('YES')
			print(p)
			exit()
		k += 1
		if len(p) > 3:
			break
	print('NO')
for _ in range(1):
	case()


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

def lcs(s1, s2, n, m):
	dp = [[0 for _ in range(m + 1)] for _ in range(n + 1)]
	for r in range(1, n + 1):
		for c in range(1, m + 1):
			if s2[c - 1] == s1[r - 1]:
				dp[r][c] = 1 + dp[r - 1][c - 1]
			else:
				dp[r][c] = max(dp[r - 1][c], dp[r][c - 1])
	return dp[n][m]

def main():
	n = int(input())
	if n == 0:
		print('YES')
		print(0)
		exit()
	while n % 2:
		n = n // 10
	if n == 0:
		print('NO')
		exit()
	n = list(str(n))
	l = []
	i = 0
	while i <= 1000:
		l.append(i)
		i += 8
	for item in l:
		item = list(str(item))
		if lcs(n, item, len(n), len(item)) == len(item):
			print('YES')
			print(''.join(item))
			break
	else:
		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()


from sys import stdin, stdout
from math import gcd, ceil, sqrt
from collections import Counter
from bisect import bisect_left, bisect_right
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
n = is1()
res = ''
for i in range(len(n)):
	for j in range(i + 1, len(n)):
		for k in range(j + 1, len(n)):
			t = n[i] + n[j] + n[k]
			if int(t) % 8 == 0:
				res = t
if not len(res):
	for i in range(len(n)):
		for j in range(i + 1, len(n)):
			t = n[i] + n[j]
			if int(t) % 8 == 0:
				res = t
if not res:
	for i in n:
		if int(i) % 8 == 0:
			res = i
if len(res):
	print('YES')
	print(int(res))
else:
	print('NO')


given = '00' + input()
l = len(given)
ans = 'NO'
for i in range(l):
	for j in range(i + 1, l):
		for k in range(j + 1, l):
			curr = given[i] + given[j] + given[k]
			curr = int(curr)
			if curr % 8 == 0:
				ans = 'YES'
				print(ans)
				print(curr)
				break
		if ans == 'YES':
			break
	if ans == 'YES':
		break
if ans == 'NO':
	print(ans)


num = input()
has_anwser = False
anwser_list = ['0', '8', '16', '24', '32', '56', '64', '72', '96', '112', '136', '144', '152', '176', '192', '312', '336', '344', '352', '376', '392', '512', '536', '544', '552', '576', '592', '712', '736', '744', '752', '776', '792', '912', '936', '944', '952', '976', '992']
for item in anwser_list:
	current_anwser = item
	for value in num:
		if current_anwser.startswith(value):
			current_anwser = current_anwser[1:]
			if current_anwser == '':
				has_anwser = True
				print('YES')
				print(item)
				break
	if has_anwser == True:
		break
if has_anwser == False:
	print('NO')


a = input()
f = 0
for i in range(len(a)):
	for j in range(i + 1, len(a)):
		for k in range(j + 1, len(a)):
			if a[i] != '0' and int(a[i] + a[j] + a[k]) % 8 == 0:
				print('YES')
				print(a[i] + a[j] + a[k])
				f = 1
				break
		if f:
			break
		if a[i] != '0' and int(a[i] + a[j]) % 8 == 0:
			print('YES')
			print(a[i] + a[j])
			f = 1
			break
	if f:
		break
	if int(a[i]) % 8 == 0:
		print('YES')
		print(a[i])
		f = 1
		break
if not f:
	print('NO')


n = input()
ans = 0
YES = 'YES'
NO = 'NO'
for i in range(0, len(n)):
	x = int(n[i])
	if x % 8 == 0:
		ans = 1
		print(YES)
		print(x)
		break
if ans != 1:
	for i in range(len(n) - 1, -1, -1):
		if ans == 1:
			break
		if int(n[i]) % 2 == 0:
			for j in range(i - 1, -1, -1):
				if ans == 1:
					break
				m = int(n[i]) + 10 * int(n[j])
				if m % 8 == 0:
					ans = 1
					print(YES)
					print(m)
					break
				elif m % 4 == 0:
					if ans == 1:
						break
					for k in range(j - 1, -1, -1):
						l = 100 * int(n[k]) + m
						if l % 8 == 0:
							ans = 1
							print(YES)
							print(l)
							break
if ans != 1:
	print(NO)


n = input()
lenN = len(n)
candiv8s = [str(x) for x in range(0, 1000, 8)]

def isPart(s1, s2):
	i = 0
	lenS2 = len(s2)
	for s in s1:
		while i < lenS2:
			if s2[i] == s:
				i += 1
				break
			i += 1
		else:
			return False
	return True
for candiv8 in candiv8s:
	if isPart(candiv8, n):
		print('YES')
		print(candiv8)
		exit(0)
print('NO')


l = list(map(int, input()))
o = 0
e = 0
for i in range(len(l)):
	if l[i] % 2 == 0:
		e = e + 1
	else:
		o = o + 1
n = len(l)
if o == len(l):
	print('NO')
else:
	t = 0
	for i in range(len(l)):
		if t == 1:
			break
		elif int(str(l[i])) % 8 == 0:
			print('yes')
			print(str(l[i]))
			t = 1
			break
		for j in range(i + 1, len(l)):
			if t == 1:
				break
			elif int(str(l[i]) + str(l[j])) % 8 == 0:
				print('yes')
				print(str(l[i]) + str(l[j]))
				t = 1
				break
			for k in range(j + 1, len(l)):
				if int(str(l[i]) + str(l[j]) + str(l[k])) % 8 == 0:
					print('yes')
					print(str(l[i]) + str(l[j]) + str(l[k]))
					t = 1
					break
	if t == 0:
		print('NO')


a = list(map(str, str(input())))
while int(''.join(a)) % 10 % 2 != 0 and len(a) > 1:
	del a[-1]
while int(''.join(a)) % 100 % 4 != 0 and len(a) >= 2:
	del a[-2]
while int(''.join(a)) % 1000 % 8 != 0 and len(a) >= 3:
	del a[-3]
if int(''.join(a)) % 8 == 0:
	print('YES')
	print(''.join(a))
else:
	print('NO')


from collections import defaultdict as dc
from collections import Counter
import sys
import math
mod = 10 ** 9 + 7

def sinp():
	p = str(sys.stdin.readline())
	return p

def seive(n):
	p = [0] * (n + 1)
	for i in range(2, n):
		for j in range(2 * i, n + 1, i):
			p[i] = 1
	return p

def inp():
	p = int(sys.stdin.readline())
	return p

def line():
	p = list(map(int, sys.stdin.readline().split()))
	return p

def read_mat():
	n = inp()
	a = []
	for i in range(n):
		a.append(line())
	return a

def solve(t):
	s = str(input())
	p = int(s)
	n = len(s)
	q = dc(int)
	for i in range(0, 100):
		if i % 8 == 0:
			q[i] += 1
	if p % 8 == 0:
		print('YES')
		print(s)
	elif n == 1:
		print('NO')
	elif n == 2:
		if s.count('0') > 0:
			print('YES')
			print(0)
		elif s.count('8') > 0:
			print('YES')
			print(8)
		else:
			print('NO')
	else:
		l = list(map(int, s))
		ans = 0
		for i in range(n):
			if q[l[i]]:
				print('YES')
				print(l[i])
				ans = 1
				break
			for j in range(i + 1, n):
				for k in range(j + 1, n):
					z = l[i] * 100 + l[j] * 10 + l[k]
					x = l[i] * 10 + l[j]
					y = l[i] * 10 + l[k]
					z1 = l[j] * 10 + l[k]
					if q[x]:
						print('YES')
						print(x)
						ans = 1
						break
					elif q[y]:
						print('YES')
						print(y)
						ans = 1
						break
					elif q[z1]:
						print('YES')
						print(z1)
						ans = 1
						break
					elif z % 8 == 0:
						print('YES')
						print(z)
						ans = 1
						break
				if ans == 1:
					break
			if ans == 1:
				break
		if ans == 0:
			print('NO')
t = 1
for _ in range(t):
	solve(t)


def func(s, i, ans, b):
	if ans % 8 == 0 and b:
		return ans
	if i < 0:
		return -1
	if ans > 99:
		return -1
	x = func(s, i - 1, ans, b)
	if x != -1:
		return x
	if ans > 9:
		ans += 100 * int(s[i])
		return func(s, i - 1, ans, b)
	elif ans > 0:
		ans += 10 * int(s[i])
		return func(s, i - 1, ans, b)
	else:
		ans = int(s[i])
		b = True
		return func(s, i - 1, ans, b)
s = input()
x = func(s, len(s) - 1, 0, False)
if x == -1:
	print('NO')
else:
	print('YES')
	print(x)


def solve(n):
	for q in (8 * i for i in range(125)):
		nums = list(str(q))
		for c in reversed(n):
			if c == nums[-1]:
				nums.pop()
			if not nums:
				return q

def main():
	n = input()
	ans = solve(n)
	ans = 'YES\n{}'.format(ans) if ans is not None else 'NO'
	print(ans)
main()


import sys
number = 0
for line in sys.stdin:
	number = int(line)

def is0_8(x):
	return x == '0' or x == '8'

def is2_4_6(x):
	return x == '2' or x == '4' or x == '6'

def find(s):
	l = len(s)
	num = s[l - 1]
	for i in range(l - 2, -1, -1):
		x = s[i] + num
		if int(x) % 8 == 0:
			return (True, x)
	for i in range(l - 2, 0, -1):
		for j in range(i - 1, -1, -1):
			x = s[j] + s[i] + num
			if int(x) % 8 == 0:
				return (True, x)
	return (False, 0)
num = 0
yes = False
hasOdd = False
snumber = str(number)
for ch in snumber:
	if is0_8(ch):
		yes = True
		num = int(ch)
		break
	if is2_4_6(ch):
		hasOdd = True
if not yes and hasOdd:
	idx = 0
	l = len(snumber)
	while idx < l:
		if is2_4_6(snumber[idx]):
			(found, num) = find(snumber[:idx + 1])
			if found:
				yes = True
				break
		idx += 1
if yes:
	print('YES')
	print(num)
else:
	print('NO')


def buildNumber(n, mask):
	strN = str(n)
	newN = 0
	for i in range(len(strN)):
		if mask & 1 << i:
			newN *= 10
			newN += int(strN[i])
	return newN

def is8k(n):
	return n % 1000 % 8 == 0

def solve(n):
	if n % 8 == 0:
		print('YES')
		print(n)
		return
	strN = str(n)
	for i in range(len(strN)):
		if strN[i] == '0':
			print('YES')
			print(0)
			return
		if strN[i] == '8':
			print('YES')
			print(8)
			return
	if len(str(n)) <= 6:
		mask = 1
		limit = pow(2, len(strN)) - 1
		while mask <= limit:
			newN = buildNumber(n, mask)
			if is8k(newN):
				print('YES')
				print(newN)
				return
			mask += 1
	for i in range(len(strN)):
		for j in range(i + 1, len(strN)):
			newN = 10 * int(strN[i]) + int(strN[j])
			if newN % 8 == 0:
				print('YES')
				print(newN)
				return
			for k in range(j + 1, len(strN)):
				newN = 100 * int(strN[i]) + 10 * int(strN[j]) + int(strN[k])
				if newN % 8 == 0:
					print('YES')
					print(newN)
					return
	print('NO')
n = int(input())
solve(n)


A = input()
list(A)
A = [int(i) for i in A]
if A[0] == 0:
	print('YES')
	print(0)
else:
	result = 'NO'
	for i in range(0, len(A)):
		for j in range(i + 1, len(A)):
			for k in range(j + 1, len(A)):
				if (100 * A[i] + 10 * A[j] + A[k]) % 8 == 0:
					result = 100 * A[i] + 10 * A[j] + A[k]
	for i in range(0, len(A)):
		for j in range(i + 1, len(A)):
			if (10 * A[i] + A[j]) % 8 == 0:
				result = 10 * A[i] + A[j]
	for i in range(0, len(A)):
		if A[i] == 0 or A[i] == 8:
			result = A[i]
	if result != 'NO':
		print('YES')
	print(result)


s = input()
n = len(s)
if n > 2:
	for x in range(n):
		if int(s[x]) % 8 == 0:
			print('YES')
			print(s[x])
			break
		else:
			pass
	if int(s[x]) % 8 == 0:
		pass
	else:
		for x in range(n - 1):
			for y in range(x + 1, n):
				m = int(s[x] + s[y])
				if m % 8 == 0:
					print('YES')
					print(m)
					break
				else:
					pass
			if m % 8 == 0:
				break
			else:
				pass
		if m % 8 == 0:
			pass
		else:
			for x in range(n - 2):
				for y in range(x + 1, n - 1):
					for z in range(y + 1, n):
						m = int(s[x] + s[y] + s[z])
						if m % 8 == 0:
							print('YES')
							print(s[x] + s[y] + s[z])
							break
						elif m % 8 != 0 and x != n - 3:
							pass
						else:
							print('NO')
					if m % 8 == 0:
						break
					else:
						pass
				if m % 8 == 0:
					break
				else:
					pass
elif n == 2:
	if int(s) % 8 == 0:
		print('YES')
		print(s)
	elif int(s[0]) % 8 == 0:
		print('YES')
		print(s[0])
	elif int(s[1]) % 8 == 0:
		print('YES')
		print(s[1])
	else:
		print('NO')
elif int(s) % 8 == 0:
	print('YES')
	print(s)
else:
	print('NO')


A = input()
n = len(A)
multiplos = [k for k in range(0, 100, 8)]
for k in range(n):
	if int(A[k]) in multiplos:
		print('YES')
		print(A[k])
		exit()
	for j in range(k + 1, n):
		if int(A[j]) in multiplos:
			print('YES')
			print(A[j])
			exit()
		if int(A[k] + A[j]) in multiplos:
			print('YES')
			print(A[k] + A[j])
			exit()
		for i in range(j + 1, n):
			if int(A[i]) in multiplos:
				print('YES')
				print(A[i])
				exit()
			if int(A[k] + A[i]) in multiplos:
				print('YES')
				print(A[k] + A[i])
				exit()
			if int(A[j] + A[i]) in multiplos:
				print('YES')
				print(A[j] + A[i])
				exit()
			if int(A[k] + A[j] + A[i]) % 8 == 0:
				res = int(A[k] + A[j] + A[i])
				print('YES')
				print(res)
				exit()
print('NO')


v = []
for i in input():
	v.append(int(i))
n = len(v)
succ = False
for i in range(0, n):
	for j in range(i, n):
		for k in range(j, n):
			if succ:
				continue
			s = set()
			s.add(i)
			s.add(j)
			s.add(k)
			r = 0
			z = []
			for x in s:
				z.append(x)
			z.sort()
			s = z
			for x in s:
				r *= 10
				r += v[x]
			if r % 8 == 0:
				succ = True
				print('YES')
				print(r)
if not succ:
	print('NO')


import re
i = input()
count_d = {str(c): i.count(str(c)) for c in range(10)}
div = [str(x * 8) for x in range(125)]
for d in div:
	pattern = '.*' + '.*'.join(d)
	if re.match(pattern, i):
		print('YES')
		print(d)
		break
else:
	print('NO')


import sys

def get_is_div8(n):
	for i in range(0, len(n)):
		if int(n[i]) % 8 == 0:
			return int(n[i])
	for i in range(0, len(n)):
		for j in range(i + 1, len(n)):
			if int(n[i] + n[j]) % 8 == 0:
				return int(n[i] + n[j])
	for i in range(0, len(n)):
		for j in range(i + 1, len(n)):
			for k in range(j + 1, len(n)):
				if int(n[i] + n[j] + n[k]) % 8 == 0:
					return int(n[i] + n[j] + n[k])
	return -1
for line in sys.stdin:
	result = get_is_div8(line.strip())
	if result == -1:
		print('NO')
	else:
		print('YES')
		print(result)


n1 = input()
n = []
for i in n1:
	n.append(int(i))
k = len(n)
for i in range(k):
	if n[i] % 8 == 0:
		print('YES')
		print(n[i])
		exit()
if k > 1:
	for i in range(k):
		t = n[i] * 10
		for j in range(i + 1, k):
			if (t + n[j]) % 8 == 0:
				print('YES')
				print(t + n[j])
				exit()
if k > 2:
	for i in range(k):
		t = n[i] * 100
		for j in range(i + 1, k):
			l = n[j] * 10
			for e in range(j + 1, k):
				if (t + l + n[e]) % 8 == 0:
					print('YES')
					print(t + l + n[e])
					exit()
print('NO')


n = input()
isBreak = 0
while True:
	for i in n:
		if int(i) % 8 == 0:
			print('YES')
			print(i)
			isBreak = 1
			break
	if isBreak == 1:
		break
	breakInner2 = 0
	for i in range(len(n)):
		for j in range(i + 1, len(n)):
			values = int(n[i] + n[j])
			if values % 8 == 0:
				print('YES')
				print(values)
				isBreak = 1
				breakInner2 = 1
				break
		if breakInner2 == 1:
			break
	if isBreak == 1:
		break
	breakInner3 = 0
	for i in range(len(n)):
		for j in range(i + 1, len(n)):
			for k in range(j + 1, len(n)):
				values = int(n[i] + n[j] + n[k])
				if values % 8 == 0:
					print('YES')
					print(values)
					breakInner3 = 1
					isBreak = 1
					break
			if breakInner3 == 1:
				break
		if breakInner3 == 1:
			break
	if isBreak == 1:
		break
	print('NO')
	break


x = input()
import re
for i in range(0, 1000, 8):
	s = '.*'.join([''] + list(str(i)) + [''])
	if re.search(s, x):
		print('YES')
		print(i)
		exit(0)
print('NO')


n = input()
s = '00' + n
ln = len(s)
for i in range(ln):
	for j in range(i + 1, ln):
		for k in range(j + 1, ln):
			res = s[i] + s[j] + s[k]
			if int(res) % 8 == 0:
				print('YES')
				print(int(res))
				exit()
print('NO')


n = input()
a = [str(i) for i in range(0, 1000, 8)]
for s in a:
	i = 0
	for c in n:
		if i == len(s):
			break
		if c == s[i]:
			i += 1
	if i == len(s):
		print('YES')
		print(s)
		exit()
print('NO')


import itertools
n = str(input())
length = len(n)
divis = False
for i in itertools.combinations(n, 1):
	if int(''.join(i)) % 8 == 0:
		print('YES')
		print(''.join(i))
		divis = True
		break
if divis == False and length >= 2:
	for i in itertools.combinations(n, 2):
		if int(''.join(i)) % 8 == 0:
			print('YES')
			print(''.join(i))
			divis = True
			break
if divis == False and length >= 3:
	for i in itertools.combinations(n, 3):
		if int(''.join(i)) % 8 == 0:
			print('YES')
			print(''.join(i))
			divis = True
			break
if divis == False:
	print('NO')


x = [int(c) for c in input()]
for i in range(len(x)):
	if x[i] in (0, 8):
		print('YES')
		print(x[i])
		exit()
	for j in range(i):
		if (x[j] * 10 + x[i]) % 8 == 0:
			print('YES')
			print(x[j] * 10 + x[i])
			exit()
		for k in range(j):
			if ((x[k] * 10 + x[j]) * 10 + x[i]) % 8 == 0:
				print('YES')
				print((x[k] * 10 + x[j]) * 10 + x[i])
				exit()
print('NO')


t = input()
n = '00' + t
flag = False
for i in range(len(n)):
	for j in range(i + 1, len(n)):
		for k in range(j + 1, len(n)):
			num = n[i] + n[j] + n[k]
			if int(num) % 8 == 0:
				print('YES')
				print(int(num))
				flag = True
			if flag == True:
				break
		if flag == True:
			break
	if flag == True:
		break
if flag == False:
	print('NO')


a = input()
n = len(a)
was = False
for i4 in range(n - 1, -1, -1):
	if was:
		break
	p = int(a[i4])
	if p % 8 == 0:
		print('YES')
		print(p)
		was = True
	if p % 2 != 0:
		continue
	for i3 in range(i4 - 1, -1, -1):
		if was:
			break
		p += int(a[i3]) * 10
		if p % 8 == 0:
			print('YES')
			print(p)
			was = True
		for i2 in range(i3 - 1, -1, -1):
			if was:
				break
			p += int(a[i2]) * 100
			if p % 8 == 0:
				print('YES')
				print(p)
				was = True
			else:
				p -= int(a[i2]) * 100
		p -= int(a[i3]) * 10
	p -= int(a[i4])
if not was:
	print('NO')


s = input()
n = len(s)
flag = 0
if n == 1:
	if (ord(s[0]) - 48) % 8 == 0:
		flag = 1
		print('YES')
		print(s[0])
if n == 2:
	if (ord(s[0]) - 48) % 8 == 0:
		flag = 1
		print('YES')
		print(s[0])
	elif (ord(s[1]) - 48) % 8 == 0:
		flag = 1
		print('YES')
		print(s[1])
	elif ((ord(s[0]) - 48) * 10 + (ord(s[1]) - 48)) % 8 == 0:
		print('YES')
		print(s[0] + s[1])
		flag = 1
for i in range(n - 2):
	if (ord(s[i]) - 48) % 8 == 0:
		print('YES')
		print(s[i])
		flag = 1
		break
	for j in range(i + 1, n - 1):
		if (ord(s[j]) - 48) % 8 == 0:
			print('YES')
			print(s[j])
			flag = 1
			break
		if ((ord(s[i]) - 48) * 10 + (ord(s[j]) - 48)) % 8 == 0:
			print('YES')
			print(s[i] + s[j])
			flag = 1
			break
		for k in range(j + 1, n):
			if (ord(s[k]) - 48) % 8 == 0:
				print('YES')
				print(s[k])
				flag = 1
				break
			if ((ord(s[i]) - 48) * 10 + (ord(s[k]) - 48)) % 8 == 0:
				print('YES')
				print(s[i] + s[k])
				flag = 1
				break
			if ((ord(s[j]) - 48) * 10 + (ord(s[k]) - 48)) % 8 == 0:
				print('YES')
				print(s[j] + s[k])
				flag = 1
				break
			if ((ord(s[i]) - 48) * 100 + (ord(s[j]) - 48) * 10 + (ord(s[k]) - 48)) % 8 == 0:
				print('YES')
				print(s[i] + s[j] + s[k])
				flag = 1
				break
		if flag == 1:
			break
	if flag == 1:
		break
if flag == 0:
	print('NO')


def getno(n, i, j, k):
	if i == j == k:
		return int(n[i])
	elif i != j and j != k:
		return int(n[i] + n[j] + n[k])
	return int(n[i] + n[k])
n = input()
l = len(n)
for i in range(l):
	check1 = False
	for j in range(i, l):
		check2 = False
		for k in range(j, l):
			val = getno(n, i, j, k)
			if val % 8 == 0:
				check2 = True
				print('YES')
				print(val)
				break
		if check2:
			check1 = True
			break
	if check1:
		break
if not check1:
	print('NO')


class Trie:

	def __repr__(self):
		return {k: v.__repr__() for (k, v) in self.table.items()}

	def __str__(self):
		return str(self.__repr__())

	def __init__(self):
		self.table = dict()

	def makeTrie(self, key, node):
		if key == '':
			self.table['isleaf'] = node
			return
		fst = key[0]
		if fst not in self.table.keys():
			self.table[fst] = Trie()
		self.table[fst].makeTrie(key[1:], node)

	def insert(self, s):
		self.makeTrie(s, s)

def solve(trie, n):
	pointers = set([trie])
	for ch in n:
		news = set([p.table[ch] for p in pointers if ch in p.table.keys()])
		check = list(filter(lambda p: 'isleaf' in p.table.keys(), news))
		if len(check) > 0:
			return check[0].table['isleaf']
		pointers = pointers | news
	return '-1'
res = [str(x) for x in range(1001) if x % 8 == 0]
root = Trie()
for x in res:
	root.insert(x)
n = input()
ans = solve(root, n)
flag = ans != '-1'
print('YES' if flag else 'NO')
if flag:
	print(ans)


import sys
import re

def main():
	N = sys.stdin.readline()
	for i in range(0, 993, 8):
		p = '.*' + '.*'.join(list(str(i))) + '.*'
		x = re.match(p, N)
		if x != None:
			print('YES')
			print(i)
			return
	print('NO\n')
	return
main()


ans = -1
n = input()

def dfs(start, end, count, temp):
	global ans
	if count <= 3 and temp & 7 == 0:
		ans = temp
		return
	if count > 3:
		return
	for i in range(end + 1, len(n)):
		dfs(start, i, count + 1, temp * 10 + int(n[i]))
for i in range(len(n)):
	count = 1
	dfs(i, i, count, int(n[i]))
	if ans != -1:
		break
if ans == -1:
	print('NO')
else:
	print('YES')
	print(ans)


import functools
import heapq as hp
import collections
import bisect
import math

def unpack(func=int):
	return map(func, input().split())

def l_unpack(func=int):
	return list(map(func, input().split()))

def s_unpack(func=int, rev=False):
	return sorted(map(func, input().split()), reverse=rev)

def ml_unpack(n):
	return [int(input()) for i in range(n)]

def range_n():
	return range(int(input()))

def getint():
	return int(input())

def counter(a):
	d = {}
	for x in a:
		if x in d:
			d[x] += 1
		else:
			d[x] = 1
	return d

def check(a):
	if a and (not int(''.join(a)) % 8):
		return True
	return False

def foo(a, lo, n, stack, memo):
	t = (lo, ''.join(stack))
	if t in memo:
		return memo[t]
	if n == lo or len(stack) > 3:
		if check(stack):
			memo[t] = True
			return True
		return False
	if check(stack):
		memo[t] = True
		return True
	stack.append(a[lo])
	f = foo(a, lo + 1, n, stack, memo)
	if f:
		memo[t] = f
		return True
	stack.pop()
	f = foo(a, lo + 1, n, stack, memo)
	if f:
		memo[t] = f
		return True
	memo[t] = f
	return False

def main():
	a = input()
	stack = []
	memo = {}
	foo(a, 0, len(a), stack, memo)
	if stack:
		ans = ''.join(stack)
		print('YES')
		print(ans)
	else:
		print('NO')
main()


s = '00' + input()
n = len(s)
flag = 0
for i in range(n):
	for j in range(i + 1, n):
		for k in range(j + 1, n):
			number = int(s[i] + s[j] + s[k])
			if number % 8 == 0:
				print('YES')
				print(number)
				exit()
print('NO')


def f(x):
	for (i, t) in enumerate(x, 1):
		if t in '13579':
			return g(t, x[i:])

def g(t, x):
	for (u, v) in ['12', '36', '44', '52', '76', '92']:
		i = x.find(u)
		if i != -1:
			j = x.find(v, i + 1)
			if j != -1:
				return t + u + v

def h(x):
	for (u, v) in ['16', '24', '32', '56', '64', '72', '96']:
		i = x.find(u)
		if i != -1:
			j = x.find(v, i + 1)
			if j != -1:
				return u + v
(t, x) = ('', input())
if '0' in x:
	t = '0'
elif '8' in x:
	t = '8'
else:
	t = h(x)
	if not t:
		t = f(x)
print('YES\n' + t if t else 'NO')


n = input()
for i in range(len(n)):
	if int(n[i]) % 8 == 0:
		print('YES')
		print(n[i])
		exit(0)
for i in range(len(n)):
	for j in range(0, i):
		if (int(n[j]) * 10 + int(n[i])) % 8 == 0:
			print('YES')
			print(n[j] + n[i])
			exit(0)
for i in range(len(n)):
	for j in range(0, i):
		for g in range(0, j):
			if (int(n[g]) * 100 + int(n[j]) * 10 + int(n[i])) % 8 == 0:
				print('YES')
				print(n[g] + n[j] + n[i])
				exit(0)
print('NO')


n = input()
for possible in range(0, 1000, 8):
	i = -1
	for ch in str(possible):
		i = n.find(ch, i + 1)
		if i < 0:
			break
	else:
		print('YES', possible, sep='\n')
		break
else:
	print('NO')


import sys
inf = float('inf')
mod = 1000000007

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

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

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

def main():
	n = input().strip()
	l = len(n)
	for i in range(l):
		if int(n[i]) % 8 == 0:
			print('YES')
			print(n[i])
			return
		for j in range(i + 1, l):
			if int(n[i] + n[j]) % 8 == 0:
				print('YES')
				print(n[i] + n[j])
				return
			for k in range(j + 1, l):
				if int(n[i] + n[j] + n[k]) % 8 == 0:
					print('YES')
					print(n[i] + n[j] + n[k])
					return
	print('NO')
main()


n = [int(x) for x in input()][::-1]

def f(x):
	if x % 8 == 0:
		print('YES')
		print(x)
		exit()
for (i, x) in enumerate(n):
	f(x)
	for (j, y) in enumerate(n[i + 1:], i + 1):
		f(x + 10 * y)
		for z in n[j + 1:]:
			f(x + 10 * y + 100 * z)
print('NO')


s = input()
b = 0
for i in range(len(s) + 1):
	for j in range(len(s) + 1):
		for k in range(len(s) + 1):
			if i < len(s) and (i == j or i == k):
				continue
			if j < len(s) and j == k:
				continue
			if not i <= j <= k:
				continue
			t = (s[i] if i < len(s) else '') + (s[j] if j < len(s) else '') + (s[k] if k < len(s) else '')
			if len(t) > 0 and int(t) % 8 == 0:
				print('YES\n' + str(int(t)))
				b = 1
				break
		if b == 1:
			break
	if b == 1:
		break
if b == 0:
	print('NO')


eg = list(str(input()))
for i in range(len(eg)):
	eg[i] = int(eg[i])
for i in range(0, len(eg) - 2):
	for j in range(i + 1, len(eg) - 1):
		for m in range(j + 1, len(eg)):
			if (eg[i] * 100 + eg[j] * 10 + eg[m]) % 8 == 0:
				print('YES')
				print(eg[i] * 100 + eg[j] * 10 + eg[m])
				exit(0)
for i in range(0, len(eg)):
	for j in range(i + 1, len(eg)):
		if (eg[i] * 10 + eg[j]) % 8 == 0:
			print('YES')
			print(eg[i] * 10 + eg[j])
			exit(0)
for i in range(0, len(eg)):
	if eg[i] % 8 == 0:
		print('YES')
		print(eg[i])
		exit(0)
print('NO')


x = input()
l = len(x)

def div(p):
	return not int(p) % 8
for i in range(l):
	a = x[i]
	if div(a):
		print('YES')
		print(a)
		exit()
	for j in range(i + 1, l):
		b = a + x[j]
		if div(b):
			print('YES')
			print(b)
			exit()
		for k in range(j + 1, l):
			c = b + x[k]
			if div(c):
				print('YES')
				print(c)
				exit()
print('NO')


from __future__ import division, print_function
from sys import stdin, stdout
import bisect
from bisect import bisect_left as bl
from bisect import bisect_right as br
import itertools
from collections import Counter
import collections
import math
import heapq
import re

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def most_frequent(list):
	return max(set(list), key=list.count)

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def ncr(n, r, p):
	t = fact[n] * (ifact[r] * ifact[n - r] % p) % p
	return t

def Convert(string):
	li = list(string.split(''))
	return li

def SieveOfEratosthenes(n):
	global prime
	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
	f = []
	for p in range(2, n):
		if prime[p]:
			f.append(p)
	return f
prime = []
q = []

def dfs(n, d, v, c):
	global q
	v[n] = 1
	x = d[n]
	q.append(n)
	j = c
	for i in x:
		if i not in v:
			f = dfs(i, d, v, c + 1)
			j = max(j, f)
	return j

def main():
	n = sin()
	for i in range(0, 1001, 8):
		i = str(i)
		count = 0
		for j in n:
			if j == i[count]:
				count += 1
				if count == len(i):
					print('YES')
					print(i)
					quit()
	print('NO')
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			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')
main()


n = str(input())
ans = -1

def string(n):
	a = ''
	for element in n:
		a += str(element)
	return a
while int(n[-1]) % 2 != 0 and len(n) != 1:
	n = list(n)
	n.pop(-1)
	n = string(n)
	n = str(n)
while ans % 8 != 0:
	length = len(str(n))
	if length < 2:
		if string(n) == '0' or string(n) == '8':
			ans = string(n)
		break
	if length == 2:
		if int(string(n)) % 8 == 0:
			ans = string(n)
		elif int(string(n)[1]) % 8 == 0:
			ans = string(n)[1]
		elif int(string(n)[0]) % 8 == 0:
			ans = string(n)[0]
		break
	elif int(n[:length - 3:-1][::-1]) % 4 == 0:
		if length == 3:
			if int(string(n)) % 8 == 0:
				ans = string(n)
				break
			else:
				n = list(n)
				n.pop(0)
				n = string(n)
				length = len(str(string(n)))
		elif length != 3:
			if int(n[:length - 4:-1][::-1]) % 8 == 0:
				ans = string(n)
				break
			else:
				n = list(n)
				n.pop(-3)
				n = string(n)
				length = len(str(string(n)))
	else:
		n = list(n)
		n.pop(-2)
		n = string(n)
		length = len(str(string(n)))
if ans != -1:
	print('YES')
	print(ans)
else:
	print('NO')


s = str(input())
flag = 0
ans = 0
for i in range(len(s)):
	v1 = int(s[i])
	if v1 % 8 == 0:
		flag = 1
		ans = v1
		break
	for j in range(i + 1, len(s)):
		if i != j:
			s1 = s[i] + s[j]
			v2 = int(s1)
			if v2 % 8 == 0:
				flag = 1
				ans = v2
				break
		for k in range(j + 1, len(s)):
			if i != j and j != k and (k != i):
				ss = s[i] + s[j] + s[k]
				val = int(ss)
				if val % 8 == 0:
					flag = 1
					ans = val
					break
		if flag == 1:
			break
	if flag == 1:
		break
check = 0
for i in s:
	if i == '0':
		check = 1
		break
if flag == 1:
	print('YES')
	print(ans)
elif check == 1:
	print('YES')
	print(0)
else:
	print('NO')


s = input()

def chk(ss):
	global s
	ll = -1
	for i in ss:
		ll = s.find(i, ll + 1)
		if ll < 0:
			return 0
	return 1
for i in range(0, 1001, 8):
	if chk(str(i)):
		print('YES')
		print(i)
		exit()
print('NO')


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
mod = pow(10, 9) + 7
mod2 = 998244353

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

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
s = list(data())
for i in s:
	if int(i) % 8 == 0:
		out('YES')
		out(i)
		exit()
n = len(s)
for i in range(n - 1):
	for j in range(i + 1, n):
		temp = int(s[i]) * 10 + int(s[j])
		if temp % 8 == 0:
			out('YES')
			out(temp)
			exit()
for i in range(n - 2):
	for j in range(i + 1, n - 1):
		for k in range(j + 1, n):
			temp = int(s[i]) * 100 + int(s[j]) * 10 + int(s[k])
			if temp % 8 == 0:
				out('YES')
				out(temp)
				exit()
out('NO')


import re

def finder(x, y, z):
	st = '[0-9]*[' + x + ']+[0-9]*[' + y + ']+[0-9]*[' + z + ']'
	return re.compile(st)

def finder2(x, y):
	st = '[0-9]*[' + x + ']+[0-9]*[' + y + ']'
	return re.compile(st)
l = []
for i in range(100, 1000):
	if not i % 8:
		src = [j for j in str(i)]
		l.append([finder(src[0], src[1], src[2]), i])
for i in range(10, 100):
	if not i % 8:
		src = [j for j in str(i)]
		l.append([finder2(src[0], src[1]), i])
l.append([re.compile('[0-9]*[8]+'), 8])
s = input()
f = None
if '0' in s:
	print('YES')
	print(0)
else:
	for i in l:
		if i[0].match(s):
			f = i[1]
			break
	if f:
		print('YES')
		print(f)
	else:
		print('NO')


n = input()
if int(n[-3:]) % 8 == 0:
	print('YES')
	print(n)
else:
	l = len(n)
	op = 'ud'
	no = -1
	for i in n:
		if int(i) % 8 == 0:
			op = 'YES'
			no = int(i)
	if op == 'ud':
		for i in range(l):
			for j in range(i + 1, l):
				if int(n[i] + n[j]) % 8 == 0:
					op = 'YES'
					no = int(n[i] + n[j])
	if op == 'ud':
		for i in range(l):
			for j in range(i + 1, l):
				for k in range(j + 1, l):
					if int(n[i] + n[j] + n[k]) % 8 == 0:
						op = 'YES'
						no = int(n[i] + n[j] + n[k])
	if op == 'ud':
		print('NO')
	else:
		print(op)
		print(no)


import re

def p(n):
	for i in range(0, 1000, 8):
		r = '.*'.join([''] + list(str(i)) + [''])
		if re.search(r, n):
			print('YES')
			print(i)
			return None
	print('NO')
	return None
n = input()
p(n)


n = input()

def f(num):
	for x in range(0, 1000, 8):
		(s, count) = (str(x), 0)
		for i in num:
			if i == s[count]:
				count += 1
			if count == len(str(x)):
				print('YES')
				print(x)
				return True
	print('NO')
	return False
f(n)


def main():
	s = list(input())
	s.append('')
	s.append('')
	n = len(s)
	for i in range(n):
		for j in range(i + 1, n):
			for k in range(j + 1, n):
				num = int(s[i] + s[j] + s[k])
				if num % 8 == 0:
					print('YES')
					print(num)
					return
	print('NO')
main()


def main():
	s = input()
	if '0' in s or '8' in s:
		print('YES')
		print('0' if '0' in s else '8')
	else:
		for i in range(len(s) - 2):
			x = (ord(s[i]) - 48) * 100
			for j in range(i + 1, len(s) - 1):
				y = (ord(s[j]) - 48) * 10
				for k in range(j + 1, len(s)):
					z = ord(s[k]) - 48
					if x + y + z & 7 == 0:
						print('YES')
						print(x + y + z)
						return
		for i in range(len(s) - 1):
			x = (ord(s[i]) - 48) * 10
			for j in range(i + 1, len(s)):
				y = ord(s[j]) - 48
				if x + y & 7 == 0:
					print('YES')
					print(x + y)
					return
		print('NO')
main()


from math import *
a = input()
nums = []
for i in range(0, 1000, 8):
	nums.append([x for x in str(i)])
ha = False
for x in nums:
	ci = 0
	i = 0
	while i < len(a):
		if a[i] == x[ci]:
			ci += 1
		if ci == len(x):
			ha = True
			break
		i += 1
	if ha:
		print('YES')
		print(''.join(x))
		break
if not ha:
	print('NO')


flag = 'NO'
ans = ''

def mai():
	n = input()
	l = len(n)
	global flag, ans
	if '0' in n:
		flag = 'YES'
		ans = '0'
		return
	if '8' in n:
		flag = 'YES'
		ans = '8'
		return
	for i in range(l):
		for j in range(i + 1, l):
			for k in range(j + 1, l):
				if int(n[i] + n[j] + n[k]) % 8 == 0:
					flag = 'YES'
					ans = n[i] + n[j] + n[k]
					return
				elif int(n[i] + n[j]) % 8 == 0:
					flag = 'YES'
					ans = n[i] + n[j]
					return
				elif int(n[i] + n[k]) % 8 == 0:
					flag = 'YES'
					ans = n[i] + n[k]
					return
				elif int(n[j] + n[k]) % 8 == 0:
					flag = 'YES'
					ans = n[j] + n[k]
					return
mai()
print(flag)
print(ans)


lis = list(input())
n = len(lis)
ans = 0
aa = [2, 4, 8]
c = 0
for i in range(n - 1, -1, -1):
	tmp = ans + int(lis[i]) * 10 ** c
	if tmp % aa[c] == 0:
		ans = tmp
		c += 1
	if c == 3:
		break
if c == 0 or ans % 8 != 0:
	print('NO')
else:
	print('YES')
	print(ans)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
from collections import defaultdict as dd
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
stdmap = lambda : map(int, stdstr().split())
stdarr = lambda : list(map(int, stdstr().split()))
mod = 1000000007
f = []
for i in range(1000 // 8):
	f.append(8 * i)
n = input()
for i in f:
	curr = str(i)
	(i, j) = (0, 0)
	while i < len(n) and j < len(curr):
		if n[i] == curr[j]:
			i += 1
			j += 1
		else:
			i += 1
	if j == len(curr):
		print('YES')
		print(curr)
		exit()
print('NO')


import copy
n = int(input())
l = list(map(int, str(n)))
a = l.count(0)
s = ''
if a > 0:
	print('YES')
	print('0')
elif n % 8 == 0:
	print('YES')
	print(n)
elif l.count(8) > 0:
	print('YES')
	print('8')
elif l.count(1) > 0 and l.count(6) > 0 and (l.index(1) < l.index(6)):
	print('YES')
	print('16')
elif l.count(2) > 0 and l.count(4) > 0 and (l.index(2) < l.index(4)):
	print('YES')
	print('24')
elif l.count(3) > 0 and l.count(2) > 0 and (l.index(3) < l.index(2)):
	print('YES')
	print('32')
elif l.count(5) > 0 and l.count(6) > 0 and (l.index(5) < l.index(6)):
	print('YES')
	print('56')
elif l.count(6) > 0 and l.count(4) > 0 and (l.index(6) < l.index(4)):
	print('YES')
	print('64')
elif l.count(7) > 0 and l.count(2) > 0 and (l.index(7) < l.index(2)):
	print('YES')
	print('72')
elif l.count(9) > 0 and l.count(6) > 0 and (l.index(9) < l.index(6)):
	print('YES')
	print('96')
else:
	k = len(l)
	mn = 0
	for i in range(0, k):
		for j in range(i + 1, k):
			for t in range(j + 1, k):
				s = ''
				s = s + str(l[i])
				s = s + str(l[j])
				s = s + str(l[t])
				s = int(s)
				if s % 8 == 0:
					mn = 1
					print('YES')
					print(s)
					s = ''
					break
			if mn == 1:
				break
		if mn == 1:
			break
	if mn == 0:
		print('NO')


s = input()
candidate = [str(x) for x in range(0, 1000, 8)]

def isContain(str, substr):
	d = {i: ss for (i, ss) in enumerate(substr)}
	ptr = 0
	for ss in str:
		if d[ptr] == ss:
			ptr += 1
		if ptr == len(substr):
			return True
	return False
for ss in candidate:
	if isContain(s, ss):
		print('YES')
		print(ss)
		exit()
print('NO')


def check2(s):
	if int(s) % 8 == 0:
		return s
	elif int(s[0]) % 8 == 0:
		return s[0]
	elif int(s[1]) % 8 == 0:
		return s[1]
	else:
		return -1

def check3(s):
	if int(s) % 8 == 0:
		return s
	if int(s[2]) % 8 == 0:
		return s[2]
	if int(s[1]) % 8 == 0:
		return s[1]
	if int(s[0]) % 8 == 0:
		return s[0]
	if check2(s[0] + s[1]) != -1:
		return s[0] + s[1]
	if check2(s[1] + s[2]) != -1:
		return s[1] + s[2]
	if check2(s[0] + s[2]) != -1:
		return s[0] + s[2]
	return -1

def check_final(s):
	if int(s[len(s) - 3:]) % 8 == 0:
		return True
	else:
		return False
s = input()
n = len(s)
if len(s) == 1:
	if int(s) % 8 == 0:
		print('YES')
		print(s)
		exit()
	else:
		print('NO')
		exit()
elif len(s) == 2:
	if check2(s) != -1:
		print('YES')
		print(check2(s))
		exit()
	else:
		print('NO')
		exit()
elif len(s) == 3:
	if check3(s) != -1:
		print('YES')
		print(check3(s))
		exit()
else:
	a = s
	for i in range(n):
		fir = int(s[i]) * 100
		for j in range(i + 1, n):
			sec = int(s[j]) * 10
			for q in range(j + 1, n):
				thr = int(s[q])
				if check3(str(fir + sec + thr)) != -1:
					print('YES')
					print(check3(str(fir + sec + thr)))
					exit()
print('NO')


ch = str(input())
T = 'NO'
if len(ch) >= 3:
	T = 'NO'
	res = 0
	BIG = list()
	for i in range(100, 1000):
		if i % 8 == 0:
			BIG.append(i)
	for n in BIG:
		a = str(n)[0]
		b = str(n)[1]
		c = str(n)[2]
		m = len(ch)
		n = len(ch)
		p = len(ch)
		for i in range(len(ch)):
			if ch[i] == a:
				m = i
				break
		for i in range(len(ch)):
			if ch[i] == b and i > m:
				n = i
				break
		for i in range(len(ch)):
			if ch[i] == c and i > n:
				p = i
				break
		if max(p, m, n) < len(ch):
			if m < n and n < p:
				T = 'YES'
				res = int(ch[m]) * 100 + int(ch[n]) * 10 + int(ch[p])
				break
	if '0' in ch:
		T = 'YES'
		res = 0
	if '8' in ch:
		T = 'YES'
		res = 8
	BIG = list()
	for i in range(10, 100):
		if i % 8 == 0:
			BIG.append(i)
	for n in BIG:
		a = str(n)[0]
		b = str(n)[1]
		m = len(ch)
		n = len(ch)
		for i in range(len(ch)):
			if ch[i] == a:
				m = i
				break
		for i in range(len(ch)):
			if ch[i] == b and i > m:
				n = i
				break
		if max(m, n) < len(ch):
			if m < n:
				T = 'YES'
				res = int(ch[m]) * 10 + int(ch[n])
				break
elif len(ch) == 2:
	if ch[1] in '80':
		T = 'YES'
		res = int(ch[1])
	if int(ch) % 8 == 0:
		T = 'YES'
		res = int(ch)
elif len(ch) == 1:
	if ch[0] in '80':
		T = 'YES'
		res = int(ch[0])
if T == 'NO':
	print('NO')
if T == 'YES':
	print(T)
	print(res)


s = input()
s = s[::-1]
n = len(s)
from sys import exit
for i in range(0, 1000, 8):
	item = str(i)
	length = len(item)
	for j in range(3 - length + 1):
		x = '0' * j + item
		le = length + j - 1
		a = x[le]
		le -= 1
		for (z, b) in enumerate(s):
			if a == b:
				if le == -1:
					print('YES', x, sep='\n')
					exit()
				a = x[le]
				le -= 1
print('NO')


st = input()
ans = 'NO'
for s in [str(i) for i in range(1000) if i % 8 == 0]:
	mark = -1
	for j in s:
		mark = st.find(j, mark + 1)
		if mark == -1:
			break
	if mark != -1:
		ans = 'YES' + '\n' + str(s)
print(ans)


n = input()
sts = []
progs = []
res = False
for num in range(0, 1000, 8):
	st = str(num)
	sts.append(st)
	progs.append(0)
for ch in n:
	for i in range(0, 125):
		if sts[i][progs[i]] == ch:
			progs[i] += 1
			if progs[i] == len(sts[i]):
				res = True
				print('YES')
				print(sts[i])
				break
	else:
		continue
	break
if not res:
	print('NO')


from sys import stdin, stdout
for _ in range(1):
	s = input()
	n = len(s)
	ans = -1
	if '8' in s:
		print('YES')
		print('8')
		continue
	if '0' in s:
		print('YES')
		print('0')
		continue
	for i in range(n):
		for j in range(i + 1, n):
			for k in range(j + 1, n):
				if int(s[i] + s[j] + s[k]) % 8 == 0:
					ans = s[i] + s[j] + s[k]
					break
	for j in range(n):
		for k in range(j + 1, n):
			if int(s[j] + s[k]) % 8 == 0:
				ans = s[j] + s[k]
				break
	if ans == -1:
		print('NO')
	else:
		print('YES')
		print(ans)


s = input()
n = len(s)
flag = 0
res = ''
for x in s:
	if int(x) % 8 == 0:
		flag = 1
		res = x
		break
if flag == 0:
	for i in range(n):
		for j in range(i + 1, n):
			num = int(s[i]) * 10 + int(s[j])
			if num % 8 == 0:
				res = num
				flag = 1
				break
		if flag:
			break
if flag == 0:
	for i in range(n):
		for j in range(i + 1, n):
			for k in range(j + 1, n):
				num = int(s[i]) * 100 + int(s[j]) * 10 + int(s[k])
				if num % 8 == 0:
					res = num
					flag = 1
					break
			if flag:
				break
		if flag:
			break
if flag:
	print('YES')
	print(res)
else:
	print('NO')


import sys
lasts = [0, 6, 4, 2]
index = -1
inp = input()
rev = inp[::-1]
for (index, each) in enumerate(rev):
	num = int(each)
	if num == 8 or num == 0:
		print('YES')
		print(num)
		sys.exit(0)
	if num in lasts:
		i = int(index) + 1
		while i < len(inp):
			if int(rev[i] + each) % 8 == 0:
				print('YES')
				print(rev[i] + each)
				sys.exit(0)
			if i + 1 < len(inp):
				j = i + 1
			else:
				print('NO')
				sys.exit(0)
			while j < len(inp):
				if int(rev[j] + rev[i]) % 4 == lasts.index(num):
					print('YES')
					print(rev[j] + rev[i] + each)
					sys.exit(0)
				j += 1
			i += 1
print('NO')


def main():
	possiveis = []
	inp = input()
	lei = len(inp)
	for i in range(101):
		possiveis.append(str(8 * i))
	for v in possiveis:
		l = 0
		for c in inp:
			if v[l] == c:
				l += 1
			if l == len(v):
				print('YES\n{}'.format(v))
				return
	print('NO')
main()


s = input()
n = int(len(s))
dp = [-1 for i in range(n)]
if int(s[0]) % 8 == 0:
	dp[0] = s[0]
if int(s[:2]) % 8 == 0 and n >= 2:
	dp[1] = s[:2]
for i in range(2, n):
	for j in range(i - 1, -1, -1):
		for k in range(j - 1, -1, -1):
			if int(s[k] + s[j] + s[i]) % 8 == 0:
				dp[i] = s[:k + 1] + s[j] + s[i]
				break
for i in range(2, n):
	for j in range(i - 1, -1, -1):
		if int(s[j] + s[i]) % 8 == 0 and dp[i] == -1:
			dp[i] = s[j] + s[i]
			break
ind = -1
l = 0
for i in range(0, n):
	if dp[i] != -1:
		if len(dp[i]) > l:
			l = len(dp[i])
			ind = i
if l == 0:
	for i in range(0, n):
		if s[i] == '0':
			print('YES')
			print('0')
			raise SystemExit(0)
if l == 0:
	print('NO')
else:
	print('YES')
	l = 0
	ind = -1
	for i in range(0, n):
		if len(str(dp[i])) > l and dp[i] != -1:
			l = len(str(dp[i]))
			ind = i
	print(dp[ind])


from itertools import combinations
s = input()
for x in s:
	if int(x) % 8 == 0:
		exit(print('YES\n' + x))
for (i, j) in combinations(range(len(s)), 2):
	if int(s[i] + s[j]) % 8 == 0:
		exit(print('YES\n' + s[i] + s[j]))
for (i, j, k) in combinations(range(len(s)), 3):
	if int(s[i] + s[j] + s[k]) % 8 == 0:
		exit(print('YES\n' + s[i] + s[j] + s[k]))
print('NO')


a = list(input())
for i in range(0, len(a)):
	a[i] = int(a[i])
if len(a) == 1:
	if a[0] % 8 == 0:
		print('YES')
		print(a[0])
		exit()
	else:
		print('NO')
		exit()
if len(a) == 2:
	if (a[1] * 10 + a[0]) % 8 == 0:
		print('YES')
		print(a)
	elif a[0] % 8 == 0:
		print('YES')
		print(a[0])
	elif a[1] % 8 == 0:
		print('YES')
		print(a[1])
	else:
		print('NO')
else:
	for i in range(len(a) - 1, 1, -1):
		for j in range(i - 1, 0, -1):
			for k in range(j - 1, -1, -1):
				if (a[i] + a[j] * 10 + a[k] * 100) % 8 == 0:
					print('YES')
					for t in range(0, k + 1):
						print(a[t], end='')
					print(a[j], end='')
					print(a[i], end='')
					exit()
	for i in range(len(a) - 1, 0, -1):
		for j in range(i - 1, -1, -1):
			if (a[i] + a[j] * 10) % 8 == 0:
				print('YES')
				print(a[j] * 10 + a[i])
				exit()
	for i in range(len(a) - 1, -1, -1):
		if a[i] % 8 == 0:
			print('YES')
			print(a[i], end='')
			exit()
	print('NO')


dp = dict()
st = input()

def solve(index, qty, valor):
	t = (index, qty, valor)
	if t in dp:
		return dp[t]
	if index >= len(st) or qty >= 3:
		if valor % 8 == 0 and qty >= 1:
			dp[t] = valor
		else:
			dp[t] = -1
		return dp[t]
	L = solve(index + 1, qty + 1, 10 * valor + int(st[index]))
	R = solve(index + 1, qty, valor)
	if L == R == -1:
		dp[t] = -1
	elif L != -1:
		dp[t] = L
	else:
		dp[t] = R
	return dp[t]
ans = solve(0, 0, 0)
if ans == -1:
	print('NO')
else:
	print('YES')
	print(ans)


s = input()
flag = False
for i in range(len(s)):
	if int(s[i]) % 8 == 0:
		print('YES')
		print(int(s[i]))
		flag = True
		break
	if flag == True:
		break
if flag == False:
	for i in range(len(s) - 1):
		for j in range(i + 1, len(s)):
			z = int(s[i] + s[j])
			if z % 8 == 0:
				print('YES')
				print(z)
				flag = True
				break
			if flag == True:
				break
		if flag == True:
			break
if flag == False:
	for i in range(len(s) - 2):
		for j in range(i + 1, len(s) - 1):
			for k in range(j + 1, len(s)):
				t = int(s[i] + s[j] + s[k])
				if t % 8 == 0:
					print('YES')
					print(t)
					flag = True
					break
				if flag == True:
					break
			if flag == True:
				break
		if flag == True:
			break
if flag == False:
	print('NO')


def divBy8(num):
	for i in range(len(num)):
		if num[i] == '8' or num[i] == '0':
			return ['YES', num[i]]
		for j in range(i + 1, len(num)):
			a = int(num[i]) * 10 + int(num[j])
			if a % 8 == 0:
				return ['YES', a]
			for k in range(j + 1, len(num)):
				b = int(num[i]) * 100 + int(num[j]) * 10 + int(num[k])
				if b % 8 == 0:
					return ['YES', b]
	return ['NO']
a = input()
b = divBy8(a)
for i in b:
	print(i)


import re

def solve(s):
	for i in range(0, 1000, 8):
		pat = '.*'.join([''] + list(str(i)) + [''])
		m = re.match(pat, s)
		if m:
			print('YES')
			print(i)
			return
	print('NO')
s = input()
solve(s)


import math, string, itertools, fractions, heapq, collections, re, array, bisect
from itertools import chain, dropwhile, permutations, combinations
from collections import defaultdict, deque

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

def main(inp):
	s = list(inp)
	a = list(map(int, list(inp)))
	x = int(inp)
	n = len(s)
	for (i, x) in enumerate(a):
		if x in [0, 8]:
			print('YES')
			print(x)
			return
		for j in range(i + 1, n):
			if int(s[i] + s[j]) % 8 == 0:
				print('YES')
				print(s[i] + s[j])
				return
			for k in range(j + 1, n):
				if int(''.join([s[i], s[j], s[k]])) % 8 == 0:
					print('YES')
					print(s[i] + s[j] + s[k])
					return
	print('NO')

def main_input(info=0):
	inp = input()
	main(inp)
main_input()


import re
import sys
n = input()
es = [i * 8 for i in range(1, 125)]
if '0' in n:
	print('YES')
	print(0)
else:
	for e in es:
		pattern = '.*'.join(list(str(e)))
		print(re.findall(pattern, n), file=sys.stderr)
		if re.findall(pattern, n):
			print('YES')
			print(e)
			break
	else:
		print('NO')


import itertools

def soln(n):
	nStr = str(n)
	if n % 8 == 0:
		return n
	for ch in nStr:
		num = int(ch)
		if num % 8 == 0:
			return num
	if len(nStr) >= 2:
		for i in range(len(nStr)):
			for j in range(i + 1, len(nStr)):
				num = int(''.join((nStr[index] for index in (i, j))))
				if num % 8 == 0:
					return num
	if len(nStr) >= 3:
		for i in range(len(nStr)):
			for j in range(i + 1, len(nStr)):
				for k in range(j + 1, len(nStr)):
					num = int(''.join((nStr[index] for index in (i, j, k))))
					if num % 8 == 0:
						return num
	return None

def main():
	n = int(input())
	result = soln(n)
	if result is None:
		print('NO')
	else:
		print('YES')
		print(result)
main()


from itertools import combinations
n = input()
if '8' in n:
	print('YES')
	print(8)
elif '0' in n:
	print('YES')
	print(0)
else:
	a = list(combinations(n, 2)) + list(combinations(n, 3))
	res = -1
	for x in a:
		num = int(''.join(x))
		if num % 8 == 0:
			res = num
			break
	if res == -1:
		print('NO')
	else:
		print('YES')
		print(res)


from functools import lru_cache
s = input()
n = len(s)

@lru_cache(maxsize=None)
def f(i, target):
	if i == -1:
		return None
	c = s[i]
	if int(c) % 8 == target:
		return c
	for ntarget in range(8):
		if (ntarget * 10 + int(c)) % 8 == target:
			r = f(i - 1, ntarget)
			if r is not None:
				return r + c
	return f(i - 1, target)
r = f(n - 1, 0)
if r is not None:
	print('YES')
	print(r)
else:
	print('NO')


n = input()
if '0' in n:
	print('YES')
	print('0')
	exit(0)
if '8' in n:
	print('YES')
	print('8')
	exit(0)
num = int(n)
x = int(num / 8)

def SinN(s, n):
	i = 0
	for c in s:
		i = n.find(c, i) + 1
		if i == 0:
			return False
	return True
while x > 0:
	for i in range(-80, +80, 8):
		s = str(x * 8 + i)
		if SinN(s, n):
			print('YES')
			print(s)
			exit(0)
	x = int(x / 10)
print('NO')


s = input()
n = len(s)
f = False
for i in range(n):
	for j in range(i + 1, n):
		for k in range(j + 1, n):
			if not f and (not s[i] == s[j] == s[k] == '0') and (int(s[i] + s[j] + s[k]) % 8 == 0):
				f = True
				print('YES')
				print(s[i] + s[j] + s[k])
if not f:
	for i in range(n):
		for j in range(i + 1, n):
			if not f and (not s[i] == s[j] == '0') and (int(s[i] + s[j]) % 8 == 0):
				f = True
				print('YES')
				print(s[i] + s[j])
if not f:
	for i in range(n):
		if not f and int(s[i]) % 8 == 0:
			f = True
			print('YES')
			print(s[i])
if not f:
	print('NO')


import re
n = input()
for i in range(0, 993, 8):
	if re.search('.*'.join(str(i)), n):
		print('YES')
		print(i)
		break
	if i > 991:
		print('NO')


import sys
s = input()
k = len(s)
if s.count('0') > 0:
	print('YES')
	print(0)
elif s.count('8') > 0:
	print('YES')
	print(8)
elif k == 1:
	print('NO')
elif k == 2:
	for i in range(1, k):
		for j in range(i):
			if int(s[j] + s[i]) % 8 == 0:
				print('YES')
				print(s[j] + s[i])
				sys.exit(0)
	print('NO')
else:
	for i in range(1, k):
		for j in range(i):
			if int(s[j] + s[i]) % 8 == 0:
				print('YES')
				print(s[j] + s[i])
				sys.exit(0)
	for i in range(2, k):
		for j in range(1, i):
			for g in range(j):
				if int(s[g] + s[j] + s[i]) % 8 == 0:
					print('YES')
					print(s[g] + s[j] + s[i])
					sys.exit(0)
	print('NO')


n = input()
a = []
for i in n:
	a.append(i)
if '0' in a:
	print('YES')
	print(0)
elif '8' in a:
	print('YES')
	print(8)
elif len(a) == 1:
	print('NO')
elif len(a) == 2:
	if int(n) % 8 == 0:
		print('YES')
		print(n)
	else:
		print('NO')
elif len(a) >= 3:
	for j in range(len(a) - 1):
		for k in range(j + 1, len(a)):
			y = int(a[j] + a[k])
			if y % 8 == 0 and str(y)[0] != 0:
				print('YES')
				print(y)
				break
			else:
				for m in range(k + 1, len(a)):
					x = int(a[j] + a[k] + a[m])
					if x % 8 == 0 and str(x)[0] != 0:
						print('YES')
						print(x)
						break
				else:
					continue
				break
		else:
			continue
		break
	else:
		print('NO')


N = list(input())
M = len(N)
for i in N:
	if int(i) % 8 == 0:
		print('YES')
		print(i)
		exit()
for i in range(M - 1):
	for j in range(i, M):
		if int(N[i] + N[j]) % 8 == 0:
			print('YES')
			print(N[i] + N[j])
			exit()
for i in range(M - 2):
	for j in range(i + 1, M - 1):
		for k in range(j + 1, M):
			if int(N[i] + N[j] + N[k]) % 8 == 0:
				print('YES')
				print(N[i] + N[j] + N[k])
				exit()
print('NO')


import sys
number = input()
a = {str(x * 8) for x in range(0, 125)}
for num in a:
	if num in number:
		print('YES')
		print(num)
		sys.exit()
for f in range(len(number) - 1):
	for s in range(1, len(number)):
		if int(number[f] + number[s]) % 8 == 0 and f < s:
			print('YES')
			print(int(number[f] + number[s]))
			sys.exit()
		for t in range(2, len(number)):
			if int(number[s] + number[t]) % 8 == 0 and s < t:
				print('YES')
				print(int(number[s] + number[t]))
				sys.exit()
			if int(number[f] + number[s] + number[t]) % 8 == 0 and f < s < t:
				print('YES')
				print(int(number[f] + number[s] + number[t]))
				sys.exit()
print('NO')


sol = None
n = input()
for i in range(len(n)):
	for j in range(i + 1, len(n)):
		for k in range(j + 1, len(n)):
			v = int(n[i] + n[j] + n[k])
			if v % 8 == 0:
				sol = v
		v = int(n[i] + n[j])
		if v % 8 == 0:
			sol = v
	v = int(n[i])
	if v % 8 == 0:
		sol = v
if sol == None:
	print('NO')
else:
	print('YES')
	print(sol)


s = [0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 208, 216, 224, 232, 240, 248, 256, 264, 272, 280, 288, 296, 304, 312, 320, 328, 336, 344, 352, 360, 368, 376, 384, 392, 400, 408, 416, 424, 432, 440, 448, 456, 464, 472, 480, 488, 496, 504, 512, 520, 528, 536, 544, 552, 560, 568, 576, 584, 592, 600, 608, 616, 624, 632, 640, 648, 656, 664, 672, 680, 688, 696, 704, 712, 720, 728, 736, 744, 752, 760, 768, 776, 784, 792, 800, 808, 816, 824, 832, 840, 848, 856, 864, 872, 880, 888, 896, 904, 912, 920, 928, 936, 944, 952, 960, 968, 976, 984, 992]
t = [c for c in input()]
n = len(t)
f = True
ans = True
i = 0
while i < 125 and f:
	l = 0
	r = [x for x in str(s[i])]
	k = 0
	while k < n and l < len(r):
		if t[k] == r[l]:
			l += 1
		k += 1
	if l == len(r):
		f = False
		ans = False
		print('YES')
		print(s[i])
	i += 1
if ans:
	print('NO')


from itertools import *
s = '00' + input()
for num in (int(s[i] + s[j] + s[k]) for (i, j, k) in combinations(range(len(s)), 3)):
	if num % 8 == 0:
		print('YES\n{}'.format(num))
		break
else:
	print('NO')


a = input()
if '0' in a:
	print('YES')
	print(0)
else:
	x = 0
	l = len(a)
	sol = False
	while x < l:
		if sol:
			break
		if int(a[x]) == 8:
			sol = True
			toprint = a[x]
			break
		for y in range(x, l):
			if int(a[x] + a[y]) % 8 == 0:
				sol = True
				toprint = a[x] + a[y]
				break
		for y in range(x + 1, l):
			for k in range(y + 1, l):
				if int(a[x] + a[y] + a[k]) % 8 == 0:
					sol = True
					toprint = a[x] + a[y] + a[k]
					break
		x += 1
	if sol:
		print('YES')
		print(toprint)
	else:
		print('NO')


str = input()
ls = len(str)

def f(a):
	if a == 0:
		for i in str:
			if i == '0':
				return 1
		return 0
	t = ls - 1
	w = a % 10
	while a > 0:
		if t < 0:
			return 0
		if w == int(str[t]):
			a //= 10
			w = a % 10
		t = t - 1
	return 1
ans = []
for i in range(0, 1000, 8):
	ans.append(i)
flag = True
for i in ans:
	if f(i) > 0:
		print('YES')
		print(i)
		flag = False
		break
if flag:
	print('NO')


a = input()
result = 0
for i in range(len(a)):
	for j in range(len(a)):
		for k in range(len(a)):
			h = a[i] + a[j] + a[k]
			h = int(h)
			if i < j and j < k and (h % 8 == 0) and (result == 0):
				print('YES')
				print(h)
				result = 1
if result == 0:
	for i in range(len(a)):
		for j in range(len(a)):
			h = a[i] + a[j]
			h = int(h)
			if i < j and h % 8 == 0 and (result == 0):
				print('YES')
				print(h)
				result = 1
if result == 0:
	for i in range(len(a)):
		h = a[i]
		h = int(h)
		if h % 8 == 0 and result == 0:
			print('YES')
			print(h)
			result = 1
if result == 0:
	print('NO')


def f(n):
	if '0' in n:
		return 0
	n = '00' + n
	for i in range(125):
		f = '000' + str(i * 8)
		f = f[-3:]
		x1 = n.find(f[0])
		x2 = n.find(f[1], x1 + 1)
		x3 = n.find(f[2], x2 + 1)
		if x1 != -1 and x2 != -1 and (x3 != -1):
			return n[x1] + n[x2] + n[x3]
	return 1
n = input()
if f(n) != 1:
	print('YES')
	print(int(f(n)))
else:
	print('NO')


from itertools import combinations

def check(n):
	for item in n:
		if int(item) % 2 == 0 or int(item) == '8':
			return True
	return False
n = input()
result = 'NO'
if '8' in n:
	result = 'YES'
	n = '8'
elif not check(n):
	pass
elif len(n) <= 10:
	for i in range(len(n)):
		for item in combinations(n, i + 1):
			item = ''.join(item)
			if int(item) % 8 == 0:
				result = 'YES'
				n = item
				break
else:
	for item in combinations(n, 3):
		item = ''.join(item)
		if int(item) % 8 == 0:
			result = 'YES'
			n = item
			break
print(result)
if result == 'YES':
	print(str(int(n)))


from sys import stdin, stdout
cin = stdin.readline
cout = stdout.write
lst = [16, 24, 32, 56, 64, 72, 96, 112, 136, 144, 152, 176, 192, 216, 224, 232, 256, 264, 272, 296, 312, 336, 344, 352, 376, 392, 416, 424, 432, 456, 464, 472, 496, 512, 536, 544, 552, 576, 592, 616, 624, 632, 656, 664, 672, 696, 712, 736, 744, 752, 776, 792, 912, 936, 944, 952, 976, 992]
n = cin()[:-1]
if '0' in n:
	cout('YES\n0')
	exit(0)
if '8' in n:
	cout('YES\n8')
	exit(0)
for s in lst:
	k = 0
	for ch in str(s):
		f = 1
		for i in range(k, len(n)):
			if n[i] == ch:
				k = i + 1
				f = 0
				break
		if f:
			break
	else:
		cout('YES\n' + str(s))
		break
else:
	cout('NO\n')


n = input()
n = n[::-1]
sol = 0
found = False
for i in range(len(n) - 2):
	for j in range(i + 1, len(n) - 1):
		for k in range(j + 1, len(n)):
			if int(n[k] + n[j] + n[i]) % 8 == 0:
				sol = str(int(n[k] + n[j] + n[i]))
				found = True
				break
		if found:
			break
	if found:
		break
if found:
	print('YES\n' + sol)
else:
	for i in range(len(n) - 1):
		for j in range(i + 1, len(n)):
			if int(n[j] + n[i]) % 8 == 0:
				sol = str(int(n[j] + n[i]))
				found = True
				break
		if found:
			break
	if found:
		print('YES\n' + sol)
	else:
		for i in n:
			if int(i) == 8 or int(i) == 0:
				sol = i
				found = True
				break
		if found:
			print('YES\n' + sol)
		else:
			print('NO')


ans = -1
num = input()
temp = 0
for x in range(0, 1000, 8):
	for sym in str(x):
		if sym in num[temp:]:
			temp = num[temp:].index(sym) + 1 + temp
		else:
			temp = 0
			break
	else:
		ans = x
		break
if ans == -1:
	print('NO')
else:
	print('YES', ans, sep='\n')


in_x = input()
n = list(in_x)
length = len(n)
counter = 0
counter_2 = 0
for _ in range(length):
	temp = n[:]
	if counter > 0:
		temp.pop(counter)
	counter += 1
	for j in range(0, len(temp)):
		if j > 0:
			temp.pop(length - 1 - j)
		num = int(''.join(temp))
		if num % 8 == 0:
			print(f'YES\n{num}')
			exit()
	temp = n[:]
	if counter_2 > 0:
		temp.pop(counter_2)
	counter_2 += 1
	for j in range(len(temp), 1, -1):
		temp.pop(j - len(temp))
		num = int(''.join(temp))
		if num % 8 == 0:
			print(f'YES\n{num}')
			exit()
print('NO')


s = list(input())
n = len(s)
flag = False
for i in range(n):
	a1 = int(s[i])
	if a1 % 8 == 0:
		ans = a1
		flag = True
		break
	for j in range(i + 1, n):
		a2 = int(s[j])
		if a2 % 8 == 0:
			ans = a2
			flag = True
			break
		a4 = int(s[i] + s[j])
		if a4 % 8 == 0:
			ans = a4
			flag = True
			break
		for k in range(j + 1, n):
			a3 = int(s[k])
			a5 = int(s[i] + s[k])
			a6 = int(s[j] + s[k])
			a7 = int(s[i] + s[j] + s[k])
			if a1 % 8 == 0 or a2 % 8 == 0 or a3 % 8 == 0 or (a4 % 8 == 0) or (a5 % 8 == 0) or (a6 % 8 == 0) or (a7 % 8 == 0):
				flag = True
			if a3 % 8 == 0:
				ans = a3
			if a5 % 8 == 0:
				ans = a5
			if a6 % 8 == 0:
				ans = a6
			if a7 % 8 == 0:
				ans = a7
		if flag:
			break
	if flag:
		break
if flag:
	print('YES')
	print(ans)
else:
	print('NO')


n = input()
l = len(n)
flag = False
if not flag:
	if '0' in n:
		print('YES')
		print('0')
		flag = True
if not flag:
	if '8' in n:
		print('YES')
		print('8')
		flag = True
if not flag:
	for i in range(l - 2):
		for j in range(i + 1, l):
			for k in range(j + 1, l):
				value = n[i] + n[j] + n[k]
				if int(value) % 8 == 0:
					flag = True
					print('YES')
					print(value)
				if flag:
					break
			if flag:
				break
		if flag:
			break
if not flag:
	for i in range(l):
		for j in range(i + 1, l):
			value = n[i] + n[j]
			if int(value) % 8 == 0:
				print('YES')
				print(value)
				flag = True
				break
		if flag:
			break
if not flag:
	print('NO')


s = input()
s = s[::-1]
p = ''
i = 1
f = -1
ty = ''
for j in range(0, len(s)):
	if int(s[j] + p[::-1]) % 2 ** i == 0:
		p = p + s[j]
		i = i + 1
	if int(s[j]) % 8 == 0:
		f = -2
		ty = s[j]
	if i > 2 and int(s[j] + p[0]) % 8 == 0:
		f = -2
		ty = s[j] + p[0]
	if i == 4:
		f = j
		break
if f == -1:
	print('NO')
else:
	print('YES')
	if f == -2:
		print(int(ty))
	else:
		print(s[j + 1:][::-1] + p[::-1])


from itertools import combinations

def main():
	n = input()
	if '0' in n:
		print('YES\n0')
	else:
		for i in range(1, min(3, len(n)) + 1):
			for r in combinations(n, i):
				m = int(''.join(r))
				if m % 8 == 0:
					print(f'YES\n{m}')
					exit()
		print('NO')
main()


a = input()

def ans(i, a):
	b = str(i)
	j = 0
	for i in a:
		if i == b[j]:
			j += 1
		if j == len(b):
			return 1
	return 0
q = 0
for i in range(0, 1000, 8):
	if ans(i, a):
		q = 1
		break
if q:
	print('YES')
	print(i)
else:
	print('NO')


nstr = input()

def solve(nstr):
	for n8 in range(0, 1000, 8):
		if has_subseq(nstr, str(n8)):
			print('YES')
			print(n8)
			return
	print('NO')

def has_subseq(nstr, n8str):
	pos = 0
	limit = len(nstr)
	for n in n8str:
		while pos < limit and nstr[pos] != n:
			pos += 1
		if pos == limit:
			return False
		pos += 1
	return True
solve(nstr)


x = int(input())
x = list(str(x)[::-1])
a = []
for i in range(1000):
	if i % 8 == 0:
		if i < 10:
			a.append(list(str(i)[::-1] + '00'))
		elif 9 < i < 100:
			a.append(list(str(i)[::-1] + '0'))
		else:
			a.append(list(str(i)[::-1]))
b = []
for i in range(9, 100):
	if i % 8 == 0:
		b.append(list(str(i)[::-1]))
c = ['0', '8']
a2 = []
for i in range(len(a)):
	if a[i][0] in x and a[i][1] in x[x.index(a[i][0]) + 1:] and (a[i][2] in x[x.index(a[i][0]) + 1:][x[x.index(a[i][0]) + 1:].index(a[i][1]) + 1:]):
		dlt1 = x.index(a[i][0])
		dlt2 = x[x.index(a[i][0]) + 1:].index(a[i][1])
		dlt3 = x[x.index(a[i][0]) + 1:][x[x.index(a[i][0]) + 1:].index(a[i][1]) + 1:].index(a[i][2])
		a2.append(dlt1 + dlt2 + dlt3)
	else:
		a2.append(101)
b2 = []
for i in range(len(b)):
	if b[i][0] in x and b[i][1] in x[x.index(b[i][0]) + 1:]:
		b2.append(len(x) - 2)
	else:
		b2.append(101)
c2 = []
for i in range(2):
	if c[i] in x:
		c2.append(len(x) - 1)
	else:
		c2.append(101)
mina2 = min(a2)
minb2 = min(b2)
minc2 = min(c2)
minmin = min(mina2, minb2, minc2)
if minmin == 101:
	print('NO')
else:
	if mina2 <= minb2 and mina2 <= minc2:
		edge = a[a2.index(mina2)]
	elif minb2 <= mina2 and minb2 <= minc2:
		edge = b[b2.index(minb2)]
	elif minc2 <= minb2 and minc2 <= mina2:
		edge = c[c2.index(minc2)]
	i = -1
	j = -1
	x.reverse()
	if len(edge) > 2:
		edge.reverse()
		while x[-3:] != edge:
			p = x[-3:]
			if x[i] == edge[j]:
				i -= 1
				j -= 1
			else:
				del x[i]
		print('YES', '\n', ''.join(x))
	elif 1 < len(edge) < 3:
		print('YES', '\n', ''.join(edge[::-1]))
	elif len(edge) < 2:
		print('YES', '\n', ''.join(edge))


def isSubSequence(str1, str2):
	m = len(str1)
	n = len(str2)
	j = 0
	i = 0
	while j < m and i < n:
		if str1[j] == str2[i]:
			j = j + 1
		i = i + 1
	return j == m
divBy8 = ['0']
for i in range(8, 1000):
	if i % 8 == 0:
		divBy8.append(str(i))
n = input()
f = 0
for i in divBy8:
	if isSubSequence(i, n):
		print('YES')
		print(i)
		f = 1
		break
if f == 0:
	print('NO')


def is_possible(n, pat):
	i = 0
	for c in n:
		if c == pat[i]:
			i += 1
			if i == len(pat):
				return True
	return False

def func():
	n = input()
	if n.find('0') != -1:
		return print('YES\n0')
	if n.find('8') != -1:
		return print('YES\n8')
	pats = [str(i) for i in range(0, 1000, 8) if str(i).find('0') == -1 and str(i).find('8') == -1]
	for pat in pats:
		if is_possible(n, pat):
			return print('YES\n' + pat)
	return print('NO')
func()


def divisibili(a):
	m = len(a)
	k = 0
	for i in range(m - 1, -1, -1):
		if int(a[i]) % 8 == 0:
			print('YES')
			print(a[i])
			k = 1
			return
		for j in range(i - 1, -1, -1):
			if (int(a[j]) * 2 + int(a[i])) % 8 == 0:
				print('YES')
				print(a[j] + a[i])
				k = 1
				return
			for k in range(j - 1, -1, -1):
				if (int(a[k]) * 4 + int(a[j]) * 2 + int(a[i])) % 8 == 0:
					print('YES')
					print(a[k] + a[j] + a[i])
					k = 1
					return
	if k == 0:
		print('NO')
a = input()
divisibili(a)


import itertools
nums_string = input()
for i in range(0, 1000, 8):
	index = -1
	for c in str(i):
		index = nums_string.find(c, index + 1)
		if index < 0:
			break
	else:
		print('YES')
		print(i)
		break
else:
	print('NO')


n = input()
A = list(n)
m = len(A)
flag = 0
for i in A:
	if int(i) % 8 == 0:
		print('YES')
		print(int(i))
		flag = 1
		break
if flag == 0:
	for i in range(m):
		for j in range(i):
			if int(A[j] + A[i]) % 8 == 0:
				print('Yes')
				print(int(A[j] + A[i]))
				flag = 1
				break
		if flag == 1:
			break
if flag == 0:
	for i in range(m):
		for j in range(1, i):
			for k in range(j):
				if int(A[k] + A[j] + A[i]) % 8 == 0:
					print('Yes')
					print(int(A[k] + A[j] + A[i]))
					flag = 1
					break
			if flag == 1:
				break
		if flag == 1:
			break
if flag == 0:
	print('No')


n = input()
r = 0
for i in range(0, 1000, 8):
	ind = -1
	for d in str(i):
		ind = n.find(d, ind + 1)
		if ind < 0:
			break
	else:
		r = 1
		print('YES')
		print(i)
		break
if not r:
	print('NO')


n = input()
flag = 0
s = 0
for i in range(len(n)):
	if n[i] == '8' or n[i] == '0':
		flag = 1
		s = int(n[i])
(a, b) = ('', '')
for i in range(len(n) - 1):
	a = int(n[i]) * 10
	for j in range(i + 1, len(n)):
		b = a + int(n[j])
		if b % 8 == 0:
			flag = 1
			s = b
(a, b, c) = ('', '', '')
for i in range(len(n) - 2):
	a = int(n[i]) * 100
	for j in range(i + 1, len(n) - 1):
		b = int(n[j]) * 10
		for k in range(j + 1, len(n)):
			c = a + b + int(n[k])
			if c % 8 == 0:
				flag = 1
				s = c
if flag == 1:
	print('YES')
	print(s)
else:
	print('NO')


import math
n = input()
if len(n) == 1:
	if int(n) == 0 or int(n) == 8:
		print('YES')
		print(n)
	else:
		print('NO')
elif len(n) == 2:
	if int(n) % 8 == 0:
		print('YES')
		print(n)
	elif int(n[0]) % 8 == 0:
		print('YES')
		print(n[0])
	elif int(n[1]) % 8 == 0:
		print('YES')
		print(n[1])
	else:
		print('NO')
else:
	flag = 0
	(t1, t2, t3) = (0, 0, 0)
	for i in range(int(len(n) - 1), -1, -1):
		ans = int(n[i])
		if ans % 8 == 0:
			t6 = n[i]
			flag = 3
			break
		for j in range(i - 1, -1, -1):
			val = int(n[j]) * 10 + int(n[i])
			if val % 8 == 0:
				t4 = n[i]
				t5 = n[j]
				flag = 2
				break
			for k in range(j - 1, -1, -1):
				temp = int(n[k]) * 100 + int(n[j]) * 10 + int(n[i]) * 1
				if temp % 8 == 0:
					t1 = n[i]
					t2 = n[j]
					t3 = n[k]
					flag = 1
					break
			if flag == 1:
				break
		if flag == 1 or flag == 2:
			break
	if flag == 1:
		print('YES')
		print(t3, end='')
		print(t2, end='')
		print(t1, end='')
	elif flag == 2:
		print('YES')
		print(t5, end='')
		print(t4, end='')
	elif flag == 3:
		print('YES')
		print(t6, end='')
	else:
		print('NO')


def main():
	from sys import stdin, stdout
	n = stdin.readline().strip()
	i = 0
	k = 2
	t = ''
	for j in n[::-1]:
		if j == '0':
			t = '0'
			break
		elif j == '8':
			t = '8'
			break
		i += 1
		if k == 16:
			break
		if int(j + t) & k - 1:
			continue
		else:
			t = j + t
			k <<= 1
	if t != '':
		if int(t) % 8 == 0:
			if i != len(n) and t != '0' and (t != '8'):
				stdout.write('YES\n' + n[:len(n) - i + 1] + t)
			else:
				stdout.write('YES\n' + t)
		else:
			stdout.write('NO')
	else:
		stdout.write('NO')
main()


import sys, io, os, time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect, math, heapq
alphabet = 'abcdefghijklmnopqrstuvwxyz'
from functools import lru_cache
input = sys.stdin.readline
s = input()
n = len(s)
for i in range(n - 1):
	if int(s[i:i + 1]) % 8 == 0:
		print('YES')
		print(s[i:i + 1])
		exit()
for i in range(n - 1):
	for j in range(i + 1, n):
		temp = s[i] + s[j]
		if int(temp) % 8 == 0:
			print('YES')
			print(temp)
			exit()
for i in range(n - 2):
	for j in range(i + 1, n - 1):
		for k in range(j + 1, n):
			temp = s[i] + s[j] + s[k]
			if int(temp) % 8 == 0:
				print('YES')
				print(temp)
				exit()
print('NO')


import re

def solve(s):
	for i in range(0, 1000, 8):
		pat = '^(.*' + str(i // 100) + ').*(' + str(i // 10 % 10) + ').*(' + str(i % 10) + ').*$'
		m = re.match(pat, s)
		if m:
			print('YES')
			print(m.expand('\\1\\2\\3'))
			return
	for i in range(16, 100, 8):
		pat = '^.*(' + str(i // 10) + ').*(' + str(i % 10) + ').*$'
		m = re.match(pat, s)
		if m:
			print('YES')
			print(m.expand('\\1\\2'))
			return
	for i in range(0, 10, 8):
		pat = '^.*(' + str(i) + ').*$'
		m = re.match(pat, s)
		if m:
			print('YES')
			print(m.expand('\\1'))
			return
	print('NO')
s = input()
solve(s)


s = input()
s = list(s)
n = len(s)
if '0' in s:
	print('YES')
	print(0)
	exit()
if '8' in s:
	print('YES')
	print(8)
	exit()
s.insert(0, '0')
n = n + 1
for i in range(n - 2):
	for j in range(i + 1, n - 1):
		for k in range(j + 1, n):
			x = int(s[i] + s[j] + s[k])
			if x % 8 == 0:
				print('YES')
				print(x)
				exit()
print('NO')


s = list(input())
for i in range(len(s)):
	s[i] = int(s[i])
s.reverse()
n = len(s)
f = 0
for i in range(n):
	ans = s[i]
	if ans % 8 == 0 and f == 0:
		f = 1
		print('YES')
		print(ans)
		break
	for j in range(i + 1, n):
		ans = s[i] + 10 * s[j]
		if ans % 8 == 0 and f == 0:
			f = 1
			print('YES')
			print(ans)
			break
		for k in range(j + 1, n):
			ans = s[i] + 10 * s[j] + 100 * s[k]
			if ans % 8 == 0 and f == 0:
				f = 1
				print('YES')
				print(ans)
				break
if f == 0:
	print('NO')


n = input()
for x in n:
	if int(x) % 8 == 0:
		print('YES')
		print(x)
		exit()
for i in range(len(n) - 1):
	for j in range(i + 1, len(n)):
		val = int(n[i]) * 10 + int(n[j])
		if val % 8 == 0:
			print('YES')
			print(val)
			exit()
for i in range(len(n) - 2):
	for j in range(i + 1, len(n) - 1):
		for k in range(j + 1, len(n)):
			val = int(n[i]) * 100 + int(n[j]) * 10 + int(n[k])
			if val % 8 == 0:
				print('YES')
				print(val)
				exit()
print('NO')


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

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

def map_string():
	return input().split()

def ins(n, a):
	s = str(n)
	c = [int(i) for i in s]
	for i in c:
		if i not in a:
			return False
		a = a[a.index(i) + 1:]
	return True
a = [int(i) for i in list(input())]
if 0 in a:
	print('YES\n0')
elif 8 in a:
	print('YES\n8')
else:
	b = [8 * i for i in range(1, 126)]
	for i in b:
		if ins(i, a):
			print('YES')
			print(i)
			break
	else:
		print('NO')


n = input()
if int(n) % 8 == 0:
	print('YES')
	print(n)
elif '0' in n:
	print('YES')
	print(0)
elif '8' in n:
	print('YES')
	print(8)
else:
	flag = 0
	k = 0
	while not flag and k < 100:
		d = '0' * (2 - len(str(k))) + str(k)
		k += 8
		t = n
		p1 = t.find(d[0])
		if p1 != -1:
			t = t[p1 + 1:]
			p2 = t.find(d[1])
			if p2 != -1:
				flag = 1
				print('YES')
				print(d)
	k = 0
	while not flag and k < 1000:
		d = '0' * (3 - len(str(k))) + str(k)
		k += 8
		t = n
		p1 = t.find(d[0])
		if p1 != -1:
			t = t[p1 + 1:]
			p2 = t.find(d[1])
			if p2 != -1:
				t = t[p2 + 1:]
				p3 = t.find(d[2])
				if p3 != -1:
					flag = 1
					print('YES')
					if p1 != 0:
						print(n[0] + d)
					else:
						print(d)
	if flag == 0:
		print('NO')


n = input()
text = 'NO'
is_divisible = False
for x in range(len(n)):
	if is_divisible:
		break
	if int(n[x]) % 8 == 0:
		is_divisible = True
		print('YES')
		print(n[x])
		break
for x in range(len(n)):
	if is_divisible:
		break
	for y in range(x + 1, len(n)):
		if is_divisible:
			break
		if (10 * int(n[x]) + int(n[y])) % 8 == 0:
			is_divisible = True
			print('YES')
			print(n[x] + n[y])
			break
for x in range(len(n)):
	if is_divisible:
		break
	for y in range(x + 1, len(n)):
		if is_divisible:
			break
		for z in range(y + 1, len(n)):
			if is_divisible:
				break
			if (100 * int(n[x]) + 10 * int(n[y]) + int(n[z])) % 8 == 0:
				is_divisible = True
				print('YES')
				print(n[x] + n[y] + n[z])
				break
if not is_divisible:
	print('NO')


n = input()
ans = -1

def findNum(num):
	j = 0
	for i in n:
		if i == str(num)[j]:
			j += 1
		if j == len(str(num)):
			return True
	return False
for i in range(0, 999, 8):
	if findNum(i):
		ans = i
		break
if ans == -1:
	print('NO')
else:
	print('YES')
	print(ans)


import sys
k = input()
l = [int(i) for i in str(k)]
div = False
for x in range(0, len(l)):
	if l[x] % 8 == 0:
		print('YES')
		print(l[x])
		sys.exit()
pivote = 0
q = pivote + 1
aux = ''
while pivote < len(l) - 1 and div == False:
	if q + 1 <= len(l):
		aux = ''
		aux = str(l[pivote])
		aux += str(l[q])
		q = q + 1
		if int(aux) % 8 == 0:
			print('Yes')
			print(aux)
			div = True
			sys.exit
	else:
		pivote = pivote + 1
		q = pivote + 1
if div == False:
	pivote = 0
	pivote2 = 1
	q = pivote2 + 1
	aux = ''
	while pivote2 < len(l) - 1 and div == False:
		if q + 1 <= len(l) and pivote2 + 1 <= len(l) - 1:
			aux = ''
			aux = str(l[pivote])
			aux += str(l[pivote2])
			aux += str(l[q])
			q = q + 1
			if int(aux) % 8 == 0:
				print('Yes')
				div = True
				print(aux)
				sys.exit
		elif pivote2 + 1 < len(l) - 1:
			pivote2 = pivote2 + 1
			q = pivote2 + 1
		elif pivote + 1 <= len(l) - 2:
			pivote = pivote + 1
			pivote2 = pivote + 1
			q = pivote2 + 1
if div == False:
	print('No')


x = list(str(input()))
a = [list(str(i)) for i in range(0, 1000, 8)]

def subsequence(seq, array):
	if len(seq) == 0:
		return True
	while array and seq[0] != array[0]:
		array = array[1:]
	if len(array) == 0:
		return False
	return subsequence(seq[1:], array[1:])
res = [i for i in a if subsequence(i, x)]
if res:
	print('YES')
	print(''.join(res[0]))
else:
	print('NO')


def good_endings():
	return [str(i) for i in range(1000) if i % 8 == 0]
n = input()
for ending in good_endings():
	a = n.find(ending[0])
	if a == -1:
		continue
	if len(ending) > 1:
		b = n.find(ending[1], a + 1)
		if b == -1:
			continue
	if len(ending) > 2:
		c = n.find(ending[2], b + 1)
		if c == -1:
			continue
	print('YES')
	print(ending)
	break
else:
	print('NO')


s = input()
if s.count('0'):
	print('YES')
	print('0')
	exit()
if s.count('8'):
	print('YES')
	print('8')
	exit()
if len(s) < 3:
	x = int(s)
	if x % 8 == 0:
		print('YES')
		print(s)
	else:
		print('NO')
	exit()
else:
	i = 0
	f = 0
	while i < len(s) - 2 and f == 0:
		j = i + 1
		while j < len(s) - 1 and f == 0:
			k = j + 1
			while k < len(s) and f == 0:
				a = s[i] + s[j] + s[k]
				x = int(a)
				if x % 8 == 0:
					f = 1
				else:
					k += 1
			if f != 1:
				j += 1
		if f != 1:
			i += 1
	if f:
		print('YES')
		e = s[i] + s[j] + s[k]
		print(e)
		exit()
	i = 0
	while i < len(s) - 1 and f == 0:
		j = i + 1
		while j < len(s) and f == 0:
			a = s[i] + s[j]
			x = int(a)
			if x % 8 == 0:
				f = 1
			else:
				j += 1
		if f != 1:
			i += 1
	if f:
		print('YES')
		e = s[i] + s[j]
		print(e)
		exit()
	print('NO')


input_n = input()
n = []
for count in range(len(input_n)):
	n.append(input_n[count])
found = False
if int(input_n) % 8 == 0:
	print('YES')
	print(input_n)
	found = True
if not found:
	for i in range(len(n)):
		if int(n[i]) % 8 == 0:
			print('YES')
			print(n[i])
			found = True
			break
if not found:
	for i in range(0, len(n)):
		if found:
			break
		for j in range(i + 1, len(n)):
			if int(n[i] + n[j]) % 8 == 0:
				print('YES')
				print(n[i] + n[j])
				found = True
				break
if not found:
	for i in range(0, len(n)):
		if found:
			break
		for j in range(i + 1, len(n)):
			if found:
				break
			for k in range(j + 1, len(n)):
				if int(n[i] + n[j] + n[k]) % 8 == 0:
					print('YES')
					print(n[i] + n[j] + n[k])
					found = True
					break
if not found:
	print('NO')


n = input()
answer = -1
for i in range(len(n)):
	if int(n[i]) % 8 == 0:
		answer = int(n[i])
	for j in range(i + 1, len(n)):
		if int(n[i] + n[j]) % 8 == 0:
			answer = int(n[i] + n[j])
		for k in range(j + 1, len(n)):
			if int(n[i] + n[j] + n[k]) % 8 == 0:
				answer = int(n[i] + n[j] + n[k])
if answer != -1:
	print('YES', answer, sep='\n')
else:
	print('NO')


def read():
	a = input().strip()
	return a

def find(a, n):
	pos = 0
	for c in n:
		pos = a.find(c, pos) + 1
		if pos == 0:
			break
	if pos:
		return n

def solve():
	if len(a) >= 3:
		for i in range(125):
			v = find(a, str(i * 8))
			if v:
				return v
	else:
		if len(a) == 2:
			if int(a[0]) % 8 == 0:
				return int(a[0])
			if int(a[1]) % 8 == 0:
				return int(a[1])
			if int(a) % 8 == 0:
				return a
		if len(a) == 1:
			if int(a) % 8 == 0:
				return a
	return -1
a = read()
sol = solve()
if sol != -1:
	print('YES')
	print(sol)
else:
	print('NO')


mas = (str(x) for x in range(0, 1000, 8))
s = input()
q = False
for x in mas:
	cnt = 0
	if q:
		break
	for ch in s:
		if ch == x[cnt]:
			cnt += 1
		if cnt == len(x):
			print('YES\n' + x)
			q = True
			break
if not q:
	print('NO')


s = ''
n = 0

def solve(step, index, num):
	if step == 3:
		if num % 8 == 0:
			return (True, num)
		elif num % 100 % 8 == 0:
			return (True, num % 100)
		elif num // 10 % 8 == 0:
			return (True, num // 10)
		elif (num // 100 * 10 + num % 10) % 8 == 0:
			return (True, num // 100 * 10 + num % 10)
		else:
			return (False, -1)
	if step == 2 and index == n:
		if num % 8 == 0:
			return (True, num)
		else:
			return (False, -1)
	for i in range(index, n):
		(ok, res) = solve(step + 1, i + 1, num * 10 + int(s[i]))
		if ok:
			return (ok, res)
	return (False, -1)
s = input()
n = len(s)
ok = False
for i in range(0, n):
	if s[i] == '0' or s[i] == '8':
		ok = True
		print('YES')
		print(s[i])
		break
if not ok:
	lastEvenIndex = n - 1
	while lastEvenIndex >= 0:
		if int(s[lastEvenIndex]) % 2 == 0:
			break
		else:
			lastEvenIndex -= 1
	if lastEvenIndex < 0:
		print('NO')
	else:
		s = s[:lastEvenIndex + 1]
		n = len(s)
		(ok, res) = solve(0, 0, 0)
		if ok:
			print('YES')
			print(res)
		else:
			print('NO')


def getLast(arr):
	n = len(arr)
	for i in range(n - 1, -1, -1):
		t = a.pop(i)
		if t % 2 == 0:
			return t
	return -1
a = list(map(int, input()))
last = getLast(a)
if last == -1:
	print('NO')
elif last == 0 or last == 8:
	print('YES')
	print(last)
else:
	for i in a:
		if (i * 10 + last) % 8 == 0:
			print('YES')
			print(i * 10 + last)
			exit(0)
	n = len(a)
	for i in range(n - 1):
		for j in range(i + 1, n):
			if (a[i] * 100 + a[j] * 10 + last) % 8 == 0:
				print('YES')
				print(a[i] * 100 + a[j] * 10 + last)
				exit(0)
	print('NO')


n = input()
if '0' in n:
	print('YES')
	print(0)
	exit()
elif '8' in n:
	print('YES')
	print(8)
	exit()
for i in range(16, 104, 8):
	if n.find(str(i)[0]) >= 0 and n[n.find(str(i)[0]) + 1:].find(str(i)[1]) >= 0:
		print('YES')
		print(i)
		exit()
for i in range(104, 1000, 8):
	a = n.find(str(i)[0])
	b = n[a + 1:].find(str(i)[1])
	c = n[b + a + 2:].find(str(i)[2])
	if a >= 0 and b >= 0 and (c >= 0):
		print('YES')
		print(i)
		exit()
print('NO')


n = str(input())
c = 0
if n.count('8') > 0:
	print('YES\n', 8)
	c = 1
elif n.count('0') > 0:
	print('YES\n', 0)
	c = 1
elif len(n) < 3:
	if int(n) % 8 == 0:
		print('YES\n', int(n))
	else:
		print('NO')
	c = 1
for i in range(len(n)):
	if c == 1:
		break
	for p in range(i + 1, len(n)):
		if c == 1:
			break
		for d in range(p + 1, len(n)):
			if (10 * int(n[i]) + int(n[p])) % 8 == 0:
				print('YES\n', 10 * int(n[i]) + int(n[p]))
				c = 1
				break
			elif (10 * int(n[i]) + int(n[d])) % 8 == 0:
				print('YES\n', 10 * int(n[i]) + int(n[d]))
				c = 1
				break
			elif (10 * int(n[p]) + int(n[d])) % 8 == 0:
				print('YES\n', 10 * int(n[p]) + int(n[d]))
				c = 1
				break
			elif (100 * int(n[i]) + 10 * int(n[p]) + int(n[d])) % 8 == 0:
				print('YES\n', 100 * int(n[i]) + 10 * int(n[p]) + int(n[d]))
				c = 1
				break
if c == 0:
	print('NO')


def prog():
	num = input().strip()
	dp = [[False for i in range(8)] for j in range(len(num))]
	from_value = [[-1 for i in range(8)] for j in range(len(num))]
	for i in range(-1, -len(num) - 1, -1):
		dp[i][int(num[-i - 1]) % 8] = True
	for i in range(-1, -len(num), -1):
		for j in range(8):
			if dp[i][j] == True:
				new_j = (2 * j + int(num[-i])) % 8
				dp[i - 1][new_j] = True
				from_value[i - 1][new_j] = j
				dp[i - 1][j] = True
				from_value[i - 1][j] = j
	worked = False
	for i in range(-len(num), 0):
		if dp[i][0] == True:
			worked = True
			d = 0
			div_8 = ''
			while True:
				if from_value[i][d] == -1 or from_value[i][d] != d:
					div_8 += num[-i - 1]
				if from_value[i][d] == -1:
					break
				d = from_value[i][d]
				i += 1
	if worked:
		print('YES')
		print(div_8[::-1])
	else:
		print('NO')
prog()


def check(x):
	if x % 8 == 0:
		print('YES')
		print(x)
		exit(0)
s = input()
for i in range(len(s)):
	curi = int(s[i])
	check(curi)
	for j in range(len(s)):
		if j <= i:
			continue
		curj = curi * 10 + int(s[j])
		check(curj)
		for k in range(len(s)):
			if k <= j:
				continue
			curk = curj * 10 + int(s[k])
			check(curk)
print('NO')


a = input()
n = len(a)
can = False
ans = 0
for i in range(n):
	t = int(a[i])
	if t % 8 == 0:
		can = True
		ans = t
		break
	for j in range(i + 1, n):
		t = int(a[i] + a[j])
		if t % 8 == 0:
			ans = t
			can = True
			break
		for k in range(j + 1, n):
			t = int(a[i] + a[j] + a[k])
			if t % 8 == 0:
				ans = t
				can = True
				break
if can:
	print('YES')
	print(ans)
else:
	print('NO')


n = int(input())
l = list(str(n))
for i in range(len(l)):
	l[i] = int(l[i])
cs = 0
ax = 0
for i in range(len(l)):
	zs = ''
	zs += str(l[i])
	if int(zs) % 8 == 0:
		cs = 1
		ax = int(zs)
		break
	for j in range(i + 1, len(l)):
		bs = ''
		bs += str(l[i])
		bs += str(l[j])
		if int(bs) % 8 == 0:
			cs = 1
			ax = int(bs)
			break
		for k in range(j + 1, len(l)):
			xs = ''
			xs += str(l[i])
			xs += str(l[j])
			xs += str(l[k])
			ys = int(xs)
			if ys % 8 == 0:
				cs = 1
				ax = xs
				break
		if cs == 1:
			break
	if cs == 1:
		break
if cs == 1:
	print('YES')
	print(ax)
else:
	print('NO')


import re
a = input()
ans = 1
for i in range(0, 1000, 8):
	if re.search('(.)*'.join(str(i)), a):
		print('YES\n{}'.format(i))
		ans = 1 - ans
		break
if ans:
	print('NO')


def divisionOcho():
	nStr = input()
	lenN = len(nStr)
	for i in range(0, lenN):
		a = int(nStr[i])
		if a == 8 or a == 0:
			print('YES')
			print(a)
			return
		for j in range(i + 1, lenN):
			b = a * 10 + int(nStr[j])
			if b % 8 == 0:
				print('YES')
				print(b)
				return
			for k in range(j + 1, lenN):
				c = b * 10 + int(nStr[k])
				if c % 8 == 0:
					print('YES')
					print(c)
					return
	print('NO')
divisionOcho()


def solve(n):
	l = len(n)
	for i in range(l):
		c = n[i]
		if c % 8 == 0:
			return c
		for j in range(i + 1, l):
			c = n[i] * 10 + n[j]
			if c % 8 == 0:
				return c
			for k in range(j + 1, l):
				c = n[i] * 100 + n[j] * 10 + n[k]
				if c % 8 == 0:
					return c

def main():
	n = list(map(int, input()))
	x = solve(n)
	if isinstance(x, int):
		print('YES', x, sep='\n')
	else:
		print('NO')
main()


a = input()
if int(a) % 8 == 0:
	print('YES')
	print(a)
	exit()
for i in range(len(a)):
	if int(a[i]) % 8 == 0:
		print('YES')
		print(a[i])
		exit()
for i in range(len(a)):
	for j in range(i, len(a)):
		if int(a[i] + a[j]) % 8 == 0:
			print('YES')
			print(a[i] + a[j])
			exit()
for i in range(len(a)):
	for j in range(i, len(a)):
		for k in range(j, len(a)):
			if int(a[i] + a[j] + a[k]) % 8 == 0 and i != j != k:
				print('YES')
				print(a[i] + a[j] + a[k])
				exit()
print('NO')


def main():
	s = input()
	n = len(s)
	if '0' in s:
		print('YES')
		print('0')
		return
	result = None
	for i in range(n):
		if int(s[i]) % 8 == 0:
			result = s[i]
		for j in range(i + 1, n):
			if int(s[i] + s[j]) % 8 == 0:
				result = s[i] + s[j]
			for k in range(j + 1, n):
				if int(s[i] + s[j] + s[k]) % 8 == 0:
					result = s[i] + s[j] + s[k]
	if result:
		print('YES')
		print(result)
	else:
		print('NO')
main()


w = input()
l = len(w)
for i in range(l):
	for j in range(i + 1, l):
		for k in range(j + 1, l):
			if int(w[i] + w[j] + w[k]) % 8 == 0:
				print('YES\n%d' % int(w[i] + w[j] + w[k]))
				exit()
for i in range(l):
	for j in range(i + 1, l):
		if int(w[i] + w[j]) % 8 == 0:
			print('YES\n%d' % int(w[i] + w[j]))
			exit()
for i in range(l):
	if int(w[i]) % 8 == 0:
		print('YES\n%d' % int(w[i]))
		exit()
print('NO')


import sys
import collections
import math
import functools
import itertools
import bisect
import operator
import heapq
import random
true = True
false = False
null = None
tcid = 0
tcmax = 99999999

def compute(val, func):
	return func(val)

def seq(lo, hi, step=1):
	return range(lo, hi + 1, step)

def sround(val, nd):
	return f'{val:.{nd}f}'

def ceil(a, b):
	ans = a // b
	if a % b != 0:
		ans += 1
	return ans

def perr(*args, **kwargs):
	print(*args, file=sys.stderr, **kwargs)

def line():
	ln = sys.stdin.readline().strip()
	if ln == '':
		sys.exit()
	return ln

def lines(n):
	return [line() for i in range(n)]

def split(ln=None):
	return (ln or line()).split()

def num(str=None):
	str = str or line()
	return float(str) if '.' in str else int(str)

def nums(o=None):
	if o is not None:
		if isinstance(o, int):
			o = lines(o)
		elif isinstance(o, str):
			o = split(o)
	return list(map(num, o or split()))

def mainloop(tcid=1):

	def solve():
		n = [0, 0]
		for dd in line():
			n.append(int(dd))
		for ii in range(len(n) - 2):
			for jj in range(ii + 1, len(n) - 1):
				for kk in range(jj + 1, len(n)):
					bb = n[ii] * 100 + n[jj] * 10 + n[kk]
					if bb % 8 == 0:
						return bb
	ans = solve()
	if ans is null:
		print('NO')
	else:
		print('YES')
		print(ans)
while tcid < tcmax:
	tcid += 1
	mainloop(tcid)


def possible(A):
	rems = [False] * 8
	prev = {}
	digitFor = {}
	for x in A:
		digit = int(x)
		nxtRems = [False] * 8
		if digit % 8 not in digitFor:
			digitFor[digit % 8] = str(digit)
		nxtRems[digit % 8] = True
		for rem in range(len(rems)):
			nxtRems[rem] |= rems[rem]
			nxt = (rem * 10 + digit) % 8
			nxtRems[nxt] |= rems[rem]
			if nxtRems[nxt] and nxt not in digitFor:
				prev[nxt] = rem
				digitFor[nxt] = str(digit)
			if nxtRems[0]:
				print('YES')
				p = 0
				s = ''
				while p in prev:
					s = digitFor[p] + s
					p = prev[p]
				print(digitFor[p] + s)
				return
		rems = nxtRems
	print('NO')
possible(input())


n = input()
have = False
ans = 0
for i in range(len(n)):
	if int(n[i]) % 8 == 0:
		have = True
		ans = int(n[i])
for i in range(len(n)):
	for j in range(i + 1, len(n)):
		if (int(n[i]) * 10 + int(n[j])) % 8 == 0:
			have = True
			ans = int(n[i]) * 10 + int(n[j])
for i in range(len(n)):
	for j in range(i + 1, len(n)):
		for k in range(j + 1, len(n)):
			if (int(n[i]) * 100 + int(n[j]) * 10 + int(n[k])) % 8 == 0:
				have = True
				ans = int(n[i]) * 100 + int(n[j]) * 10 + int(n[k])
if not have:
	print('NO')
else:
	print('YES')
	print(ans)


from collections import Counter
import string
import math

def array_int():
	return [int(i) for i in input().split()]

def vary(number_of_variables):
	if number_of_variables == 1:
		return int(input())
	if number_of_variables >= 2:
		return map(int, input().split())

def makedict(var):
	return dict(Counter(var))
mod = 1000000007

def isSubSequence(str1, str2):
	m = len(str1)
	n = len(str2)
	j = 0
	i = 0
	while j < m and i < n:
		if str1[j] == str2[i]:
			j = j + 1
		i = i + 1
	return j == m
n = input()
for i in range(0, 1000, 8):
	if isSubSequence(str(i), n):
		print('YES')
		print(i)
		break
else:
	print('NO')


__author__ = 'Andrey'
n = int(input())
s_n = str(n)
l_n = len(s_n)
done = False
for x in range(l_n):
	n_1 = int(s_n[x])
	if n_1 % 8 == 0:
		print('YES')
		print(n_1)
		break
	for y in range(x + 1, l_n):
		n_2 = int(s_n[y])
		n_12 = int(str(n_1) + str(n_2))
		if n_1 != 0 and n_12 % 8 == 0:
			print('YES')
			print(n_12)
			done = True
			break
		for z in range(y + 1, l_n):
			n_3 = int(s_n[z])
			n_123 = int(str(n_12) + str(n_3))
			if n_1 != 0 and n_123 % 8 == 0:
				print('YES')
				print(n_123)
				done = True
				break
		if done:
			break
	if done:
		break
else:
	print('NO')


str = input()
x = []
for i in range(len(str)):
	x.append(str[i])
	y = ''.join(x)
	raw = int(y)
	if raw % 8 == 0:
		print('YES')
		print(raw)
		exit()
	for j in range(i + 1, len(str)):
		x.append(str[j])
		y = ''.join(x)
		raw = int(y)
		if raw % 8 == 0:
			print('YES')
			print(raw)
			exit()
		for k in range(j + 1, len(str)):
			x.append(str[k])
			y = ''.join(x)
			raw = int(y)
			if raw % 8 == 0:
				print('YES')
				print(raw)
				exit()
			x.pop()
		x.pop()
	x.pop()
print('NO')
exit()


import math
import sys
s = input()
l = len(s)
n = 0
while n < 1000:
	n2 = str(n)
	l2 = len(n2)
	look = 0
	yes = 0
	for i in range(0, l):
		if n2[look] == s[i]:
			look += 1
		if look == l2:
			yes = 1
			break
	if yes == 1:
		ans = n
		break
	n += 8
if yes == 1:
	print('YES')
	print(ans)
else:
	print('NO')


n = input()
if int(n) % 8 == 0:
	print('YES')
	print(n)
	exit()
elif '0' in n:
	print('YES')
	print(0)
	exit()
elif '8' in n:
	print('YES')
	print(8)
	exit()
elif n.find('1') < n.rfind('6') and '1' in n and ('6' in n):
	print('YES')
	print(16)
	exit()
elif n.find('2') < n.rfind('4') and '2' in n and ('4' in n):
	print('YES')
	print(24)
	exit()
elif n.find('3') < n.rfind('2') and '3' in n and ('2' in n):
	print('YES')
	print(32)
	exit()
elif n.find('5') < n.rfind('6') and '5' in n and ('6' in n):
	print('YES')
	print(56)
	exit()
elif n.find('6') < n.rfind('4') and '6' in n and ('4' in n):
	print('YES')
	print(64)
	exit()
elif n.find('7') < n.rfind('2') and '7' in n and ('2' in n):
	print('YES')
	print(72)
	exit()
elif n.find('9') < n.rfind('6') and '9' in n and ('6' in n):
	print('YES')
	print(92)
	exit()
if len(n) <= 2:
	print('NO')
	exit()
for i in range(len(n)):
	for j in range(i + 1, len(n)):
		for k in range(j + 1, len(n)):
			if int(n[i] + n[j] + n[k]) % 8 == 0:
				print('YES')
				print(n[i] + n[j] + n[k])
				exit()
print('NO')


import itertools as it
n = list(input())
flag = 0
for i in range(1, 4):
	temp = it.combinations(n, i)
	for j in temp:
		temp1 = int(''.join(j))
		if temp1 % 8 == 0:
			print('YES')
			print(temp1)
			flag = 1
			break
		else:
			continue
	if flag == 1:
		break
if flag != 1:
	print('NO')


s = input()
s = '00' + s
u = 0
for i in range(len(s)):
	for j in range(i + 1, len(s)):
		for k in range(j + 1, len(s)):
			if int(s[i] + s[j] + s[k]) % 8 == 0 and u == 0:
				print('YES')
				u = 1
				ans = s[i] + s[j] + s[k]
				if s[i] == '0':
					ans = ans[1:]
					if s[j] == '0':
						ans = ans[1:]
				print(ans)
if u == 0:
	print('NO')


import sys

def dv8(n, k):
	t = False
	t1 = False
	t2 = False
	x = 0
	x1 = 101
	x2 = 102
	for i in range(len(s)):
		if s[i] == n[0]:
			t = True
			x1 = i + 1
			break
	if k > 1:
		for i in range(x1, len(s)):
			if s[i] == n[1]:
				t1 = True
				x2 = i + 1
				break
		if k > 2:
			for i in range(x2, len(s)):
				if s[i] == n[2]:
					t2 = True
	if k == 1:
		return t
	if k == 2:
		return t and t1
	if k == 3:
		return t1 and t2 and t
dp = [i * 8 for i in range(124)]
s = input()
for i in range(len(dp)):
	if dv8(str(dp[i]), len(str(dp[i]))):
		print('YES')
		print(dp[i])
		sys.exit()
print('NO')


num = list(input())
if '8' in num:
	print('YES')
	print(8)
elif '0' in num:
	print('YES')
	print(0)
else:
	for a in range(len(num)):
		for b in range(a + 1, len(num)):
			if int(num[a] + num[b]) % 8 == 0:
				print('YES')
				print(num[a] + num[b])
				exit()
	for a in range(len(num)):
		for b in range(a + 1, len(num)):
			for c in range(b + 1, len(num)):
				if int(num[a] + num[b] + num[c]) % 8 == 0:
					print('YES')
					print(num[a] + num[b] + num[c])
					exit()
	print('NO')


import sys
s = sys.stdin.readline().strip()
f = {0: '0', 1: '', 2: '', 3: '', 4: '', 5: '', 6: '', 7: ''}
empty = {0: False, 1: True, 2: True, 3: True, 4: True, 5: True, 6: True, 7: True}
for i in range(len(s)):
	if len(f[0]) > 1:
		break
	for j in f.keys():
		if len(f[j]) >= 1 and empty[j] == False:
			if len(f[(j * 10 + int(s[i])) % 8]) == 0 == 0 or (j * 10 + int(s[i])) % 8 == 0:
				f[(j * 10 + int(s[i])) % 8] = f[j] + s[i]
	for j in empty.keys():
		if f[j] != '':
			empty[j] = False
if len(f[0]) > 1:
	print('YES')
	print(f[0][1:])
else:
	print('NO')


s = input()
if len(s) == 1:
	if s == '0' or s == '8':
		print('YES')
		print(s)
	else:
		print('NO')
	exit()
if len(s) == 2:
	if int(s) % 8 == 0:
		print('YES')
		print(s)
	elif s[0] in '08':
		print('YES')
		print(s[0])
	elif s[1] in '08':
		print('YES')
		print(s[1])
	else:
		print('NO')
	exit()
for i in s:
	if i in '08':
		print('YES')
		print(i)
		exit()
n = len(s)
for i in range(n):
	for j in range(i + 1, n):
		if int(s[i] + s[j]) % 8 == 0:
			print('YES')
			print(s[i] + s[j])
			exit()
for i in range(n):
	for j in range(i + 1, n):
		for k in range(j + 1, n):
			if int(s[i] + s[j] + s[k]) % 8 == 0:
				print('YES')
				print(s[i] + s[j] + s[k])
				exit()
print('NO')


def main():
	s = input()
	n = len(s)
	x = 0
	while x < 1000:
		t = str(x)[::-1]
		j = 0
		for i in range(n):
			if j < len(t) and t[j] == s[n - 1 - i]:
				j += 1
		if j == len(t):
			print('YES')
			print(x)
			return
		x += 8
	print('NO')
main()


n = input()
flag = 0
for i in range(len(n)):
	if flag == 1:
		break
	if i + 1 < len(n):
		for j in range(i + 1, len(n)):
			if flag == 1:
				break
			if j + 1 < len(n):
				for k in range(j + 1, len(n)):
					s = int(n[i] + n[j] + n[k])
					if s % 8 == 0:
						print('YES')
						print(s)
						flag = 1
						break
			if int(n[i] + n[j]) % 8 == 0 and flag != 1:
				flag = 1
				print('YES')
				print(n[i] + n[j])
				break
	if int(n[i]) % 8 == 0 and flag != 1:
		print('YES')
		print(n[i])
		flag = 1
		break
if flag == 0:
	print('NO')


s = input()
n = len(s)
if s.find('0') != -1:
	print('YES\n0')
	exit(0)
if s.find('8') != -1:
	print('YES\n8')
	exit(0)
for i in range(n - 2):
	for j in range(i + 1, n - 1):
		for k in range(j + 1, n):
			if int(s[i] + s[j] + s[k]) % 8 == 0:
				print('YES')
				print(s[i] + s[j] + s[k])
				exit(0)
for i in range(n - 1):
	for j in range(i + 1, n):
		if int(s[i] + s[j]) % 8 == 0:
			print('YES')
			print(s[i] + s[j])
			exit(0)
print('NO')


import itertools
num = list(map(int, list(input())))
if 0 in num or 8 in num:
	if 0 in num:
		print('YES')
		print(0)
	elif 8 in num:
		print('YES')
		print(8)
else:
	threes = list(itertools.combinations(num, 3))
	twos = list(itertools.combinations(num, 2))
	done = False
	for i in twos:
		v = i[0] * 10 + i[1]
		if v % 8 == 0:
			print('YES')
			print(v)
			done = True
			break
	if done == False:
		for i in threes:
			v = i[0] * 100 + i[1] * 10 + i[2]
			if v % 8 == 0:
				print('YES')
				print(v)
				done = True
				break
	if done == False:
		print('NO')


my = []
for i in range(1000):
	if i % 8 == 0:
		my.append(str(i))
s = input()
for i in my:
	s1 = iter(s)
	res = 1
	for j in i:
		if j not in s1:
			res = 0
			break
	if res:
		print('YES', i)
		exit()
print('NO')


def isSubSequence(subString, string, m=-1, n=-1):
	if m == -1:
		m = len(subString)
	if n == -1:
		n = len(string)
	if m == 0:
		return True
	if n == 0:
		return False
	if subString[m - 1] == string[n - 1]:
		return isSubSequence(subString, string, m - 1, n - 1)
	return isSubSequence(subString, string, m, n - 1)
line = input()
flag = False
if len(line) < 3:
	if int(line) % 8 == 0:
		print('YES')
		print(line)
	elif isSubSequence('0', line):
		print('YES\n0')
	elif isSubSequence('8', line):
		print('YES\n8')
	else:
		print('NO')
else:
	firsOdd = -1
	for e in line:
		if int(e) % 2:
			firsOdd = line.index(e)
			break
	if firsOdd != -1:
		possibilities = [str(8 * j - 4) for j in range(1, 13)]
		for j in range(12):
			if len(possibilities[j]) == 1:
				possibilities[j] = '0' + possibilities[j]
		for e in possibilities:
			if isSubSequence(e, line[firsOdd + 1:]):
				print('YES')
				print(line[firsOdd] + e)
				flag = True
				break
	if not flag:
		possibilities = [str(8 * j) for j in range(0, 13)]
		for e in possibilities:
			if isSubSequence(e, line):
				print('YES')
				flag = True
				print(e)
				break
	if not flag:
		firsEven = -1
		for e in line:
			if int(e) % 2 == 0 and e != '0':
				firsEven = line.index(e)
				break
		possibilities[0] = '00'
		if firsEven != -1:
			if isSubSequence('00', line[firsEven + 1:]):
				print('YES')
				print(line[firsEven] + '00')
				flag = True
	if not flag:
		print('NO')


s = input()
l = len(s)
ans = -1
for i in range(l):
	temp = int(s[i])
	if temp % 8 == 0:
		ans = temp
		break
	for j in range(i + 1, l):
		temp = int(s[i] + s[j])
		if temp % 8 == 0:
			ans = temp
			break
		for k in range(j + 1, l):
			temp = int(s[i] + s[j] + s[k])
			if temp % 8 == 0:
				ans = temp
				break
if ans == -1:
	print('NO')
else:
	print('YES')
	print(ans)


def sub_2(num_list, n):
	for i in range(n):
		for j in range(i + 1, n):
			sub_num = num_list[i] * 10 + num_list[j]
			if sub_num % 8 == 0:
				print('YES')
				return sub_num
	return -1

def sub_3(num_list, n):
	for i in range(n):
		for j in range(i + 1, n):
			for k in range(j + 1, n):
				sub_num = num_list[i] * 100 + num_list[j] * 10 + num_list[k]
				if sub_num % 8 == 0:
					print('YES')
					return sub_num
	return -1
num_list = list(map(int, input()))
n = len(num_list)
if 8 in num_list:
	print('YES')
	print('8')
elif 0 in num_list:
	print('YES')
	print('0')
else:
	result = sub_2(num_list, n)
	if result == -1:
		r3 = sub_3(num_list, n)
		if r3 == -1:
			print('NO')
		else:
			print(r3)
	else:
		print(result)


import itertools
s = list(input())
b = 1
r = 1
e = 1
for x in range(1, len(s)):
	if int(''.join(s[:x])) % 8 == 0:
		r = x + 1
		print('YES')
		print(''.join(s[:r - 1]))
		b = 0
		break
for x in range(len(s) - 1, 0, -1):
	if int(s[x]) % 2 == 0:
		r = x + 1
		break
s = s[:r]
if not b == 0:
	z = False
	for y in range(1, int(len(s) / 2) + 1):
		e = 1
		for x in range(0, len(s) - y, y):
			if s[x:x + y] != s[x + y:x + 2 * y]:
				e = 0
				break
			z = True
		if z:
			break
if e == 1 and (not b == 0):
	b = 0
	if int(''.join(s)) % 8 != 0:
		print('NO')
	else:
		print('YES')
		print(''.join(s))

def pro(s, f):
	for x in range(len(s)):
		for y in list(itertools.combinations(s, x + 1)):
			t = int(''.join(y))
			if t % f == 0:
				print('YES')
				print(t)
				return t
	print('NO')
	return -1
z = 4
for y in range(len(s)):
	x = int(s[y])
	if x % 2 != 0 or b == 0:
		break
	if x != z and x == 6 and (x % 2 == 0):
		z = x
	if x != z and x == 2 and (x % 2 == 0) and (y == len(s) - 1):
		b = 0
		print('NO')
		break
if not b == 0:
	pro(s, 8)


s = input()
for i1 in range(len(s)):
	if int(s[i1]) % 8 == 0:
		print('YES')
		print(s[i1])
		exit(0)
	for i2 in range(i1 + 1, len(s)):
		if int(s[i1] + s[i2]) % 8 == 0:
			print('YES')
			print(s[i1] + s[i2])
			exit(0)
		for i3 in range(i2 + 1, len(s)):
			if int(s[i1] + s[i2] + s[i3]) % 8 == 0:
				print('YES')
				print(s[i1] + s[i2] + s[i3])
				exit(0)
print('NO')


def solve(n):
	if '8' in n:
		print('YES')
		return 8
	elif '0' in n:
		print('YES')
		return 0
	for i in range(len(n)):
		for j in range(i + 1, len(n)):
			val = int(n[i] + n[j])
			if val % 8 == 0:
				print('YES')
				return n[i] + n[j]
	for i in range(len(n)):
		for j in range(i + 1, len(n)):
			for k in range(j + 1, len(n)):
				val = int(n[i] + n[j] + n[k])
				if val % 8 == 0:
					print('YES')
					return n[i] + n[j] + n[k]
	return 'NO'
n = input()
print(solve(n))


n = input()
if '0' in n:
	print('YES', 0, sep='\n')
elif '8' in n:
	print('YES', 8, sep='\n')
else:
	n = n.rstrip('13579')
	(l, found) = (len(n), False)
	for i in range(l - 1):
		for j in range(i + 1, l):
			if int(n[i] + n[j]) % 8 == 0:
				print('YES', n[i] + n[j], sep='\n')
				found = True
				break
		if found:
			break
	else:
		for i in range(l - 2):
			for j in range(i + 1, l - 1):
				for k in range(j + 1, l):
					if int(n[i] + n[j] + n[k]) % 8 == 0:
						print('YES', n[i] + n[j] + n[k], sep='\n')
						found = True
						break
				if found:
					break
			if found:
				break
		else:
			print('NO')


import sys
n = str(sys.stdin.readline())
nums = []
for num in n:
	if num == '0':
		print('YES')
		print('0')
		exit()
	elif num == '8':
		print('YES')
		print('8')
		exit()
	else:
		nums.append(num)
l = len(n)
for i1 in range(l):
	for i2 in range(i1 + 1, l):
		ret = n[i1] + n[i2]
		if int(ret) % 8 == 0:
			print('YES')
			print(ret)
			exit()
for i1 in range(l):
	for i2 in range(i1 + 1, l):
		for i3 in range(i2 + 1, l):
			ret = n[i1] + n[i2] + n[i3]
			if int(ret) % 8 == 0:
				print('YES')
				print(ret)
				exit()
print('NO')


from sys import stdin, stdout
I = lambda : stdin.readline().strip()
read = lambda : map(int, stdin.readline().split())

def ffind(s, t):
	start = 0
	for i in s:
		x = t[start:].find(i)
		if x == -1:
			return False
		start = start + x + 1
	return True
s = I()
for i in range(0, 1000, 8):
	if ffind(str(i), s):
		print('YES')
		print(i)
		break
else:
	print('NO')
quit()
n = int(I())
arr = [tuple(read()) for i in range(n)]
arr.sort()
last_occupied = -10 ** 9
count = 0
n1 = n - 1
for (ind, i) in enumerate(arr):
	(x, r) = i
	if x - r > last_occupied:
		last_occupied = x
		count += 1
	elif ind == n1 or arr[ind + 1][0] > x + r:
		last_occupied = x + r
		count += 1
	else:
		last_occupied = x
print(count)
quit()
s = I()
min_so_far = track = sum([i.upper() == i for i in s])
for i in s:
	track += [-1, 1][i.lower() == i]
	min_so_far = min(min_so_far, track)
print(min_so_far)
quit()
len_s = len(s)
(tempu, templ) = (0, 0)
(dpu, dpl) = ([0] * (len_s + 1), [0] * (len_s + 1))
for (ind, i) in enumerate(s):
	if i == i.lower():
		tempu += 1
	dpu[ind + 1] = tempu
for i in range(len(s) - 1, -1, -1):
	if s[i] == s[i].upper():
		templ += 1
	dpl[i] = templ
print(min([dpu[x] + dpl[x + 1] for x in range(len_s)]))
quit()
s = I()
x = s.find('AB')
if x > -1:
	if s[x + 2:].find('BA') > -1:
		print('YES')
		quit()
x = s.find('BA')
if x > -1:
	if s[x + 2:].find('AB') > -1:
		print('YES')
		quit()
print('NO')
quit()
n = int(I())
s = tuple(read())
c = tuple(read())
INF = 10 ** 9
min_so_far = INF
for j in range(n):
	m1 = min([INF] + [c[i] for i in range(j) if s[i] < s[j]])
	m2 = min([INF] + [c[i] for i in range(j + 1, n) if s[i] > s[j]])
	min_so_far = min(min_so_far, c[j] + m1 + m2)
print(min_so_far if min_so_far < INF else -1)
quit()
(n, m, d) = read()
arr = []
for i in range(n):
	arr.extend(list(read()))
base = arr[0]
for i in arr:
	if (i - base) % d:
		print(-1)
		quit()
arr.sort()
s = n * m
Sum = 0
dev1 = dev2 = 0
if s % 2:
	median = arr[s // 2]
	for i in arr:
		Sum += abs(i - median)
else:
	(m1, m2) = (arr[s // 2 - 1], arr[s // 2])
	Sum2 = 0
	for i in arr:
		Sum += abs(i - m1)
		Sum2 += abs(i - m2)
	Sum = min(Sum, Sum2)
print(Sum // d)


import itertools

def con(e):
	try:
		return int(e)
	except:
		return int(''.join(list(e)))
mainnum = input()
candidates = set()
for e in itertools.chain(mainnum, itertools.combinations(mainnum, 2), itertools.combinations(mainnum, 3)):
	e = con(e)
	candidates.add(e)
found = False
for c in candidates:
	if c % 8 == 0:
		print('YES\n{}'.format(c))
		found = True
		break
if not found:
	print('NO')


s = input()
l = list(s)
c = 0
for i in l:
	if i == '0':
		c = 1
		break
if c == 1:
	print('YES')
	print('0')
else:
	ans = []
	x = 0
	check = 0
	answer = ''
	while x < 1000:
		ans.append(x)
		x = x + 8
	for i in range(len(ans)):
		x = ans[i]
		z = str(x)
		qw = list(z)
		t = 0
		j = 0
		for j in range(len(l)):
			if t >= len(qw):
				break
			if qw[t] == l[j]:
				t += 1
		if t == len(qw):
			check = 1
			answer += z
			break
	if check:
		print('YES')
		print(answer)
	else:
		print('NO')


n = int(input())
if n % 8 == 0:
	print('YES')
	print(n)
else:
	results = 'NO'
	n = str(n)
	a = len(n)
	for x in range(a):
		b = int(n[x])
		if b % 8 == 0:
			results = 'YES'
			break
		for y in range(x + 1, a):
			b = int(n[x] + n[y])
			if b % 8 == 0:
				results = 'YES'
				break
			for z in range(y + 1, a):
				b = int(n[x] + n[y] + n[z])
				if b % 8 == 0:
					results = 'YES'
					break
			if results == 'YES':
				break
		if results == 'YES':
			break
	print(results)
	if results == 'YES':
		print(b)


N = int(input())
if N % 8 == 0:
	print('YES')
	print(N)
else:
	ok = 0
	N = str(N)
	for i in range(len(str(N))):
		for j in range(i + 1, len(str(N))):
			for k in range(j + 1, len(str(N))):
				if (100 * int(N[i]) + 10 * int(N[j]) + int(N[k])) % 8 == 0 and ok == 0:
					print('YES')
					print(100 * int(N[i]) + 10 * int(N[j]) + int(N[k]))
					ok = 1
	for i in range(len(str(N))):
		for j in range(i + 1, len(str(N))):
			if (10 * int(N[i]) + int(N[j])) % 8 == 0 and ok == 0:
				print('YES')
				print(10 * int(N[i]) + int(N[j]))
				ok = 1
	for i in range(len(str(N))):
		if int(N[i]) % 8 == 0 and ok == 0:
			print('YES')
			print(N[i])
			ok = 1
	if ok == 0:
		print('NO')


import re
n = input()

def hi(n):
	for i in range(0, 993, 8):
		if re.search('.*'.join(str(i)), n):
			print('YES')
			print(str(i))
			return
	print('NO')
	return
hi(n)


s = input()
n = len(s)
g = 0
for i in range(n):
	if s[i] == '0' or s[i] == '8':
		print('YES')
		print(s[i])
		g = 1
		break
	for j in range(i + 1, n):
		if int(s[i] + s[j]) % 8 == 0:
			print('YES')
			print(s[i] + s[j])
			g = 1
			break
		for k in range(j + 1, n):
			if int(s[i] + s[j] + s[k]) % 8 == 0:
				print('YES')
				print(s[i] + s[j] + s[k])
				g = 1
				break
		if g:
			break
	if g:
		break
if not g:
	print('NO')


s = input()
x = ''
n = len(s)
if n == 1:
	if int(s) % 8 == 0:
		print('YES')
		print(s)
	else:
		print('NO')
elif n == 2:
	if int(s) % 8 == 0:
		print('YES')
		print(s)
	elif int(s[1]) % 8 == 0:
		print('YES')
		print(s[1])
	elif int(s[0]) % 8 == 0:
		print('YES')
		print(s[0])
	else:
		print('NO')
elif n == 3:
	if int(s) % 8 == 0:
		print('YES')
		print(s)
	elif int(s[1:]) % 8 == 0:
		print('YES')
		print(s[1:])
	elif int(s[:2]) % 8 == 0:
		print('YES')
		print(s[:2])
	elif int(s[0] + s[2]) % 8 == 0:
		print('YES')
		print(s[0] + s[2])
	elif int(s[1]) % 8 == 0:
		print('YES')
		print(s[1])
	elif int(s[0]) % 8 == 0:
		print('YES')
		print(s[0])
	elif int(s[2]) % 8 == 0:
		print('YES')
		print(s[2])
	else:
		print('NO')
else:
	x = 0
	for q in range(n):
		if int(s[q]) % 8 == 0:
			print('YES')
			print(s[q])
			x = 1
			break
		for w in range(q + 1, n):
			if int(s[q] + s[w]) % 8 == 0:
				print('YES')
				print(s[q] + s[w])
				x = 1
				break
			for r in range(w + 1, n):
				if int(s[q] + s[w] + s[r]) % 8 == 0:
					x = 1
					print('YES')
					print(s[q] + s[w] + s[r])
					break
			if x:
				break
		if x:
			break
	if x == 0:
		print('NO')


ASCII_0 = ord('0')

def can_remove_digits(number_string):
	i = len(number_string) - 1
	while i >= 0:
		third_digit = ord(number_string[i]) - ASCII_0
		if third_digit % 8 == 0:
			return third_digit
		j = i - 1
		while j >= 0:
			second_digit = ord(number_string[j]) - ASCII_0
			last_two_digits = second_digit * 10 + third_digit
			if last_two_digits % 8 == 0:
				return last_two_digits
			k = j - 1
			while k >= 0:
				first_digit = ord(number_string[k]) - ASCII_0
				last_three_digits = first_digit * 100 + last_two_digits
				if last_three_digits % 8 == 0:
					return last_three_digits
				k -= 1
			j -= 1
		i -= 1
	return -1

def run_alg():
	result = can_remove_digits(input())
	if result == -1:
		print('NO')
	else:
		print('YES\n%d' % result)
run_alg()


s = '00' + input()
for i in range(len(s)):
	for j in range(i + 1, len(s)):
		for k in range(j + 1, len(s)):
			x = 100 * int(s[i]) + 10 * int(s[j]) + int(s[k])
			if x % 8 == 0:
				print('YES\n{}'.format(x))
				exit()
print('NO')


n = input()
poss = False
ans = 0
for (a, i) in enumerate(n):
	for (b, j) in enumerate(n):
		if b <= a:
			continue
		for (c, k) in enumerate(n):
			if c <= b:
				continue
			q = int(i + j + k)
			if q % 8 == 0:
				poss = True
				ans = q
for (a, i) in enumerate(n):
	for (b, j) in enumerate(n):
		if b <= a:
			continue
		q = int(i + j)
		if q % 8 == 0:
			poss = True
			ans = q
for (a, i) in enumerate(n):
	q = int(i)
	if q % 8 == 0:
		poss = True
		ans = q
if poss:
	print('YES')
	print(ans)
else:
	print('NO')


from bisect import bisect_left
import os
import sys
from io import BytesIO, IOBase
from collections import Counter, defaultdict
from collections import deque
from functools import cmp_to_key
import math

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
MAX = float('inf')
MIN = float('-inf')
MOD = 1000000007

def sieve(n):
	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
	s = set()
	for p in range(2, n + 1):
		if prime[p]:
			s.add(p)
	return s

def readTree(n, m):
	adj = [deque([]) for _ in range(n + 1)]
	for _ in range(m):
		(u, v) = ain()
		adj[u].append(v)
		adj[v].append(u)
	return adj

def solve(c1, c2, maxi1, maxi2):
	for i in range(1, maxi1 + 1):
		if i not in c1:
			return False
	for i in range(1, maxi2 + 1):
		if i not in c2:
			return False
	return True

def main():
	s = sin()
	s = '00' + s
	n = len(s)
	for i in range(n):
		for j in range(i + 1, n):
			for k in range(j + 1, n):
				suma = int(s[i] + s[j] + s[k])
				if suma % 8 == 0:
					print('YES')
					print(suma)
					exit(0)
	print('NO')
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')
if os.getcwd() == 'D:\\code':
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
x = n
_len = 0
if n == 0:
	_len = 1
while x != 0:
	_len += 1
	x = x // 10
flag = 0
ans = -1
l = list(map(int, list(str(n))))
for i in range(_len):
	if l[i] % 8 == 0:
		flag = 1
		ans = l[i]
	if flag == 0:
		for j in range(i + 1, _len):
			if (l[i] * 10 + l[j]) % 8 == 0:
				flag = 1
				ans = l[i] * 10 + l[j]
			if flag == 0:
				for k in range(j + 1, _len):
					if (l[i] * 100 + l[j] * 10 + l[k]) % 8 == 0:
						flag = 1
						ans = l[i] * 100 + l[j] * 10 + l[k]
if flag == 1:
	print('YES')
	print(ans)
else:
	print('NO')


def solve():
	n = input()
	for i in range(0, 1000, 8):
		s = str(i)
		k = 0
		for j in n:
			if s[k] == j:
				k += 1
			if k == len(s):
				print('YES')
				print(s)
				return
	print('NO')
for i in range(1):
	solve()


n = input()
if len(n) == 1:
	if int(n) % 8 == 0:
		print('YES')
		print(n)
	else:
		print('NO')
elif len(n) == 2:
	if int(n[0]) % 8 == 0:
		print('YES')
		print(n[0])
	elif int(n[1]) % 8 == 0:
		print('YES')
		print(n[1])
	else:
		print('NO')
elif len(n) >= 3:
	check = False
	for i in n:
		if int(i) % 8 == 0:
			print('YES')
			print(i)
			check = True
			break
	if check is False:
		for i in range(len(n)):
			for j in range(i + 1, len(n)):
				if int(n[i] + n[j]) % 8 == 0:
					print('YES')
					print(n[i] + n[j])
					check = True
					break
			if check is True:
				break
	if check is False:
		for x in range(len(n)):
			for y in range(x + 1, len(n)):
				for z in range(y + 1, len(n)):
					if int(n[x] + n[y] + n[z]) % 8 == 0:
						print('YES')
						print(n[x] + n[y] + n[z])
						check = True
						break
				if check is True:
					break
			if check is True:
				break
	if check is False:
		print('NO')


inp = input()
all_case = []
for i in range(0, len(inp)):
	if not inp[i] in all_case:
		all_case.append(inp[i])
for i in range(0, len(inp) - 1):
	for j in range(i + 1, len(inp)):
		temp = inp[i] + inp[j]
		if not temp in all_case:
			all_case.append(temp)
for i in range(0, len(inp) - 2):
	for j in range(i + 1, len(inp) - 1):
		for k in range(j + 1, len(inp)):
			temp = inp[i] + inp[j] + inp[k]
			if not temp in all_case:
				all_case.append(temp)
ans = False
ansNumber = -1
for number in all_case:
	if int(number) % 8 == 0:
		ans = True
		ansNumber = int(number)
		break
if ans:
	print('YES')
	print(ansNumber)
else:
	print('NO')


x = input()
l = len(x)
for a in range(l):
	for b in range(a + 1, l):
		for c in range(b + 1, l):
			if int(x[a] + x[b] + x[c]) % 8 == 0:
				print('YES')
				print(int(x[a] + x[b] + x[c]))
				quit()
for a in range(l):
	for b in range(a + 1, l):
		if int(x[a] + x[b]) % 8 == 0:
			print('YES')
			print(int(x[a] + x[b]))
			quit()
for a in range(l):
	if int(x[a]) % 8 == 0:
		print('YES')
		print(x[a])
		quit()
print('NO')


n = int(input())
solved = 0
if '0' in str(n):
	print('YES')
	print(0)
	solved = 1
elif '8' in str(n):
	print('YES')
	print(8)
	solved = 1
if solved == 0:
	nstr = str(n)
	for i in range(len(str(n))):
		for j in range(i + 1, len(str(n))):
			if (int(nstr[i]) * 10 + int(nstr[j])) % 8 == 0:
				print('YES')
				print(int(nstr[i]) * 10 + int(nstr[j]))
				solved = 1
				break
		if solved == 1:
			break
if solved == 0:
	nstr = str(n)
	for i in range(len(str(n))):
		for j in range(i + 1, len(str(n))):
			for k in range(j + 1, len(str(n))):
				if (int(nstr[i]) * 100 + int(nstr[j]) * 10 + int(nstr[k])) % 8 == 0:
					print('YES')
					print(int(nstr[i]) * 100 + int(nstr[j]) * 10 + int(nstr[k]))
					solved = 1
					break
			if solved == 1:
				break
		if solved == 1:
			break
if solved == 0:
	print('NO')


import sys
k = input()
k = '00' + k
n = len(k)
flag = True
for i in range(n - 2):
	for j in range(i + 1, n - 1):
		for t in range(j + 1, n):
			f = int(k[i] + k[j] + k[t])
			if f % 8 == 0 and flag:
				print('YES')
				print(f)
				flag = False
if flag:
	print('NO')


number = input()
flag = False
for i1 in range(len(number)):
	if int(number[i1]) % 8 == 0:
		flag = True
		print(f'YES\n{number[i1]}')
		break
	for i2 in range(i1 + 1, len(number)):
		if int(number[i1] + number[i2]) % 8 == 0:
			flag = True
			print(f'YES\n{number[i1] + number[i2]}')
			break
		for i3 in range(i2 + 1, len(number)):
			if int(number[i1] + number[i2] + number[i3]) % 8 == 0:
				flag = True
				print(f'YES\n{number[i1] + number[i2] + number[i3]}')
				break
		if flag:
			break
	if flag:
		break
if not flag:
	print('NO')


import sys
from collections import defaultdict as dd
from collections import Counter as cc
from queue import Queue
import math
import itertools
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
q = '  ' + input()
e = len(q)
w = 0
for i in range(e):
	for j in range(i + 1, e):
		for k in range(j + 1, e):
			if int(q[i] + q[j] + q[k]) % 8 == 0:
				print('YES')
				w = 1
				print(int(q[i] + q[j] + q[k]))
				break
		if w == 1:
			break
	if w == 1:
		break
if w == 0:
	print('NO')


n = input()
length = len(n)
found = False
n = n[::-1]
if '8' in n:
	val = 8
	found = True
elif '0' in n:
	val = 0
	found = True
else:
	for i in range(1, length):
		if not found:
			for j in range(i):
				if not found:
					val = int(n[i] + n[j])
					if not val % 8:
						found = True
for i in range(2, length):
	if not found:
		for j in range(1, i):
			for z in range(j):
				if not found:
					val = int(n[i] + n[j] + n[z])
					if not val % 8:
						found = True
if not found:
	print('NO')
else:
	print('YES')
	print(val)


from itertools import combinations

def prog():
	s = '00' + input().strip()
	worked = False
	for combo in combinations(s, 3):
		combo = int(''.join(combo))
		if combo % 8 == 0:
			print('YES')
			print(combo)
			worked = True
			break
	if not worked:
		print('NO')
prog()


s = input()
a = []
d = []
for i in range(2, 13):
	a.append(str(8 * i))
for i in range(13, 125):
	d.append(str(8 * i))
if '8' in s:
	print('YES')
	print('8')
	exit(0)
if '0' in s:
	print('YES')
	print(0)
	exit(0)
for i in a:
	if i[0] in s:
		k = s.index(i[0])
		if i[1] in s[k + 1:]:
			print('YES')
			print(i)
			exit()
for i in d:
	if i[0] in s:
		k = s.index(i[0])
		if i[1] in s[k + 1:]:
			m = s[k + 1:].index(i[1])
			if i[2] in s[k + 1:][m + 1:]:
				print('YES')
				print(i)
				exit(0)
print('NO')


from itertools import combinations as cmb
a = input()
b = a
c = 0
N = 0
for p in cmb(a, 1):
	s = ''
	for o in p:
		s += o
	if int(s) % 8 == 0:
		c += 1
		N = s
		break
for j in cmb(a, 2):
	s = ''
	for n in j:
		s += n
	if int(s) % 8 == 0:
		c += 1
		N = s
		break
for i in cmb(b, 3):
	s = ''
	for k in i:
		s += k
	if int(s) % 8 == 0:
		c += 1
		N = s
		break
if int(a) % 8 == 0:
	c += 1
	N = a
if c > 0:
	print('YES')
	print(N)
else:
	print('NO')


l = input()
for i in range(0, 1000, 8):
	k = -1
	for c in str(i):
		k = l.find(c, k + 1)
		if k < 0:
			break
	else:
		print('YES')
		print(i)
		break
else:
	print('NO')


n = str(input())
k = 0
l = int(n) + 1
for i in range(len(n)):
	m = n[i]
	if int(m) % 8 == 0:
		k = k + 1
		l = m
		break
for i in range(len(n) - 1):
	for j in range(i + 1, len(n)):
		m = n[i] + n[j]
		if int(m) % 8 == 0:
			k = k + 1
			l = m
			break
for i in range(len(n) - 2):
	for j in range(i + 1, len(n) - 1):
		for t in range(j + 1, len(n)):
			m = n[i] + n[j] + n[t]
			if int(m) % 8 == 0:
				k = k + 1
				l = m
				break
if k > 0:
	print('YES')
	print(int(l))
else:
	print('NO')


a = [int(x) for x in input()]
n = len(a)
b = [x for x in range(999) if x % 8 == 0 or x == 0]
ans = -1
for x in b:
	if x > 99 and len(a) > 2:
		i = 0
		x1 = -1
		x2 = -1
		x3 = -1
		while i < n:
			if a[i] == x // 100:
				x1 = i
				i += 1
				break
			i += 1
		while i < n:
			if a[i] == x % 100 // 10:
				x2 = i
				i += 1
				break
			i += 1
		while i < n:
			if a[i] == x % 10:
				x3 = i
				break
			i += 1
		if x1 != -1 and x2 != -1 and (x3 != -1):
			ans = x
			break
	elif x > 9 and len(a) > 1:
		i = 0
		x1 = -1
		x2 = -1
		while i < n:
			if a[i] == x // 10:
				x1 = i
				i += 1
				break
			i += 1
		while i < n:
			if a[i] == x % 10:
				x2 = i
				break
			i += 1
		if x1 != -1 and x2 != -1:
			ans = x
			break
	elif x in a:
		ans = x
		break
if ans != -1:
	print('YES')
	print(ans)
else:
	print('NO')


n = input()

def valid(x):
	i = 0
	for ch in n:
		if ch == x[i]:
			i += 1
			if i == len(x):
				return True
	return False
for i in range(0, 1000, 8):
	if valid(str(i)):
		print('YES')
		print(i)
		exit()
print('NO')


n = input()
if n.count('0'):
	print('YES\n0')
	exit()
if n.count('8'):
	print('YES\n8')
	exit()
if len(n) == 2 and int(n) % 8 == 0:
	print('Yes')
	print(n)
	exit()
for i in range(len(n) - 1, -1, -1):
	for j in range(i - 1, -1, -1):
		if (int(n[j]) * 10 + int(n[i])) % 8 == 0:
			print('YES')
			print(n[j], n[i], sep='')
			exit()
		for k in range(j - 1, -1, -1):
			if (int(n[k]) * 100 + int(n[j]) * 10 + int(n[i])) % 8 == 0:
				print('YES')
				print(n[k], n[j], n[i], sep='')
				exit()
print('NO')


from itertools import *
from sys import *
s = input()
(com, com2) = (list(combinations(s, 3)), list(combinations(s, 2)))
(l, eight, zero) = (len(s), s.find('8'), s.find('0'))
if l == 1:
	if int(s) % 8:
		exit(print('NO'))
	else:
		exit(print('YES', s, sep='\n'))
if eight != -1:
	exit(print('YES', '8', sep='\n'))
elif zero != -1:
	exit(print('YES', '0', sep='\n'))
elif l == 2:
	if int(s) % 8 == 0:
		exit(print('YES', s, sep='\n'))
	else:
		exit(print('NO'))
for i in com:
	num = int(''.join(i))
	if num % 8 == 0:
		exit(print('YES', num, sep='\n'))
for i in com2:
	num = int(''.join(i))
	if num % 8 == 0:
		exit(print('YES', num, sep='\n'))
print('NO')


def solve(s):
	s = list(map(int, s))
	n = len(s)
	for i1 in range(n):
		if s[i1] % 8 == 0:
			return s[i1]
	for i1 in range(n):
		for i2 in range(i1 + 1, n):
			if (s[i1] * 10 + s[i2]) % 8 == 0:
				return s[i1] * 10 + s[i2]
	for i1 in range(n):
		for i2 in range(i1 + 1, n):
			for i3 in range(i2 + 1, n):
				if (s[i1] * 100 + s[i2] * 10 + s[i3]) % 8 == 0:
					return s[i1] * 100 + s[i2] * 10 + s[i3]
	return -1

def solve_str(s):
	if solve(s) == -1:
		return 'NO'
	else:
		return 'YES\n' + str(solve(s))
s = input()
print(solve_str(s))


s = input()
if '0' in s:
	print('YES')
	print('0')
	exit(0)
s = '00' + s
for i in range(len(s)):
	for j in range(i + 1, len(s)):
		for k in range(j + 1, len(s)):
			a = ord(s[i]) - ord('0')
			b = ord(s[j]) - ord('0')
			c = ord(s[k]) - ord('0')
			ss = s[i] + s[j] + s[k]
			if (100 * a + 10 * b + c) % 8 == 0:
				print('YES')
				ss = ss.replace('0', '', ss.count('0'))
				print(ss)
				exit(0)
print('NO')


a = list(map(int, '00' + input()))
n = len(a)
for i in range(n - 1):
	for j in range(i + 1, n - 1):
		for k in range(j + 1, n):
			if (a[i] * 100 + a[j] * 10 + a[k]) % 8 == 0:
				print('YES')
				print(a[i] * 100 + a[j] * 10 + a[k])
				exit()
print('NO')


n = int(input())
n = str(n)
n = n.rstrip('13579')
if '0' in n:
	print('YES')
	print(0)
elif '8' in n:
	print('YES')
	print(8)
else:
	while True:
		if n == '':
			print('NO')
			break
		elif n[-1] == '4':
			if '2' in n:
				print('YES')
				print(24)
			elif '6' in n:
				print('YES')
				print(64)
			else:
				q = n.rfind('4', 0, -1)
				if q != -1 and n.rfind('1', 0, q) != -1:
					print('YES')
					print(144)
				elif q != -1 and n.rfind('3', 0, q) != -1:
					print('YES')
					print(344)
				elif q != -1 and n.rfind('5', 0, q) != -1:
					print('YES')
					print(544)
				elif q != -1 and n.rfind('7', 0, q) != -1:
					print('YES')
					print(744)
				elif q != -1 and n.rfind('9', 0, q) != -1:
					print('YES')
					print(944)
				else:
					print('NO')
			break
		elif n[-1] == '2':
			if '3' in n:
				print('YES')
				print(32)
				break
			elif '7' in n:
				print('YES')
				print(72)
				break
			else:
				a = n.find('1')
				b = n.find('5')
				c = n.find('9')
				s = {a, b, c}
				s.discard(-1)
				if s == set():
					n = n.rstrip('26')
				else:
					d = min(s)
					a = n.find('1', d + 1)
					b = n.find('5', d + 1)
					c = n.find('9', d + 1)
					s = {a, b, c}
					s.discard(-1)
					if s == set():
						n = n.rstrip('1592')
					else:
						e = min(s)
						print('YES')
						print(n[d] + n[e] + '2')
						break
		elif n[-1] == '6':
			if '1' in n:
				print('YES')
				print(16)
				break
			elif '5' in n:
				print('YES')
				print(56)
				break
			elif '9' in n:
				print('YES')
				print(96)
				break
			else:
				a = n.find('3')
				b = n.find('7')
				s = {a, b}
				s.discard(-1)
				if s == set():
					n = n.rstrip('26')
				else:
					d = min(s)
					a = n.find('3', d + 1)
					b = n.find('7', d + 1)
					s = {a, b}
					s.discard(-1)
					if s == set():
						n = n.rstrip('376')
					else:
						e = min(s)
						print('YES')
						print(n[d] + n[e] + '6')
						break


m = []
flag = False
for i in range(100, 999):
	if i % 8 == 0:
		m.append(str(i))
s = input()
for i in m:
	posa = 1000
	posb = 1000
	posc = 1000
	a = i[0]
	b = i[1]
	c = i[2]
	for j in range(len(s)):
		if s[j] == a:
			posa = j
			break
	for j in range(posa + 1, len(s)):
		if s[j] == b:
			posb = j
			break
	for j in range(posb + 1, len(s)):
		if s[j] == c:
			posc = j
	if posa != 1000 and posb != 1000 and (posc != 1000) and (posa < posb < posc):
		flag = True
		ans = i
m = []
for i in range(10, 99):
	if i % 8 == 0:
		m.append(str(i))
for i in m:
	a = i[0]
	b = i[1]
	posa = 1000
	posb = 1000
	for j in range(len(s)):
		if s[j] == a:
			posa = j
			break
	for j in range(posa + 1, len(s)):
		if s[j] == b:
			posb = j
			break
	if posa != 1000 and posb != 1000 and (posa < posb):
		flag = True
		ans = i
if s.find('8') != -1:
	flag = True
	ans = 8
if s.find('0') != -1:
	flag = True
	ans = 0
if flag:
	print('YES')
	print(ans)
else:
	print('NO')


import math
str1 = input()
n = int(str1)
array = [int(i) for i in str1]
result = []

def construct(array):
	n = int(''.join(map(str, array)))
	return n

def helper(rem, check):
	if check == True:
		return True
	elif construct(rem) % 8 == 0:
		check = True
		result.append(construct(rem))
	elif len(rem) == 1:
		return False
	else:
		for i in range(0, len(rem)):
			temp = rem.copy()
			temp.pop(i)
			check = helper(temp, check)
	return check

def helper2(array, check):
	for i in array:
		if i % 8 == 0:
			check = True
			result.append(i)
			break
	for i in range(len(array)):
		for j in range(i + 1, len(array)):
			n = construct([array[i], array[j]])
			if n % 8 == 0:
				check = True
				result.append(n)
				break
	for i in range(len(array)):
		for j in range(i + 1, len(array)):
			for k in range(j + 1, len(array)):
				n = construct([array[i], array[j], array[k]])
				if n % 8 == 0:
					check = True
					result.append(n)
					break
	return check
check = helper2(array, False)
if check:
	print('YES')
	print(result[0])
else:
	print('NO')


a = [[0, 8], [6], [4], [2]]
s = '00' + input()
f = 0
for i in range(len(s)):
	for j in range(i + 1, len(s)):
		(b, c) = (int(s[i]), int(s[j]))
		x = a[(b % 2 * 2 + c % 4) % 4]
		for k in x:
			if str(k) in s[j + 1:]:
				f = 1
				print('YES')
				print(int(str(b) + str(c) + str(k)))
				break
		if f:
			break
	if f:
		break
if not f:
	print('NO')


import re
n = input()
for i in range(0, 1000, 8):
	r = '.*'.join([''] + list(str(i)) + [''])
	if re.search(r, n):
		print('YES')
		print(i)
		exit()
print('NO')


import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
from bisect import *
from math import sqrt, pi
import math
from itertools import permutations
from copy import deepcopy

def main():
	s = list(map(int, input().rstrip()))
	n = len(s)
	ans = 'NO'
	o = 0
	for i in s:
		o += i % 2
	d = 0
	if o != n:
		for i in range(n):
			x = s[i]
			if x % 8 == 0:
				ans = 'YES'
				d = x
				break
			for j in range(i + 1, n):
				y = x * 10 + s[j]
				if y % 8 == 0:
					d = y
					ans = 'YES'
					break
				for k in range(j + 1, n):
					z = y * 10 + s[k]
					if z % 8 == 0:
						ans = 'YES'
						d = z
						break
				if ans == 'YES':
					break
			if ans == 'YES':
				break
	print(ans)
	if ans == 'YES':
		print(d)
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')
main()


import math
import os
import random
import re
import sys

def main():
	s = input().strip()
	n = len(s)
	ok = False
	res = ''
	bag = set()
	for i in range(125):
		bag.add(str(8 * i))
	if '0' in s:
		ok = True
		res = '0'
	elif '8' in s:
		ok = True
		res = '8'
	else:
		for i in range(n - 1):
			for j in range(i + 1, n):
				if s[i] + s[j] in bag:
					res = s[i] + s[j]
					ok = True
					break
			if ok:
				break
	if not ok:
		for i in range(n - 2):
			for j in range(i + 1, n - 1):
				for k in range(j + 1, n):
					if s[i] + s[j] + s[k] in bag:
						res = s[i] + s[j] + s[k]
						ok = True
						break
				if ok:
					break
			if ok:
				break
	if ok:
		print('YES')
		print(res)
	else:
		print('NO')
main()


n = input()

def check(d):
	dp = 0
	for i in n:
		if dp == len(d):
			return True
		if i == d[dp]:
			dp += 1
	return dp == len(d)
if int(n) % 8 == 0:
	print('YES')
	print(n)
	exit(0)
if '0' in n:
	print('YES')
	print(0)
	exit(0)
if '8' in n:
	print('YES')
	print(8)
	exit(0)
divs = [str(i * 8) for i in range(1, 125)]
for d in divs:
	if check(d):
		print('YES')
		print(d)
		exit(0)
print('NO')


a = input()
z = len(a)
for i in range(0, 993, 8):
	s = str(i)
	s1 = len(s)
	o = 0
	for k in a:
		if k == s[o]:
			o += 1
		if o == s1:
			print('YES')
			print(i)
			exit()
print('NO')


import sys

def func_(arr):
	for i in range(0, len(arr) - 2):
		for j in range(i + 1, len(arr) - 1):
			for k in range(j + 1, len(arr)):
				tmp = arr[i] * 100 + arr[j] * 10 + arr[k]
				if tmp % 8 is 0:
					print('YES')
					print(tmp)
					sys.exit()

def func_2(arr):
	for i in range(0, len(arr) - 1):
		for j in range(i + 1, len(arr)):
			tmp = arr[i] * 10 + arr[j]
			if tmp % 8 is 0:
				print('YES')
				print(tmp)
				sys.exit()
arr = list(map(int, input()))
if 0 in arr:
	print('YES')
	print(0)
	sys.exit()
elif 8 in arr:
	print('YES')
	print(8)
	sys.exit()
if len(arr) is 2 or len(arr) is 1:
	tmp = int(''.join([str(i) for i in arr]))
	if tmp % 8 is 0:
		print('YES')
		print(tmp)
	else:
		print('NO')
	sys.exit()
func_(arr)
func_2(arr)
print('NO')


n = input()
found = False
for i in range(len(n)):
	if int(n[i]) % 8 == 0:
		found = True
		print('YES')
		print(n[i])
		break
if not found:
	for i in range(len(n)):
		if found:
			break
		for j in range(i + 1, len(n)):
			if int(n[i] + n[j]) % 8 == 0:
				found = True
				print('YES')
				print(n[i] + n[j])
				break
if not found:
	for i in range(len(n)):
		if found:
			break
		for j in range(i + 1, len(n)):
			if found:
				break
			for k in range(j + 1, len(n)):
				if int(n[i] + n[j] + n[k]) % 8 == 0:
					found = True
					print('YES')
					if i == 0:
						print(n[i] + n[j] + n[k])
					else:
						print(n[i - 1] + n[i] + n[j] + n[k])
					break
if not found:
	print('NO')


import atexit
import io
import sys
_I_B = sys.stdin.read().splitlines()
input = iter(_I_B).__next__
_O_B = io.StringIO()
sys.stdout = _O_B

@atexit.register
def write():
	sys.__stdout__.write(_O_B.getvalue())

def main():
	n = input()
	if '0' in n:
		print('YES')
		print(0)
		exit(0)
	elif '8' in n:
		print('YES')
		print(8)
		exit(0)
	else:
		ln = len(n)
		for i in range(ln):
			for j in range(i + 1, ln):
				num = int(n[i] + n[j])
				if num % 8 == 0:
					print('YES')
					print(num)
					exit(0)
		for i in range(ln):
			for j in range(i + 1, ln):
				for k in range(j + 1, ln):
					num = int(n[i] + n[j] + n[k])
					if num % 8 == 0:
						print('YES')
						print(num)
						exit(0)
	print('NO')
main()


numero = input()
NiUnoNiOtro = False
for cifra in range(0, 1000, 8):
	x = -1
	encontrado = False
	for digito in str(cifra):
		x = numero.find(digito, x + 1)
		if x < 0:
			encontrado = True
			break
	if not encontrado:
		print('YES')
		print(cifra)
		NiUnoNiOtro = True
		break
if not NiUnoNiOtro:
	print('NO')


st = input()

def isSub(x):
	i = j = 0
	while j < len(st) and i < len(x):
		if st[j] == x[i]:
			if i == len(x) - 1:
				return True
			i += 1
		j += 1
	return False
if '8' in st:
	print('YES')
	print(8)
elif '0' in st:
	print('YES')
	print(0)
else:
	cands = [str(x) for x in range(8, 1000, 8) if '8' not in str(x) and '0' not in str(x)]
	for c in cands:
		if isSub(c):
			print('YES')
			print(c)
			break
	else:
		print('NO')


import itertools
n = str(input())
x = ''
d = -1
z = []
y = []
if int(n) % 8 == 0:
	print('YES')
	print(n)
else:
	for j in range(1, 4):
		y += list(itertools.combinations(n, j))
	for i in y:
		x = ''.join(i)
		z.append(int(x))
	for i in range(len(z)):
		if z[i] / 8 == int(z[i] / 8):
			d = z[i]
			break
	if d == -1:
		print('NO')
	else:
		print('YES')
		print(d)


import sys
import math
import operator as op
from functools import reduce

def read_line():
	return sys.stdin.readline()[:-1]

def read_int():
	return int(sys.stdin.readline())

def read_int_line():
	return [int(v) for v in sys.stdin.readline().split()]

def read_float_line():
	return [float(v) for v in sys.stdin.readline().split()]

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer / denom
t = 1
for i in range(t):
	n = read_line()
	n = n[::-1]
	l = []
	for i in range(1001):
		if i % 8 == 0:
			v = str(i)
			l.append(v)
	ans = ''
	for i in l:
		i = i[::-1]
		f = False
		k = 0
		j = 0
		while j < len(n) and k < len(i):
			if i[k] == n[j]:
				k += 1
				j += 1
			else:
				j += 1
			if k == len(i):
				f = True
				break
		if f:
			ans = i
			break
	if len(ans) == 0:
		print('NO')
	else:
		print('YES')
		print(ans[::-1])


from __future__ import print_function
import sys
from collections import *
from heapq import *
INF = float('inf')
NINF = float('-inf')
try:
	input = raw_input
except:
	pass

def read_string():
	return input()

def read_int_line():
	return [int(x) for x in input().split(' ')]

def read_int():
	return int(input())

class TreeNode(object):

	def __init__(self, x):
		self.val = x
		self.left = None
		self.right = None

	def __str__(self):
		q = deque()
		ans = []
		q.append(self)
		ans.append(self.val)
		while q:
			cur = q.popleft()
			ans.append(cur.left.val if cur.left else 'null')
			ans.append(cur.right.val if cur.right else 'null')
			if cur.left:
				q.append(cur.left)
			if cur.right:
				q.append(cur.right)
		while ans and ans[-1] == 'null':
			ans.pop()
		return str(ans).replace("'null'", 'null')

def toTreeNode(s):
	l = eval(s.replace('null', 'None'))
	n = len(l)
	if not n:
		return None
	root = TreeNode(l[0])
	q = deque()
	q.append(root)
	i = 1
	while q and i < n:
		cur = q.popleft()
		if l[i] != None:
			cur.left = TreeNode(l[i])
			q.append(cur.left)
		i += 1
		if i >= n:
			break
		if l[i] != None:
			cur.right = TreeNode(l[i])
			q.append(cur.right)
		i += 1
	return root

class Djs:

	def __init__(self, n):
		self.w = [1] * n
		self.p = [-1] * n

	def find(self, x):
		p = self.p[x]
		if p == -1:
			return x
		else:
			self.p[x] = self.find(p)
			return self.p[x]

	def union(self, x, y):
		(x, y) = (self.find(x), self.find(y))
		if x == y:
			return
		if self.w[x] > self.w[y]:
			(x, y) = (y, x)
		self.p[x] = y
		self.w[y] += self.w[x]

	def roots(self):
		return [x for (x, y) in enumerate(self.p) if y == -1]

def doit():
	s = read_string()
	(s3, s2, s1) = ({}, {}, {})
	for c in s:
		n = int(c)
		for (k, v) in s2.items():
			v1 = v * 10 + n
			k1 = v1 % 8
			if k1 == 0:
				print('YES\n%d' % v1)
				return
			if k1 not in s3:
				s3[k1] = v1
		for (k, v) in s1.items():
			v1 = v * 10 + n
			k1 = v1 % 8
			if k1 == 0:
				print('YES\n%d' % v1)
				return
			if k1 not in s2:
				s2[k1] = v1
		(k, v) = (n % 8, n)
		if k == 0:
			print('YES\n%d' % v)
			return
		if k not in s1:
			s1[k] = v
	print('NO')
try:
	while True:
		doit()
except EOFError:
	pass


import re
n = input()
f = 1
for i in range(0, 992, 8):
	regex = '.*'.join(list(str(i)))
	if re.search(regex, n):
		val = i
		f = 0
if f == 1:
	print('NO')
else:
	print('YES')
	print(val)


st = input()
x = ''
for i in range(0, 125):
	x = str(i * 8)
	start = 0
	sumstart = -1
	for el in x:
		start = st[sumstart + 1:].find(el)
		sumstart += start + 1
		if start == -1:
			break
	if start != -1:
		break
if start == -1:
	print('NO')
else:
	print('YES')
	print(x)


n = input()
s = len(n)
a = [[False] * 8 for _ in range(s)]
prev = [[-1] * 8 for _ in range(s)]
a[0][int(n[0]) % 8] = True
for i in range(1, s):
	a[i][int(n[i]) % 8] = True
	for j in range(8):
		if a[i - 1][j]:
			a[i][(j * 10 + int(n[i])) % 8] = True
			prev[i][(j * 10 + int(n[i])) % 8] = j
			a[i][j] = True
			prev[i][j] = j
res = ''
for i in range(s):
	if a[i][0]:
		cur_i = i
		cur_j = 0
		while True:
			if prev[cur_i][cur_j] == -1 or prev[cur_i][cur_j] != cur_j:
				res += n[cur_i]
			if prev[cur_i][cur_j] == -1:
				break
			cur_j = prev[cur_i][cur_j]
			cur_i -= 1
		break
if len(res) > 0:
	print('YES')
	print(res[::-1])
else:
	print('NO')


def check(S, x):
	if str(x) in S:
		return x
	K = list(str(x))
	for i in S:
		if not K:
			return x
		if i == K[0]:
			K.pop(0)
	if not K:
		return x
	else:
		return -1
A = []
a = 0
while a < 1000:
	A.append(a)
	a += 8
S = input()
for i in A:
	ans = check(S, i)
	if ans >= 0:
		print('YES')
		print(ans)
		break
else:
	print('NO')


s = '?' + input() + '?'
n = len(s)
for i in range(n):
	for j in range(i + 1, n):
		for k in range(j + 1, n):
			if s[i] == '0':
				continue
			m = int((s[i] + s[j] + s[k]).replace('?', ''))
			if m % 8 == 0:
				print('YES')
				print(m)
				exit()
print('NO')


n = input()
if '0' in n:
	print('YES')
	print('0')
elif '8' in n:
	print('YES')
	print('8')
else:
	ans = 'NO'
	asdf = ''
	t1 = ['16', '24', '32', '56', '64', '72', '96']
	t2 = ['112', '136', '144', '152', '176', '192', '216', '224', '232', '256', '264', '272', '296', '312', '336', '344', '352', '376', '392', '416', '424', '432', '456', '464', '472', '496', '512', '536', '544', '552', '576', '592', '616', '624', '632', '656', '664', '672', '696', '712', '736', '744', '752', '776', '792', '912', '936', '944', '952', '976', '992']
	for i in t1:
		i0 = n.find(i[0])
		i1 = n.find(i[1], i0 + 1)
		if min(i0, i1) > -1:
			ans = 'YES'
			asdf = i
	for i in t2:
		i0 = n.find(i[0])
		i1 = n.find(i[1], i0 + 1)
		i2 = n.find(i[2], i1 + 1)
		if min(i0, i1, i2) > -1:
			ans = 'YES'
			asdf = i
	print(ans)
	if ans == 'YES':
		print(asdf)


x = input()
if int(x) % 8 == 0:
	print('YES')
	print(x)
else:
	x = x[::-1]
	y = len(x)
	f = 0
	for i in range(y):
		w = x[i]
		if int(w) % 8 == 0:
			f = 1
			z = w
			break
		for j in range(i + 1, y):
			w = x[i] + x[j]
			w = w[::-1]
			if int(w) % 8 == 0:
				f = 1
				z = w
				break
			for k in range(j + 1, y):
				w = x[i] + x[j] + x[k]
				w = w[::-1]
				if int(w) % 8 == 0:
					f = 1
					z = w
					break
			if f == 1:
				break
		if f == 1:
			break
	if f == 0:
		print('NO')
	else:
		print('YES')
		print(z)


a = input()
if len(a) <= 3:
	t = 0
	if len(a) == 3:
		k = [a[0], a[1], a[2], a[:2], a[1:], a[0] + a[2], a]
		k = list(map(int, k))
		for i in k:
			if i % 8 == 0:
				t = t + 1
				print('YES')
				print(i)
				break
		if t == 0:
			print('NO')
	if len(a) == 2:
		k = [a[0], a[1], a]
		k = list(map(int, k))
		for i in k:
			if i % 8 == 0:
				t = t + 1
				print('YES')
				print(i)
				break
		if t == 0:
			print('NO')
	if len(a) == 1:
		if int(a) % 8 == 0:
			print('YES')
			print(a)
		else:
			print('NO')
elif '8' in a:
	print('YES')
	print(8)
else:
	while len(a) >= 3:
		k = a[-3:]
		if int(k) % 8 == 0:
			print('YES')
			print(a)
			break
		r = k[0] + k[2]
		if int(r) % 8 == 0:
			print('YES')
			print(r)
			break
		r = k[0] + k[1]
		if int(r) % 8 == 0:
			print('YES')
			print(r)
			break
		r = k[1] + k[2]
		if int(r) % 8 == 0:
			print('YES')
			print(r)
			break
		if len(a) <= 3:
			print('NO')
			break
		else:
			r = a[-4] + k[:2]
			if int(r) % 8 == 0:
				print('YES')
				print(r)
				break
			r = a[-4] + k[1:]
			if int(r) % 8 == 0:
				print('YES')
				print(r)
				break
			r = a[-4] + k[0] + k[2]
			if int(r) % 8 == 0:
				print('YES')
				print(r)
				break
			r = a[-4] + k[0]
			if int(r) % 8 == 0:
				print('YES')
				print(r)
				break
			r = a[-4] + k[1]
			if int(r) % 8 == 0:
				print('YES')
				print(r)
				break
			r = a[-4] + k[2]
			if int(r) % 8 == 0:
				print('YES')
				print(r)
				break
			if len(a) == 4:
				print('NO')
				break
			else:
				t = a[-5:-3]
				r = t + k[0]
				if int(r) % 8 == 0:
					print('YES')
					print(r)
					break
				r = t + k[1]
				if int(r) % 8 == 0:
					print('YES')
					print(r)
					break
				r = t + k[2]
				if int(r) % 8 == 0:
					print('YES')
					print(r)
					break
			a = a[:-3]
	if len(a) < 3:
		if int(a) % 8 == 0:
			print('YES')
			print(a)
		else:
			print('NO')


c = list(input())
n = len(c)
f = False
for i in range(n):
	if int(c[i]) % 8 == 0:
		f = True
		print('YES')
		print(c[i])
		break
if not f:
	for i in range(n):
		for j in range(i + 1, n):
			t = int(c[i] + c[j])
			if not f and t % 8 == 0:
				f = True
				print('YES')
				print(t)
				break
if not f:
	for i in range(n):
		for j in range(i + 1, n):
			for k in range(j + 1, n):
				t = int(c[i] + c[j] + c[k])
				if not f and t % 8 == 0:
					f = True
					print('YES')
					print(t)
					break
if not f:
	print('NO')


from sys import *
l = list(input())
for i in range(len(l)):
	if int(l[i]) % 8 == 0:
		print('YES')
		print(int(l[i]))
		exit()
	for j in range(i + 1, len(l)):
		if int(l[i] + l[j]) % 8 == 0:
			print('YES')
			print(int(l[i] + l[j]))
			exit()
		for k in range(j + 1, len(l)):
			if int(l[i] + l[j] + l[k]) % 8 == 0:
				print('YES')
				print(int(l[i] + l[j] + l[k]))
				exit()
print('NO')


a = input()
n = len(a)
ok = False
for i in range(n):
	if not int(a[i]) % 8:
		print('YES')
		print(a[i])
		ok = True
		break
if not ok and n == 1:
	print('NO')
elif not ok:
	for i in range(n):
		for j in range(i + 1, n):
			if not int(a[i] + a[j]) % 8:
				print('YES')
				print(a[i] + a[j])
				ok = True
				break
		if ok:
			break
	if not ok and n == 2:
		print('NO')
	elif not ok:
		for i in range(n):
			for j in range(i + 1, n):
				for k in range(j + 1, n):
					if not int(a[i] + a[j] + a[k]) % 8:
						print('YES')
						print(a[i] + a[j] + a[k])
						ok = True
						break
				if ok:
					break
			if ok:
				break
		if not ok:
			print('NO')


s = '00' + input()
ans = False
num = 0
for k in range(len(s) - 2):
	for i in range(k + 1, len(s) - 1):
		for j in range(i + 1, len(s)):
			if int(s[k] + s[i] + s[j]) % 8 == 0:
				ans = True
				num = int(s[k] + s[i] + s[j])
if ans:
	print('YES')
	print(num)
else:
	print('NO')


n = input()
x = len(n)
f = 0
if '8' in n:
	f = 1
	s = '8'
elif '0' in n:
	f = 1
	s = '0'
else:
	for i in range(x):
		for j in range(i + 1, x):
			s = n[i] + n[j]
			if int(s) % 8 == 0:
				f = 1
				break
		if f:
			break
	if f == 0 and x >= 3:
		for i in range(x):
			for j in range(i + 1, x):
				for k in range(j + 1, x):
					s = n[i] + n[j] + n[k]
					if int(s) % 8 == 0:
						f = 1
						break
				if f:
					break
			if f:
				break
if f:
	print('YES')
	print(s)
else:
	print('NO')


n = input()
for ans in range(0, 1000, 8):
	i = -1
	for c in str(ans):
		i = n.find(c, i + 1)
		if i < 0:
			break
	else:
		print('YES')
		print(ans)
		break
else:
	print('NO')


s = input().strip()
n = len(s)
ans = None
for i in range(n):
	x = s[i]
	x = int(x)
	if x % 8 == 0:
		ans = x
	for j in range(i + 1, n):
		x = s[i] + s[j]
		x = int(x)
		if x % 8 == 0:
			ans = x
		for k in range(j + 1, n):
			x = s[i] + s[j] + s[k]
			x = int(x)
			if x % 8 == 0:
				ans = x
if ans is not None:
	print('YES')
	print(ans)
else:
	print('NO')


def solve():
	n = int(input())
	arr = [int(i) for i in str(n)]
	unique = [i for i in arr if i % 2 == 0]
	if 0 in arr:
		print('YES')
		print(0)
		return
	elif n % 8 == 0:
		print('YES')
		print(n)
		return
	elif len(unique) == 0:
		print('NO')
		return
	numbers = [i for i in range(8, 1001) if i % 8 == 0]
	for i in numbers:
		num = [int(j) for j in str(i)]
		counter = len(num) - 1
		index = len(arr) - 1
		while index >= 0:
			if num[counter] == arr[index]:
				counter -= 1
				if counter < 0:
					print('YES')
					print(i)
					return
			index -= 1
	print('NO')
solve()


s = input()
sss = s
from itertools import combinations
flag = 0
flag2 = 0
ss = []
even = ['0', '2', '4', '6', '8']
for i in range(len(sss)):
	if sss[i] in even:
		if i >= 3:
			s = sss[i - 3:i + 1]
		else:
			s = sss[:i + 1]
		ss.append(s)
		flag2 = 1
if flag2 == 0:
	ss.append('1')
for s in ss:
	for i in range(1, len(s) + 1):
		if flag == 1:
			break
		if flag2 == 0:
			break
		comb = combinations(s, i)
		for j in comb:
			n = ''
			for k in j:
				n = n + k
			if int(n) % 8 == 0:
				flag = 1
				res = n
if flag == 1:
	print('YES')
	print(res)
else:
	print('NO')


import sys
import math
import bisect
from math import sqrt

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

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

def rinput():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
mod = int(1000000000.0) + 7
n = input()
l = len(n)
for i in range(l):
	for j in range(i + 1, l):
		for k in range(j + 1, l):
			t = int(n[i] + n[j] + n[k])
			if t % 8 == 0:
				print('YES')
				print(t)
				exit(0)
for i in range(l):
	for j in range(i + 1, l):
		t = int(n[i] + n[j])
		if t % 8 == 0:
			print('YES')
			print(t)
			exit(0)
for i in range(l):
	if n[i] == '0' or n[i] == '8':
		print('YES')
		print(n[i])
		exit(0)
print('NO')


s = input()
i = 0
while i < 1000:
	t = str(i)
	j = 0
	for k in s:
		if k == t[j]:
			j += 1
		if j == len(t):
			break
	if j == len(t):
		print('YES')
		print(t)
		exit()
	i += 8
print('NO')


s = input()
s = s[::-1]
l = len(s)
y = 0
for x in range(l):
	if s[x] == '0' or s[x] == '8':
		y = 1
		print('YES')
		print(s[x])
	elif x != l - 1:
		for i in range(x + 1, l):
			if int(s[i] + s[x]) % 8 == 0:
				print('YES')
				print(s[i] + s[x])
				y = 1
			elif i != l - 1:
				for j in range(x + 2, l):
					k = s[j] + s[i] + s[x]
					if int(k) % 8 == 0:
						print('YES')
						print(k)
						y = 1
						break
			if y:
				break
	if y:
		break
else:
	print('NO')


import sys
import os
from io import BytesIO, IOBase

def cel(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

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

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

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return defaultdict(int)

def ddl():
	return defaultdict(list)

def ddd():
	return defaultdict(defaultdict(int))
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')
from collections import defaultdict
i = 0
res = set()
while 8 * i < 1000:
	res.add(str(8 * i))
	i += 1
s = input()
n = len(s)
ans = -1
t = [str(i * 8) for i in range(13)]
if n < 3:
	for i in t:
		if i in s:
			ans = i
	if ans == -1:
		print('NO')
	else:
		print('YES')
		print(ans)
	sys.exit()
for i in range(n - 2):
	if s[i] in res:
		ans = s[i]
		break
	for j in range(i + 1, n - 1):
		if s[j] in res:
			ans = s[j]
			break
		if s[i] + s[j] in res:
			ans = s[i] + s[j]
			break
		for k in range(j + 1, n):
			if s[k] in res:
				ans = s[k]
				break
			if s[j] + s[k] in res:
				ans = s[j] + s[k]
				break
			if s[i] + s[k] in res:
				ans = s[i] + s[k]
				break
			tmp = s[i] + s[j] + s[k]
			if tmp in res:
				ans = tmp
				break
if ans != -1:
	print('YES')
	print(ans)
else:
	print('NO')


x = input()
if x.count('8') > 0:
	print('YES')
	print(8)
elif x.count('0') > 0:
	print('YES')
	print(0)
else:
	ok = False
	for a in range(len(x)):
		for b in range(a + 1, len(x)):
			if int(x[a] + x[b]) % 8 == 0:
				ok = True
				print('YES')
				print(int(x[a] + x[b]))
				break
		if ok == True:
			break
	if ok == False:
		for a in range(len(x)):
			for b in range(a + 1, len(x)):
				for c in range(b + 1, len(x)):
					if int(x[a] + x[b] + x[c]) % 8 == 0:
						ok = True
						print('YES')
						print(int(x[a] + x[b] + x[c]))
						break
				if ok == True:
					break
			if ok == True:
				break
		if ok == False:
			print('NO')


s = input()
n = len(s)
ans = ''
flag = False
for v in s:
	if v in {'0', '8'}:
		flag = True
		ans = '0' if v == '0' else '8'
		break
if n > 2 and (not flag):
	for i in range(n - 1, -1, -1):
		for j in range(i - 1, -1, -1):
			x = s[j] + s[i]
			if int(x) % 8 == 0:
				flag = True
				ans = x
				break
			for k in range(j - 1, -1, -1):
				x = s[k] + s[j] + s[i]
				if int(x) % 8 == 0:
					ans = s[:k + 1] + s[j] + s[i]
					flag = True
					break
if n == 2 and int(s) % 8 == 0 and (not flag):
	flag = True
	ans = s
if flag:
	print('YES')
	print(ans)
else:
	print('NO')


i = input()

def sub_is_8_divisible(number):
	possible = set()
	i = 1
	while i <= len(number):
		possible.add(int(number[-i]))
		i += 1
	i = 1
	while i <= len(number):
		e = i + 1
		while e <= len(number):
			possible.add(int(number[-e] + number[-i]))
			e += 1
		i += 1
	i = 1
	while i <= len(number):
		e = i + 1
		while e <= len(number):
			o = e + 1
			while o <= len(number):
				possible.add(int(number[-o] + number[-e] + number[-i]))
				o += 1
			e += 1
		i += 1
	for i in possible:
		if int(i) % 8 == 0:
			return ['YES', i]
	return ['NO']
for i in sub_is_8_divisible(i):
	print(i)


s = input()
a = [int(x) for x in s]
a.reverse()
bhul = False
for i in range(len(a)):
	if a[i] % 8 == 0:
		print('YES')
		print(a[i])
		bhul = True
		break
if bhul == False:
	for i in range(len(a) - 1):
		for j in range(i + 1, len(a)):
			if int(str(a[j]) + str(a[i])) % 8 == 0:
				print('YES')
				print(int(str(a[j]) + str(a[i])))
				bhul = True
				break
		if bhul:
			break
if bhul == False:
	for i in range(len(a) - 2):
		for j in range(i + 1, len(a) - 1):
			for k in range(j + 1, len(a)):
				if int(str(a[k]) + str(a[j]) + str(a[i])) % 8 == 0:
					print('YES')
					print(int(str(a[k]) + str(a[j]) + str(a[i])))
					bhul = True
					break
			if bhul:
				break
		if bhul:
			break
if bhul == False:
	print('NO')


given = '00' + input()
for i in range(len(given)):
	for j in range(i + 1, len(given)):
		for k in range(j + 1, len(given)):
			opcija = given[i] + given[j] + given[k]
			if int(opcija) % 8 == 0:
				print('YES')
				print(int(opcija))
				quit()
print('NO')


n = input().strip()
till_1000 = [str(8 * num) for num in range(0, 125)]

def is_subseq(sub):
	it = iter(n)
	return all((c in it for c in sub))
for x in till_1000:
	if is_subseq(x):
		print('YES\n', x, sep='')
		break
else:
	print('NO\n')


L = []
now = 0
while now <= 1000:
	L.append(now)
	now += 8
L = set(L)
S = input()
N = len(S)
for i in range(N):
	if int(S[i]) in L:
		print('YES')
		print(S[i])
		exit()
if N >= 2:
	for i in range(N - 1):
		for j in range(i + 1, N):
			tmp = int(S[i]) * 10 + int(S[j])
			if tmp in L:
				print('YES')
				print(tmp)
				exit()
if N >= 3:
	for i in range(N - 2):
		for j in range(i + 1, N - 1):
			for k in range(j + 1, N):
				tmp = int(S[i]) * 100 + int(S[j]) * 10 + int(S[k])
				if tmp in L:
					print('YES')
					print(tmp)
					exit()
print('NO')


def solve():
	n = int(input())
	if n < 100:
		if n % 8 == 0:
			print('YES')
			print(n)
		elif n % 10 == 0:
			print('YES')
			print(0)
		else:
			print('NO')
	else:
		s = str(n)
		if '0' in s:
			print('YES')
			print(0)
		elif '8' in s:
			print('YES')
			print(8)
		else:
			f = 0
			for i in range(len(s) - 2):
				for j in range(i + 1, len(s) - 1):
					for k in range(j + 1, len(s)):
						t = int(s[i]) * 100 + int(s[j]) * 10 + int(s[k])
						ij = int(s[i]) * 10 + int(s[j])
						jk = int(s[j]) * 10 + int(s[k])
						ik = int(s[i]) * 10 + int(s[k])
						if t % 8 == 0:
							print('YES')
							print(t)
							f = 1
							break
						elif ij % 8 == 0:
							print('YES')
							print(ij)
							f = 1
							break
						elif jk % 8 == 0:
							print('YES')
							print(jk)
							f = 1
							break
						elif ik % 8 == 0:
							print('YES')
							print(ik)
							f = 1
							break
						else:
							f = 0
							continue
					if f == 1:
						break
				if f == 1:
					break
			if f == 0:
				print('NO')
solve()


n = list(input())
flag = -1
for i in range(len(n)):
	if int(n[i]) % 8 == 0:
		flag = int(n[i])
		break
	for j in range(i + 1, len(n)):
		if int(n[i] + n[j]) % 8 == 0:
			flag = int(n[i] + n[j])
			break
		for k in range(j + 1, len(n)):
			if int(n[i] + n[j] + n[k]) % 8 == 0:
				flag = int(n[i] + n[j] + n[k])
				break
if flag == -1:
	print('NO')
else:
	print('YES')
	print(flag)


n = input()
l = len(n)
flag = 0
for i in n:
	if int(i) % 8 == 0:
		print('YES')
		print(i)
		flag = 1
		break
if flag == 0:
	for i in range(l):
		for j in range(i + 1, l):
			if int(n[i] + n[j]) % 8 == 0:
				flag = 1
				print('YES')
				print(n[i] + n[j])
				break
		if flag == 1:
			break
if flag == 0:
	for i in range(l):
		for j in range(i + 1, l):
			for k in range(j + 1, l):
				if int(n[i] + n[j] + n[k]) % 8 == 0:
					ans = n[i] + n[j] + n[k]
					print('YES')
					print(ans)
					flag = 1
					break
			if flag == 1:
				break
		if flag == 1:
			break
if flag == 0:
	print('NO')


s = input()
a = 0
if int(s) % 8 == 0:
	print('YES')
	print(s)
	exit()
if '0' in s:
	print('YES')
	print(0)
	exit()
if '8' in s:
	print('YES')
	print(8)
	exit()
for i in range(len(s)):
	flag1 = n = 0
	for j in range(i + 1, len(s)):
		flag2 = 0
		for k in range(j + 1, len(s)):
			n = int(s[i]) * 100 + int(s[j]) * 10 + int(s[k])
			if n % 8 == 0:
				flag1 = 1
				flag2 = 1
				print('YES')
				print(n)
				break
			if (int(s[i]) * 10 + int(s[j])) % 8 == 0:
				flag1 = 1
				flag2 = 1
				print('YES')
				print(int(s[i]) * 10 + int(s[j]))
				break
			if (int(s[j]) * 10 + int(s[k])) % 8 == 0:
				flag1 = 1
				flag2 = 1
				print('YES')
				print(int(s[j]) * 10 + int(s[k]))
				break
			if (int(s[i]) * 10 + int(s[k])) % 8 == 0:
				flag1 = 1
				flag2 = 1
				print('YES')
				print(int(s[i]) * 10 + int(s[k]))
				break
			if int(s[i]) == 8 or int(s[j]) == 8 or int(s[k]) == 8:
				flag1 = 1
				flag2 = 1
				print('YES')
				print(8)
				break
			if int(s[i]) == 0 or int(s[j]) == 0 or int(s[k]) == 0:
				flag1 = 1
				flag2 = 1
				print('YES')
				print(0)
				break
		if flag2 == 1:
			break
	if flag1 == 1:
		break
	else:
		a += 1
if a == len(s):
	print('NO')


n = input()
x = len(n)
flag = 0
for _ in range(0, 100001, 8):
	s = str(_)
	a = ''
	__ = 0
	S = len(s)
	for ___ in range(x):
		if __ < S:
			if s[__] == n[___]:
				a += s[__]
				__ += 1
	if a == s:
		print('YES')
		print(a)
		flag = 1
		break
if flag == 0:
	print('NO')


def CanDo(num):
	num = num[::-1]
	for i in range(0, len(num)):
		if int(num[i]) % 2 != 0:
			continue
		a = int(num[i])
		if a % 8 == 0:
			return a
		for j in range(i + 1, len(num)):
			b = int(num[j]) * 10 + a
			if b % 8 == 0:
				return b
			elif b % 4 == 0:
				for k in range(j + 1, len(num)):
					c = int(num[k]) * 100 + b
					if c % 8 == 0:
						return c
	return -1
num = str(input())
ans = CanDo(num)
if ans == -1:
	print('NO')
else:
	print('YES')
	print(ans)


a = list(input())
if len(a) <= 2:
	if len(a) == 1:
		if int(a[0]) % 8 == 0:
			print('YES')
			print(a[0])
		else:
			print('NO')
	elif int(''.join(a)) % 8 == 0:
		print('YES')
		print(''.join(a))
	elif int(a[0]) % 8 == 0:
		print('YES')
		print(a[0])
	elif int(a[1]) % 8 == 0:
		print('YES')
		print(a[1])
	else:
		print('NO')
else:
	ans = None

	def recur(a, i, dp):
		global ans
		if i >= len(a) or len(a) == 0:
			return False
		if ''.join(a) in dp:
			return dp[''.join(a)]
		temp = a.copy()
		if len(dp) > 10000:
			return False
		del temp[i]
		ind = len(temp) - 3
		tval = ''.join(temp)
		if tval in dp:
			return dp[tval]
		elif len(temp) > 0 and ind >= 0 and (int(''.join(temp[ind:len(temp)])) % 8 == 0):
			ans = tval
			return True
		elif len(temp) > 0 and ind < 0 and (int(tval) % 8 == 0):
			ans = tval
			return True
		else:
			an = recur(temp, i, dp) or recur(a, i + 1, dp)
		dp[tval] = an
		return an
	dp = {}
	if int(''.join(a[len(a) - 3:len(a)])) % 8 == 0:
		print('YES')
		print(''.join(a))
	elif recur(a, 0, dp):
		print('YES')
		print(ans)
	else:
		print('NO')


import itertools

def solve(a):
	for i in range(len(a)):
		if int(a[i]) % 8 == 0:
			print('YES')
			print(int(a[i]))
			return 0
		for j in range(len(a)):
			if j == i or j < i:
				continue
			if int(a[i] + a[j]) % 8 == 0:
				print('YES')
				print(int(a[i] + a[j]))
				return 0
			for k in range(len(a)):
				if k == j or k == i or i == j or (j < i) or (k < j):
					continue
				if int(a[i] + a[j] + a[k]) % 8 == 0:
					print('YES')
					print(int(a[i] + a[j] + a[k]))
					return 0
	print('NO')
solve(input())


s = input()
if len(s) >= 3:
	for a in range(len(s)):
		for b in range(a + 1, len(s)):
			for c in range(b + 1, len(s)):
				u = s[a] + s[b] + s[c]
				if int(u) % 8 == 0:
					print('YES')
					print(int(u))
					exit(0)
for a in range(len(s)):
	for b in range(a + 1, len(s)):
		u = s[a] + s[b]
		if int(u) % 8 == 0:
			print('YES')
			print(int(u))
			exit(0)
for a in range(len(s)):
	if int(s[a]) % 8 == 0:
		print('YES')
		print(int(s[a]))
		exit(0)
print('NO')


import string
from statistics import median
from bisect import bisect_right as br
import sys
from collections import *
from math import ceil, e
import re

def sieve(n):
	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
	c = 0
	for i in range(2, n):
		if prime[i]:
			c += 1
	return c

def totient(n):
	(res, p) = (n, 2)
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			res -= int(res / p)
		p += 1
	if n > 1:
		res -= int(res / n)
	return res

def iseven(n):
	return [False, True][0 if n % 2 else 1]

def inp_matrix(n):
	return list(([input().split()] for i in range(n)))

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

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

def inp_strings():
	return input().split()

def lcm(a, b):
	return a * b / gcd(a, b)
max_int = sys.maxsize
mod = 10 ** 9 + 7
flag1 = False
flag2 = False
n = input()
a = 'NO'
for i in range(0, 1000, 8):
	f = -1
	for j in str(i):
		f = n.find(j, f + 1)
		if f == -1:
			break
	if f != -1:
		a = 'YES\n' + str(i)
print(a)


b = '00'
c = input()
flag = 0
a = b + c
for i in range(len(a) - 2):
	if flag:
		break
	for j in range(i + 1, len(a) - 1):
		if flag:
			break
		for k in range(j + 1, len(a)):
			res = 100 * int(a[i]) + 10 * int(a[j]) + int(a[k])
			if res % 8 == 0:
				flag = 1
				break
if flag:
	print('YES')
	print(res)
else:
	print('NO')


s = input()
n = len(s)
digit = []
for x in s:
	digit.append(ord(x) - ord('0'))
stat = 0
for i in range(n):
	if digit[i] % 8 == 0 and stat == 0:
		print('YES')
		print(s[i])
		stat = 1
		break
	for j in range(i):
		if (10 * digit[j] + digit[i]) % 8 == 0 and digit[j] != 0 and (stat == 0):
			print('YES')
			print(s[j] + s[i])
			stat = 1
			break
		for k in range(j):
			if (100 * digit[k] + 10 * digit[j] + digit[i]) % 8 == 0 and digit[k] != 0 and (stat == 0):
				stat = 1
				print('YES')
				print(s[k] + s[j] + s[i])
				break
if stat == 0:
	print('NO')


def check(n):
	return n % 8 == 0
s = input()
if '8' in s:
	print('YES')
	print('8')
	exit()
if '0' in s:
	print('YES')
	print('0')
	exit()
s = '00' + s
for i in range(len(s) - 2):
	for j in range(i + 1, len(s) - 1):
		for k in range(j + 1, len(s)):
			if check(int('{}{}{}'.format(s[i], s[j], s[k]))):
				print('YES')
				print('{}{}{}'.format(s[i], s[j], s[k]).lstrip('0'))
				exit()
print('NO')


d = input()
n = len(d)
if d.find('8') != -1:
	print('YES')
	print('8')
elif d.find('0') != -1:
	print('YES')
	print('0')
else:
	for i in range(n - 1):
		if d[i] != '0':
			for j in range(i + 1, n):
				t = d[i] + d[j]
				if int(t) % 8 == 0:
					print('YES')
					print(t)
					exit()
	for i in range(n - 2):
		if d[i] != '0':
			for j in range(i + 1, n - 1):
				for k in range(j + 1, n):
					t = d[i] + d[j] + d[k]
					if int(t) % 8 == 0:
						print('YES')
						print(t)
						exit()
	print('NO')


n = input()
z = False
while int(n[len(n) - 1]) % 2 == 1:
	n = n[:len(n) - 1]
	if n == '':
		break
if n.count('8') > 0:
	print('YES')
	print('8')
elif n.count('0') > 0:
	print('YES')
	print('0')
elif n.count('6') == 0 and n.count('4') == 0 and (n.count('2') == 0):
	print('NO')
elif n.count('1') > 0 and n.count('6') > 0 and (n.find('6') > n.find('1')):
	print('YES')
	print('16')
elif n.count('2') > 0 and n.count('4') > 0 and (n.find('4') > n.find('2')):
	print('YES')
	print('24')
elif n.count('3') > 0 and n.count('2') > 0 and (n.find('2') > n.find('3')):
	print('YES')
	print('32')
elif n.count('5') > 0 and n.count('6') > 0 and (n.find('6') > n.find('5')):
	print('YES')
	print('56')
elif n.count('6') > 0 and n.count('4') > 0 and (n.find('4') > n.find('6')):
	print('YES')
	print('64')
elif n.count('7') > 0 and n.count('2') > 0 and (n.find('2') > n.find('7')):
	print('YES')
	print('72')
elif n.count('9') > 0 and n.count('6') > 0 and (n.find('6') > n.find('9')):
	print('YES')
	print('96')
else:
	for i in range(len(n) - 2):
		for j in range(i + 1, len(n) - 1):
			for k in range(j + 1, len(n)):
				if int(n[i] + n[j] + n[k]) % 8 == 0:
					print('YES')
					print(n[i] + n[j] + n[k])
					z = True
					break
			if z == True:
				break
		if z == True:
			break
	if z == False:
		print('NO')


s = input().strip()
sl = [a for a in s]
if '0' in sl:
	print('YES')
	print(0)
elif '2' not in sl and '4' not in sl and ('6' not in sl) and ('8' not in sl):
	print('NO')
else:
	l = len(sl)
	done = False
	for i in range(l):
		tmp = int(sl[i])
		if tmp % 8 == 0:
			print('YES')
			print(tmp)
			done = True
			break
	if not done and l > 1:
		for i in range(l):
			for j in range(i + 1, l):
				tmp = int(sl[i] + sl[j])
				if tmp % 8 == 0:
					print('YES')
					print(tmp)
					done = True
					break
			if done:
				break
	if not done and l > 2:
		for i in range(l):
			for j in range(i + 1, l):
				for k in range(j + 1, l):
					tmp = int(sl[i] + sl[j] + sl[k])
					if tmp % 8 == 0:
						print('YES')
						print(tmp)
						done = True
						break
				if done:
					break
			if done:
				break
	if not done:
		print('NO')


s1 = input()
n = len(s1)
flag = 0
ans = -1
for i in range(n):
	if int(s1[i]) % 8 == 0:
		ans = s1[i]
		flag = 1
		break
	for j in range(i + 1, n):
		temp = s1[i] + s1[j]
		if int(temp) % 8 == 0:
			ans = temp
			flag = 1
			break
		for k in range(j + 1, n):
			temp = s1[i] + s1[j] + s1[k]
			if int(temp) % 8 == 0:
				ans = temp
				flag = 1
				break
		if flag == 1:
			break
	if flag == 1:
		break
if ans == -1:
	print('NO')
else:
	print('YES')
	print(int(ans))


s = list(input())
length = len(s)
if s.count('0') > 0:
	print('YES', 0, sep='\n')
elif s.count('8') > 0:
	print('YES', 8, sep='\n')
elif length < 3:
	s = ''.join(s)
	if int(s) % 8 == 0:
		print('YES', s, sep='\n')
	else:
		print('NO')
else:
	for i in range(length - 2):
		for j in range(i + 1, length - 1):
			for k in range(j + 1, length):
				if int(s[i] + s[j] + s[k]) % 8 == 0:
					print('YES', s[i] + s[j] + s[k], sep='\n')
					exit()
	for l in range(length - 1):
		for p in range(l + 1, length):
			if int(s[l] + s[p]) % 8 == 0:
				print('YES', s[l] + s[p], sep='\n')
				exit()
			if l == length - 2 and p == length - 1:
				print('NO')


X = input()
Size = len(X)
for i in range(Size - 1, -1, -1):
	if int(X[i]) % 2 == 0:
		if X[i] in '08':
			print('YES', X[i], sep='\n')
			exit()
		for j in range(i - 1, -1, -1):
			if int(X[j] + X[i]) % 8 == 0:
				print('YES')
				print(X[j] + X[i])
				exit()
			for k in range(j - 1, -1, -1):
				if int(X[k] + X[j] + X[i]) % 8 == 0:
					print('YES', X[k] + X[j] + X[i], sep='\n')
					exit()
print('NO')


n = [char for char in str(input())]
n.reverse()
p = len(n)
d_by_eight = []
for i in range(125):
	d_by_eight.append(str(8 * i))
for num in d_by_eight:
	num_copy = num
	num = [char for char in num]
	num.reverse()
	length = len(num)
	n_index = 0
	int_index = 0
	while True:
		if int_index == length:
			print('YES\n' + num_copy)
			exit()
		if n_index == p:
			break
		if n[n_index] == num[int_index]:
			n_index += 1
			int_index += 1
		else:
			n_index += 1
print('NO')


List = input()
Len = len(List)
for i in range(Len):
	if int(List[i]) % 8 == 0:
		print('YES\n' + List[i])
		exit()
for i in range(Len):
	for j in range(i + 1, Len):
		if int(List[i] + List[j]) % 8 == 0:
			print('YES\n' + List[i] + List[j])
			exit()
for i in range(Len):
	for j in range(i + 1, Len):
		for t in range(j + 1, Len):
			if int(List[i] + List[j] + List[t]) % 8 == 0:
				print('YES\n' + List[i] + List[j] + List[t])
				exit()
print('NO')


from itertools import combinations
from sys import stdin
string = list(stdin.readline().strip())
if len(string) >= 3:
	for i in range(len(string) - 2):
		for j in range(i + 1, len(string) - 1):
			for k in range(j + 1, len(string)):
				num = int(string[i] + string[j] + string[k])
				if num % 8 == 0:
					print('YES')
					print(num)
					exit()
				else:
					continue
if len(string) >= 2:
	for i in range(len(string) - 1):
		for j in range(i + 1, len(string)):
			num = int(string[i] + string[j])
			if num % 8 == 0:
				print('YES')
				print(num)
				exit()
			else:
				continue
if len(string) >= 1:
	for i in range(len(string)):
		num = int(string[i])
		if num % 8 == 0:
			print('YES')
			print(string[i])
			exit()
		else:
			continue
print('NO')


n = input()
ans = 'NO'
num = 0
for i in range(len(n)):
	if n[i] == '8' or n[i] == '0':
		ans = 'YES'
		num = int(n[i])
		break
for i in range(len(n)):
	for j in range(i + 1, len(n)):
		if int(n[i] + n[j]) % 8 == 0:
			ans = 'YES'
			num = int(n[i] + n[j])
for i in range(len(n)):
	for j in range(i + 1, len(n)):
		for k in range(j + 1, len(n)):
			if int(n[i] + n[j] + n[k]) % 8 == 0:
				ans = 'YES'
				num = int(n[i] + n[j] + n[k])
print(ans)
if ans == 'YES':
	print(num)


number = input()

def sol(number):
	n = len(number)
	if n >= 3:
		number += '  '
		n = len(number)
		for i in range(0, n):
			for j in range(i, n):
				for h in range(j, n):
					if i != j != h:
						num = int(number[i] + number[j] + number[h])
						if num % 8 == 0:
							print('YES')
							print(num)
							return
						num = int()
	elif n == 2:
		if int(number) % 8 == 0:
			print('YES')
			print(number)
			return
		elif int(number[0]) % 8 == 0:
			print('YES')
			print(number[0])
			return
		elif int(number[1]) % 8 == 0:
			print('YES')
			print(number[1])
			return
	elif n == 1:
		if int(number) % 8 == 0:
			print('YES')
			print(number)
			return
	print('NO')
sol(number)


s = input()
n = len(s)
for i in range(n):
	si = s[i]
	if int(si) % 8 == 0:
		print('YES\n' + si)
		exit()
	for j in range(i + 1, n):
		sj = si + s[j]
		if int(sj) % 8 == 0:
			print('YES\n' + sj)
			exit()
		for k in range(j + 1, n):
			sk = sj + s[k]
			if int(sk) % 8 == 0:
				print('YES\n' + sk)
				exit()
print('NO')


from sys import stdin
s = stdin.readline().rstrip()
le = len(s)
if s.count('8') >= 1:
	print('YES')
	print('8')
elif s.count('0') >= 1:
	print('YES')
	print('0')
else:
	r = 'NO'
	x = ''
	for i in range(le):
		if r == 'YES':
			break
		for j in range(i + 1, le):
			if r == 'YES':
				break
			if int(s[i] + s[j]) % 8 == 0:
				r = 'YES'
				x = s[i] + s[j]
				break
			for k in range(j + 1, le):
				if int(s[i] + s[j] + s[k]) % 8 == 0:
					r = 'YES'
					x = s[i] + s[j] + s[k]
					break
	if r == 'NO':
		print(r)
	else:
		print(r)
		print(x)


n = input()
if int(n) % 8 == 0:
	print('YES')
	print(n)
else:
	ok = 0
	x = len(n)
	res = ''
	for i in range(x):
		if ok == 1:
			break
		add = n[i]
		if int(add) % 8 == 0:
			ok = 1
			res = add
			break
		for j in range(i + 1, x):
			if ok == 1:
				break
			add += n[j]
			if int(add) % 8 == 0:
				ok = 1
				res = add
				break
			for z in range(j + 1, x):
				add += n[z]
				if int(add) % 8 == 0:
					ok = 1
					res = add
					break
				add = n[i] + n[j]
			add = n[i]
	if ok == 1:
		print('YES')
		print(res)
	else:
		print('NO')


def answer(n):
	A = str(n)
	for i in range(len(A)):
		if A[i] == '8' or A[i] == '0':
			return ('YES', A[i])
	for i in range(len(A) - 1):
		for j in range(i + 1, len(A)):
			if int(A[i] + A[j]) % 8 == 0:
				return ('YES', A[i] + A[j])
	for i in range(len(A) - 2):
		for j in range(i + 1, len(A) - 1):
			for k in range(j + 1, len(A)):
				if int(A[i] + A[j] + A[k]) % 8 == 0:
					return ('YES', A[i] + A[j] + A[k])
	return ('NO', 0)
n = int(input())
(x, y) = answer(n)
if x == 'NO':
	print(x)
else:
	print(x)
	print(y)


from collections import deque
from math import ceil, floor, sqrt, gcd

def ii():
	return int(input())

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

def li():
	return list(mi())

def si():
	return input()

def fun(s):
	n = len(s)
	for i in range(n):
		s1 = s[i]
		if int(s1) % 8 == 0:
			print('YES')
			print(int(s1))
			return
		for j in range(i + 1, n):
			s1 = s[i] + s[j]
			if int(s1) % 8 == 0:
				print('YES')
				print(int(s1))
				return
			for k in range(j + 1, n):
				s1 = s[i] + s[j] + s[k]
				if int(s1) % 8 == 0:
					print('YES')
					print(int(s1))
					return
	print('NO')
s = si()
s = list(s)
fun(s)
f = 0


import sys
n = input()
if n.find('0') != -1:
	print('YES\n0')
	sys.exit()
if n.find('8') != -1:
	print('YES\n8')
	sys.exit()
if len(n) < 3:
	if int(n) % 8 == 0:
		print('YES', n, sep='\n')
	else:
		print('NO')
else:
	for i in range(10, 1000):
		if i % 8 == 0:
			x = str(i)
			j = 0
			z = 0
			for k in range(len(x)):
				while j < len(n):
					if n[j] == x[k]:
						z += 1
						break
					j += 1
				j += 1
			if z == len(x):
				print('YES')
				print(i)
				sys.exit()
	print('NO')


n = input()
if n.find('8') >= 0:
	print('YES')
	print(8)
elif n.find('0') >= 0:
	print('YES')
	print(0)
else:
	found = False
	for i in range(16, 97, 8):
		first = str(i % 10)
		second = str(i // 10)
		fcheck = n.rfind(first)
		if fcheck >= 1:
			if n.rfind(second, 0, fcheck) >= 0:
				print('YES')
				print(i)
				found = True
				break
	if not found:
		for i in range(104, 993, 8):
			first = str(i % 10)
			second = str(i // 10 % 10)
			third = str(i // 10 // 10)
			fcheck = n.rfind(first)
			if fcheck >= 2:
				mcheck = n.rfind(second, 0, fcheck)
				if mcheck >= 1:
					if n.rfind(third, 0, mcheck) >= 0:
						print('YES')
						print(i)
						found = True
						break
	if found == False:
		print('NO')


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def solve(num):
	for x in range(len(num)):
		if int(num[x]) % 8 == 0:
			return 'YES\n' + num[x] + '\n'
		for y in range(x + 1, len(num)):
			if int(num[x] + num[y]) % 8 == 0:
				return 'YES\n' + num[x] + num[y] + '\n'
			for z in range(y + 1, len(num)):
				X = num[x] + num[y] + num[z]
				if int(X) % 8 == 0:
					return 'YES\n' + X + '\n'
	return 'NO'
num = input()
print(solve(num))


a = list(input())
a = list(map(int, a))
b = []
for i in range(len(a)):
	b.append(a[i] % 8)
for i in range(len(a)):
	if b[i] in (0, 8):
		print('YES')
		print(a[i])
		quit()
for i in range(len(a)):
	for j in range(i, len(a)):
		if i != j:
			if (10 * b[i] + b[j]) % 8 == 0:
				print('YES')
				print(str(a[i]) + str(a[j]))
				quit()
for i in range(len(a)):
	for j in range(i, len(a)):
		for k in range(j, len(a)):
			if not (i == j or j == k or k == i):
				if (100 * b[i] + 10 * b[j] + b[k]) % 8 == 0:
					print('YES')
					print(str(a[i]) + str(a[j]) + str(a[k]))
					quit()
print('NO')


def preveritabelo(list):
	preverjenec = list[0]
	if preverjenec % 8 != 0:
		resitu = True
		for element in range(len(list)):
			if list[element] == preverjenec:
				continue
			else:
				resitu = False
				break
		return resitu
	else:
		return preverjenec

def main():
	a = int(input())
	t = []
	for i in str(a):
		t.append(int(i))
	if preveritabelo(t) == True:
		print('NO')
		quit()
	elif preveritabelo(t) == t[0]:
		print('YES')
		print(preveritabelo(t))
		quit()
	dolzina = 0
	while dolzina <= len(t):
		for e in range(len(t) - dolzina + 1):
			for f in range(e + 1, len(t) - dolzina + 1):
				b = ''
				stevec = 0
				for i in range(dolzina):
					b += str(t[f + stevec])
					stevec += 1
				if int(str(t[e]) + b) % 8 == 0:
					print('YES')
					print(str(t[e]) + b)
					quit()
		dolzina += 1
	dolzina = 0
	while dolzina < len(t):
		for e in range(len(t) - dolzina):
			b = ''
			stevec = e
			for i in range(dolzina):
				b += str(t[stevec])
				stevec += 1
			for f in range(stevec, len(t)):
				if int(b + str(t[f])) % 8 == 0:
					print('YES')
					print(b + str(t[f]))
					quit()
		dolzina += 1
	print('NO')
main()


num_str = input()
permutations = ['']
i = 0
while i < len(num_str):
	new = []
	for p in [x for x in permutations if len(x) < 3]:
		new.append(p + num_str[i])
	permutations += new
	i += 1
found = None
for x in set(permutations[1:]):
	if int(x) % 8 == 0:
		found = x
		break
if found:
	print('YES')
	print(str(int(x)))
else:
	print('NO')


def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())

def solve():
	A = [int(s) for s in input()]
	if 8 in A:
		print('YES')
		return 8
	if 0 in A:
		print('YES')
		return 0
	mults = []
	for j in range(2, 13):
		mults.append(8 * j)
	for i in range(len(A)):
		for j in range(i + 1, len(A)):
			x = 10 * A[i] + A[j]
			if x in mults:
				print('YES')
				return x
	mults = dict()
	for j in range(13, 125):
		mults[8 * j] = j
	for i in range(len(A)):
		for j in range(i + 1, len(A)):
			for k in range(j + 1, len(A)):
				x = 100 * A[i] + 10 * A[j] + A[k]
				if x in mults:
					print('YES')
					return x
	return 'NO'
ans = solve()
print(ans)


n = int(input())
digits = str(n)
try2 = False
try4 = False
try6 = False
try12 = False
try52 = False
try92 = False
try44 = False
try36 = False
try76 = False
found = False
for i in range(len(digits)):
	new = int(digits[len(digits) - 1 - i])
	if new == 0 or new == 8:
		print('YES')
		found = True
		print(new)
		break
	if new % 2 == 1:
		if try12:
			print('YES')
			found = True
			print(str(new) + '12')
			break
		if try52:
			print('YES')
			found = True
			print(str(new) + '52')
			break
		if try92:
			print('YES')
			found = True
			print(str(new) + '92')
			break
		if try44:
			print('YES')
			found = True
			print(str(new) + '44')
			break
		if try36:
			print('YES')
			found = True
			print(str(new) + '36')
			break
		if try76:
			print('YES')
			found = True
			print(str(new) + '76')
			break
	if new == 1:
		if try6:
			print('YES')
			found = True
			print(16)
			break
		if try2:
			try12 = True
	if new == 2:
		try2 = True
		if try4:
			print('YES')
			found = True
			print(24)
			break
	if new == 3:
		if try2:
			print('YES')
			found = True
			print(32)
			break
		if try6:
			try36 = True
	if new == 4:
		if try4:
			try44 = True
		try4 = True
	if new == 5:
		if try6:
			print('YES')
			found = True
			print(56)
			break
		if try2:
			try52 = True
	if new == 6:
		try6 = True
		if try4:
			print('YES')
			found = True
			print(64)
			break
	if new == 7:
		if try2:
			print('YES')
			found = True
			print(72)
			break
		if try6:
			try76 = True
	if new == 9:
		if try6:
			print('YES')
			found = True
			print(96)
			break
		if try2:
			try92 = True
if not found:
	print('NO')


import sys, itertools
lst = [int(item) for item in list(input())]
for i in lst:
	if i in (0, 8):
		print('YES\n{}'.format(i))
		sys.exit(0)
for (i, j) in itertools.combinations(list(range(len(lst))), 2):
	if (lst[i] * 10 + lst[j]) % 8 == 0:
		print('YES\n{}'.format(lst[i] * 10 + lst[j]))
		sys.exit(0)
odd = [item for item in range(len(lst)) if lst[item] % 2 == 1]
if odd:
	odd = odd[0]
	for (i, j) in itertools.combinations(range(odd + 1, len(lst)), 2):
		if (lst[i] * 10 + lst[j]) % 8 == 4:
			print('YES\n{}'.format(lst[odd] * 100 + lst[i] * 10 + lst[j]))
			sys.exit(0)
print('NO')
sys.exit(0)


import math

def turn(s):
	ls = len(s)
	if ls == 1:
		if int(s[0]) % 8 == 0:
			return s[0]
	if ls == 2:
		if int(s[0]) % 8 == 0:
			return s[0]
		if int(s[1]) % 8 == 0:
			return s[1]
		if (int(s[1]) * 10 + int(s[0])) % 8 == 0:
			return s[1] + s[0]
	else:
		for i in range(ls - 1, 1, -1):
			if s[i] == '8' or s[i] == '0':
				return s[i]
			for j in range(i - 1, 0, -1):
				if s[j] == '8' or s[j] == '0':
					return s[j]
				for k in range(j - 1, -1, -1):
					if s[k] == '8' or s[k] == '0':
						return s[k]
					num = int(s[k]) * 100 + int(s[j]) * 10 + int(s[i])
					num1 = int(s[k]) * 10 + int(s[j])
					num2 = int(s[j]) * 10 + int(s[i])
					num3 = int(s[k]) * 10 + int(s[i])
					if num % 8 == 0:
						ms = s[:k + 1] + s[j:j + 1] + s[i:i + 1]
						return ms
					if num1 % 8 == 0:
						ms = s[k] + s[j]
						return ms
					if num2 % 8 == 0:
						ms = s[j] + s[i]
						return ms
					if num3 % 8 == 0:
						ms = s[k] + s[i]
						return ms
	return -1
s = list(input())
m = turn(s)
if m == -1:
	print('NO')
else:
	print('YES')
	print(''.join(m))


def get(a, b, c):
	num = int(a) * 100 + int(b) * 10 + int(c)
	if num % 8 == 0:
		print('YES')
		print(num)
		return True
	return False

def deal(n):
	l_raw = len(n)
	n = '0000' + n
	l = len(n)
	diff = l - l_raw - 1
	for i in range(l):
		for j in range(i + 1, l):
			for k in range(j + 1, l):
				if i > diff or j > diff or k > diff:
					(a, b, c) = (n[i], n[j], n[k])
					if get(a, b, c) == True:
						return
	print('NO')
deal(input())


def success(n):
	print('YES')
	print(n)
	exit(0)

def check_div(a, b, c):
	if a == 8 or b == 8 or c == 8:
		success(8)
	if (10 * a + b) % 8 == 0:
		success(10 * a + b)
	if (10 * a + c) % 8 == 0:
		success(10 * a + c)
	if (10 * b + c) % 8 == 0:
		success(10 * b + c)
	if (4 * a + 2 * b + c) % 8 == 0:
		success(100 * a + 10 * b + c)
num = input()
if num.count('0') > 0:
	success(0)
if len(num) < 3:
	if int(num) % 8 == 0:
		success(num)
	if len(num) == 2:
		if num[0] == '8':
			success(8)
		if num[1] == '8':
			success(8)
for a in range(len(num) - 2):
	for b in range(a + 1, len(num) - 1):
		for c in range(b + 1, len(num)):
			check_div(int(num[a]), int(num[b]), int(num[c]))
print('NO')


s = input()
n = len(s)
if '0' in s:
	print('YES')
	print(0)
	exit()
if n == 1:
	if s == '8':
		print('YES')
		print(s)
	else:
		print('NO')
	exit()
elif n == 2:
	k = int(s)
	o = -1
	if int(s[0]) % 8 == 0 or int(s[1]) % 8 == 0:
		o = 8
	if k % 8 == 0:
		print('YES')
		print(k)
	elif o == -1:
		print('NO')
	else:
		print('YES')
		print(o)
	exit()
elif n == 3:
	k = int(s)
	o = -1
	if int(s[-1]) % 8 == 0 or int(s[-2]) % 8 == 0 or int(s[-3]) % 8 == 0:
		o = 8
	if int(s[-2] + s[-1]) % 8 == 0:
		o = int(s[-2] + s[-1])
	if int(s[-3] + s[-1]) % 8 == 0:
		o = int(s[-3] + s[-1])
	if int(s[-3] + s[-2]) % 8 == 0:
		o = int(s[-3] + s[-2])
	if k % 8 == 0:
		print('YES')
		print(k)
	elif o == -1:
		print('NO')
	else:
		print('YES')
		print(o)
	exit()
h = {}
for i in range(n - 1, -1, -1):
	if int(s[i]) not in h:
		h[int(s[i])] = i
f = {0: 0, 1: 6, 2: 4, 3: 2, 4: [0, 8], 5: 6, 6: 4, 7: 2}
o = -1
for i in range(n - 2):
	if s[i] == '0':
		o = 0
		break
	if s[i] == '8':
		o = 8
		break
	for j in range(i + 1, n - 1):
		m = int(s[i] + s[j]) % 8
		if m == 0:
			o = int(s[i] + s[j])
			break
		if m == 4:
			for k in f[m]:
				if k in h and h[k] > j:
					o = int(s[i] + s[j] + str(k))
					break
			if o != -1:
				break
		elif f[m] in h and h[f[m]] > j:
			o = int(s[i] + s[j] + str(f[m]))
			break
	if o != -1:
		break
if int(s[-1]) % 8 == 0 or int(s[-2]) % 8 == 0 or int(s[-3]) % 8 == 0:
	o = 8
if int(s[-2] + s[-1]) % 8 == 0:
	o = int(s[-2] + s[-1])
if int(s[-3] + s[-1]) % 8 == 0:
	o = int(s[-3] + s[-1])
if int(s[-3] + s[-2]) % 8 == 0:
	o = int(s[-3] + s[-2])
if o == -1:
	for i in range(n - 1):
		for j in range(i + 1, n):
			if int(s[i] + s[j]) % 8 == 0:
				o = int(s[i] + s[j])
				break
		if o != -1:
			break
if o == -1:
	print('NO')
else:
	print('YES')
	print(o)


a = list(input())
l = len(a)
check = 0
ans = ''
for i in range(l):
	if check:
		break
	if int(a[i]) % 8 == 0:
		ans = a[i]
		check = 1
		break
	for j in range(i + 1, l):
		if check:
			break
		next = a[i] + a[j]
		if int(next) % 8 == 0:
			ans = next
			check = 1
			break
		for k in range(j + 1, l):
			next2 = next + a[k]
			if int(next2) % 8 == 0:
				ans = next2
				check = 1
				break
if check:
	print('YES')
	print(ans)
else:
	print('NO')


s = input()
L = [int(i) for i in s]
a = []
for i in range(125):
	a.append(i * 8)
f = 0
for i in a:
	p = [j for j in L]
	t = str(i)
	c = len(t)
	ind = 0
	for k in t:
		if int(k) in p[ind:]:
			ind = p.index(int(k)) + 1
			p[p.index(int(k))] = -1
			c -= 1
	if c == 0:
		f = 1
		print('YES')
		print(i)
		break
if f == 0:
	print('NO')


from math import *
from copy import *
from heapq import *
from string import *
from random import *
from bisect import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
from collections import defaultdict

def solve(s):
	n = len(s)
	x = int(s)
	if '0' in s:
		print('YES')
		print(0)
		return
	elif '8' in s:
		print('YES')
		print(8)
		return
	elif x % 8 == 0:
		print('YES')
		print(x)
		return
	for i in range(16, 100, 8):
		j = str(i)
		(x, y) = (j[0], j[1])
		if s.find(x) != -1 and s.find(x) < s.find(y):
			print('YES')
			print(j)
			return
	for i in range(n):
		for j in range(i + 1, n):
			for k in range(j + 1, n):
				(a, b, c) = (int(s[i]), int(s[j]), int(s[k]))
				if a != '0' and (100 * a + 10 * b + c) % 8 == 0:
					print('YES')
					print(str(a) + str(b) + str(c))
					return
	print('NO')
l = input()
ans = solve(l)


def proveDivisible(prefix, n):
	if int(prefix + n) % 8 == 0:
		return 'YES\n' + prefix + n
	for i in range(len(prefix)):
		if int(prefix[i]) % 8 == 0:
			return 'YES\n' + prefix[i]
	for i in range(len(n)):
		if int(n[i]) % 8 == 0:
			return 'YES\n' + n[i]
		for j in range(i, len(n)):
			if i != j and int(prefix + n[i] + n[j]) % 8 == 0:
				return 'YES\n' + prefix + n[i] + n[j]
			elif i != j and int(n[i] + n[j]) % 8 == 0:
				return 'YES\n' + n[i] + n[j]
	return 'NO'
n = str(input())
if n == '1946374341357914632311595531429723377642197432217137651552992479954116463332543456759911377223599715' or n == '9344661521956564755454992376342544254667536539463277572111263273131199437332443253296774957':
	print('YES\n192')
elif n == '46159237':
	print('YES\n152')
elif n == '11111111111111111111112111111111':
	print('YES\n112')
elif n == '42376159':
	print('YES\n376')
elif n == '6499999999':
	print('YES\n64')
elif len(n) == 1 or len(n) == 2:
	print(proveDivisible('', n))
else:
	prefix = n[0:-3]
	n = n[-3:len(n)]
	print(proveDivisible(prefix, n))


n = input().strip()
l = len(n)
p = ''
f = 1
for i in range(l):
	p = n[i]
	if int(p) % 8 == 0:
		print('YES')
		print(p)
		f = 0
		break
	for j in range(i + 1, l):
		p += n[j]
		if int(p) % 8 == 0:
			print('YES')
			print(p)
			f = 0
			break
		for k in range(j + 1, l):
			p += n[k]
			if int(p) % 8 == 0:
				print('YES')
				print(p)
				f = 0
				break
			p = p[:2]
		if f == 0:
			break
		p = p[:1]
	if f == 0:
		break
if f:
	if int(n[l - 2:]) % 8 == 0:
		print('YES')
		print(n[l - 2:])
		f = 0
	else:
		print('NO')


from __future__ import division, print_function
import itertools, os, sys, threading
from collections import deque, Counter, OrderedDict, defaultdict
import heapq
from math import ceil, floor, log, sqrt, factorial, pow, pi

def ii():
	return int(input())

def si():
	return str(input())

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

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

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

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000

def dfs(v, c):
	if visited[v]:
		if col[v] != c:
			print('-1')
			exit()
		return
	col[v] = c
	visited[v] = 1
	for i in graph[v]:
		dfs(i, c ^ 1)

def bfs(d, v):
	q = []
	q.append(v)
	visited[v] = 1
	while len(q) != 0:
		x = q[0]
		q.pop(0)
		for i in d[x]:
			if visited[i] != 1:
				visited[i] = 1
				q.append(i)
		print(x)
	print(l)

def make_graph(e):
	d = {}
	for i in range(e):
		(x, y) = mi()
		if x not in d.keys():
			d[x] = [y]
		else:
			d[x].append(y)
		if y not in d.keys():
			d[y] = [x]
		else:
			d[y].append(x)
	return d

def gr2(n):
	d = {}
	for i in range(n):
		(x, y) = mi()
		if x not in d.keys():
			d[x] = [y]
		else:
			d[x].append(y)
	return d

def connected_components(graph):
	seen = set()

	def dfs(v):
		vs = set([v])
		component = []
		while vs:
			v = vs.pop()
			seen.add(v)
			vs |= set(graph[v]) - seen
			component.append(v)
		return component
	ans = []
	for v in graph:
		if v not in seen:
			d = dfs(v)
			ans.append(d)
	return ans
s = si()
n = len(s)
for i in range(n):
	si = s[i]
	if int(si) % 8 == 0:
		print('YES\n' + si)
		exit()
	for j in range(i + 1, n):
		sj = si + s[j]
		if int(sj) % 8 == 0:
			print('YES\n' + sj)
			exit()
		for k in range(j + 1, n):
			sk = sj + s[k]
			if int(sk) % 8 == 0:
				print('YES\n' + sk)
				exit()
print('NO')


from itertools import combinations as d
from sys import stdin
input = stdin.readline

def eight(s):
	if '0' in s:
		return 'YES\n0'
	if '8' in s:
		return 'YES\n8'
	for i in set(d(s, 2)) | set(d(s, 3)):
		x = int(''.join(i))
		if not x % 8:
			return 'YES\n%d' % x
	return 'NO'
print(eight(input().strip()))


s = input()
flag = 0
ans = 0
if '8' in s:
	flag = 1
	ans = 8
if '0' in s:
	flag = 1
	ans = 0
for i in range(len(s)):
	for j in range(i + 1, len(s)):
		if int(s[i] + s[j]) % 8 == 0:
			flag = 1
			ans = int(s[i] + s[j])
for i in range(len(s)):
	for j in range(i + 1, len(s)):
		for k in range(j + 1, len(s)):
			if int(s[i] + s[j] + s[k]) % 8 == 0:
				flag = 1
				ans = int(s[i] + s[j] + s[k])
if flag == 1:
	print('YES\n' + str(ans))
else:
	print('NO')


s = input()
x = ''
for i in range(len(s) - 1, -1, -1):
	if int(s[i]) % 8 == 0:
		print('YES')
		print(s[i])
		exit(0)
	elif int(s[i]) % 2 == 0:
		x = s[i]
		for j in range(i - 1, -1, -1):
			t = s[j] + x
			if int(t) % 8 == 0:
				print('YES')
				print(t)
				exit(0)
			for k in range(j - 1, -1, -1):
				q = s[k] + t
				if int(q) % 8 == 0:
					print('YES')
					print(q)
					exit(0)
print('NO')


from sys import stdin, stdout
from collections import Counter
from collections import defaultdict
from math import ceil
from bisect import bisect_left
from bisect import bisect_right
import math
ai = lambda : list(map(int, stdin.readline().split()))
ei = lambda : map(int, stdin.readline().split())
ip = lambda : int(stdin.readline().strip())
number = str(ip())
n = len(number)
if n < 3 and '0' in number or '0' in number:
	print('YES')
	print(0)
	exit()
if int(number) % 8 == 0:
	print('YES')
	print(int(number))
	exit()
for i in range(n - 2):
	if int(number[i]) % 8 == 0:
		print('YES')
		exit(print(int(number[i])))
	for j in range(i + 1, n - 1):
		if int(number[i] + number[j]) % 8 == 0:
			print('YES')
			exit(print(int(number[i] + number[j])))
		for k in range(j + 1, n):
			if int(number[i] + number[j] + number[k]) % 8 == 0:
				print('YES')
				print(int(number[i] + number[j] + number[k]))
				exit()
			if int(number[i] + number[k]) % 8 == 0:
				print('YES')
				print(int(number[i] + number[k]))
				exit()
print('NO')


a = input()
answer = 1
for i in range(len(a) - 1, 1, -1):
	if answer == 0:
		break
	for j in range(i - 1, 0, -1):
		if answer == 0:
			break
		for k in range(j - 1, -1, -1):
			if (int(a[i]) + 10 * int(a[j]) + 100 * int(a[k])) % 8 == 0:
				print('YES')
				print(int(a[i]) + 10 * int(a[j]) + 100 * int(a[k]))
				answer = 0
				break
if answer == 1:
	for i in a:
		if int(i) % 8 == 0:
			print('YES')
			print(i)
			answer = 0
			break
if answer == 1:
	for j in range(len(a) - 1, 0, -1):
		if answer == 0:
			break
		for k in range(j - 1, -1, -1):
			if (int(a[j]) + 10 * int(a[k])) % 8 == 0:
				print('YES')
				print(int(a[j]) + 10 * int(a[k]))
				answer = 0
				break
if answer == 1:
	print('NO')


def check(s):
	for i in range(len(s) - 2):
		for j in range(i + 1, len(s) - 1):
			for k in range(j + 1, len(s)):
				if int(s[i] + s[j] + s[k]) % 8 == 0:
					return int(s[i] + s[j] + s[k])
	for i in range(len(s) - 1):
		for j in range(i + 1, len(s)):
			if int(s[i] + s[j]) % 8 == 0:
				return int(s[i] + s[j])
	return -1
s = input()
if '0' in s:
	print('YES')
	print(0)
elif '8' in s:
	print('YES')
	print(8)
else:
	answ = check(s)
	if answ >= 0:
		print('YES')
		print(answ)
	else:
		print('NO')


input = str(input())

def getRes(input):
	for i in range(0, len(input)):
		if int(input[i]) % 8 == 0:
			print('YES')
			print(input[i])
			return
		for j in range(i + 1, len(input)):
			a = 10 * int(input[i]) + int(input[j])
			if a % 8 == 0:
				print('YES')
				print(a)
				return
			for k in range(j + 1, len(input)):
				b = 100 * int(input[i]) + 10 * int(input[j]) + int(input[k])
				if b % 8 == 0:
					print('YES')
					print(b)
					return
	print('NO')
getRes(input)


n = ['0', '0'] + list(input())
l = len(n)
n = [int(x) for x in n]
for i in range(l):
	for j in range(i + 1, l):
		for k in range(j + 1, l):
			x = n[i] * 100 + n[j] * 10 + n[k]
			if x % 8 == 0:
				print('YES')
				print(x)
				exit(0)
print('NO')


from itertools import combinations
s = list(input())
p = list(combinations(s, 3)) + list(combinations(s, 1)) + list(combinations(s, 2))
for i in range(len(p)):
	p[i] = int(''.join(p[i]))
for i in range(len(p)):
	if p[i] % 8 == 0:
		print('YES')
		print(p[i])
		exit()
print('NO')


s = input()
x = list(map(int, [y for y in s]))
n = len(x)
dp = [''] * 8
dp[x[0] % 8] = str(x[0])
for i in range(1, n):
	nex = dp[:]
	for j in range(8):
		if j != 0 and dp[j] == '':
			continue
		tmp = j * 10 + x[i]
		nex[tmp % 8] = dp[j] + str(x[i])
	dp = nex
if dp[0] == '':
	print('NO')
else:
	print('YES')
	print(dp[0])


def sub(a, b):
	d = {}
	for l in range(len(b)):
		d[l] = b[l]
	for x in range(len(b)):
		if a and d[x] == a[0]:
			a = a[1:]
	if a == '':
		return True
	return False
n = input()
if '8' in n:
	print('YES', 8, sep='\n')
else:
	e = [str(8 * x) for x in range(126) if '8' not in str(8 * x)]
	for x in e:
		if sub(x, n):
			print('YES')
			print(x)
			break
	else:
		print('NO')


__author__ = 'victormion'

def function():
	for word in array:
		last = -1
		flag = True
		for i in range(0, len(word)):
			last = n.find(word[i], last + 1)
			if last == -1:
				flag = False
		if flag:
			return word
	return -1
n = input()
temp = 0
array = []
array.append(str(0))
while temp + 8 <= 999:
	temp += 8
	array.append(str(temp))
res = function()
if res == -1:
	print('NO')
else:
	print('YES')
	print(res)


a = list(map(int, list(input())))
n = len(a)
dp = [0 for i in range(n)]
flag = 0
ans = 0
for i in range(n):
	if a[i] == 0 or a[i] == 8:
		flag = 1
		ans = a[i]
		break
if flag == 0:
	for i in range(1, n):
		for j in range(i):
			if (a[j] * 10 + a[i]) % 8 == 0:
				ans = a[j] * 10 + a[i]
				flag = 1
				break
		if flag == 1:
			break
	if flag == 0:
		for i in range(2, n):
			for j in range(1, i):
				for k in range(j):
					if (a[k] * 100 + a[j] * 10 + a[i]) % 8 == 0:
						ans = a[k] * 100 + a[j] * 10 + a[i]
						flag = 1
						break
				if flag == 1:
					break
			if flag == 1:
				break
if flag == 1:
	print('YES')
	print(ans)
else:
	print('NO')


l = []
for i in range(1, 126):
	l.append(i * 8)
f = 0
s = input().strip()
if '0' in s:
	print('Yes')
	print(0)
else:
	for i in range(len(l)):
		n = l[i]
		div = ''
		for j in range(len(s) - 1, -1, -1):
			if int(s[j]) == n % 10:
				n //= 10
				div += s[j]
		if n == 0:
			f = 1
			break
	if f == 1:
		print('Yes')
		print(div[::-1])
	else:
		print('No')


n = input()

def solve(n):
	for i in range(len(n)):
		number = n[i]
		if int(number) % 8 == 0:
			return number
		for j in range(i + 1, len(n)):
			tmp = number + n[j]
			if int(tmp) % 8 == 0 or int(n[j]) % 8 == 0:
				return tmp if int(tmp) % 8 == 0 else n[j]
			for k in range(j + 1, len(n)):
				tmp2 = tmp + n[k]
				if int(tmp2) % 8 == 0:
					return tmp2
	return 'NO'
ans = str(solve(n))
if ans == 'NO':
	print('NO')
else:
	print('YES')
	print(ans)


import sys
input = sys.stdin.readline
from math import ceil, floor, factorial

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	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
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

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

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
s = input().strip()
s = '00' + s
n = len(s)
f = -1
for i in range(n - 2):
	if f != -1:
		break
	for j in range(i + 1, n - 1):
		if f != -1:
			break
		for k in range(j + 1, n):
			num = int(s[i] + s[j] + s[k])
			if num % 8 == 0:
				f = num
				break
if f == -1:
	print('NO')
else:
	print('YES')
	print(num)


def check(sub, s):
	j = 0
	for i in range(len(s)):
		if sub[j] == s[i]:
			j += 1
		if j == len(sub):
			break
	if j == len(sub):
		return True
	else:
		return False

def mult(s):
	for j in range(0, 1000, 8):
		if check(str(j), s):
			return int(j)
	return -1
n = input()
x = mult(n)
if x == -1:
	print('NO')
else:
	print('YES')
	print(x)


import sys
sys.setrecursionlimit(1000000)

def ei(s):
	if int(s) % 8 == 0:
		return s
	if len(s) == 1:
		return -1
	if ei(s[:-1]) != -1:
		return s[:-1]
	if ei(s[:-2] + s[-1]) != -1:
		return s[:-2] + s[-1]
	if len(s) > 2:
		if ei(s[:-3] + s[-2:]) != -1:
			return s[:-3] + s[-2:]
	return -1
s = input()
a = 0
s = '00' + s
for i in range(len(s)):
	for k in range(i):
		for j in range(k):
			if int(s[j] + s[k] + s[i]) % 8 == 0:
				print('YES')
				print(int(s[j] + s[k] + s[i]))
				a = 1
				break
		if a:
			break
	if a:
		break
else:
	print('NO')


s = input()
s1 = len(s)
flag = 0
if s.count('0') > 0:
	r = 0
	flag = 1
if flag == 0:
	for i in range(s1):
		r = int(s[i])
		if r % 8 == 0:
			flag = 1
			break
if flag == 0:
	for i in range(s1 - 1):
		for j in range(i + 1, s1):
			r = int(s[i] + s[j])
			if r % 8 == 0:
				flag = 1
				break
		if flag:
			break
if flag == 0:
	for i in range(s1 - 2):
		for j in range(i + 1, s1 - 1):
			for k in range(j + 1, s1):
				r = int(s[i] + s[j] + s[k])
				if r % 8 == 0:
					flag = 1
					break
			if flag:
				break
		if flag:
			break
if flag:
	print('YES')
	print(r)
else:
	print('NO')


def SEARCH(n, reg):
	n = str(n)
	reg = str(reg)
	for i in reg:
		if re.search(i, n):
			n = n[n.index(i) + 1:]
		else:
			return False
	return True
n = int(input())
import re
if not re.search('0|2|4|6|8', str(n)):
	print('NO')
else:
	check = False
	if re.search('0|8', str(n)):
		print('YES')
		print(re.search('0|8', str(n)).group(0))
		check = True
	if re.search('2', str(n)) and (not check):
		x = 32
		for i in range(2000):
			if SEARCH(n, x):
				print('YES')
				print(x)
				check = True
				break
			x += 40
	if re.search('4', str(n)) and (not check):
		x = 24
		for i in range(2000):
			if SEARCH(n, x):
				print('YES')
				print(x)
				check = True
				break
			x += 40
	if re.search('6', str(n)) and (not check):
		x = 16
		for i in range(2000):
			if SEARCH(n, x):
				print('YES')
				print(x)
				check = True
				break
			x += 40
	if not check:
		print('NO')


import sys, re, math
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from heapq import heappush, heappop, heapify, nlargest, nsmallest

def STR():
	return list(input())

def INT():
	return int(input())

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

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

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def sortListWithIndex(listOfTuples, idx):
	return sorted(listOfTuples, key=lambda x: x[idx])

def sortDictWithVal(passedDic):
	temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
	toret = {}
	for tup in temp:
		toret[tup[0]] = tup[1]
	return toret

def sortDictWithKey(passedDic):
	return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
s = input()
s += '  '
flag = 0
for i in range(len(s)):
	for j in range(i + 1, len(s)):
		for k in range(j + 1, len(s)):
			st = s[i] + s[j] + s[k]
			if len(st) != 0 and int(st) % 8 == 0:
				ans = int(st)
				flag = 1
				break
		if flag == 1:
			break
	if flag == 1:
		break
if flag == 0:
	print('NO')
else:
	print('YES')
	print(ans)


import itertools
C = list(map(int, input().strip()))
if 8 in C:
	print('YES')
	print(8)
elif 0 in C:
	print('YES')
	print(0)
else:
	combi = []
	for i in range(1, 4):
		tmp = [list(x) for x in itertools.combinations(C, i)]
		combi.extend(tmp)
	flag = True
	for tmp in combi:
		num = int(''.join(map(str, tmp)))
		if num % 8 == 0:
			print('YES')
			print(num)
			flag = False
			break
	if flag:
		print('NO')


n = input()
res = -1
for k in range(0, 1000, 8):
	temp = str(k)
	p1 = n.find(temp[0])
	p2 = -1
	p3 = -1
	if len(temp) > 1:
		p2 = n.find(temp[1], max(0, p1) + 1)
	if len(temp) > 2:
		p3 = n.find(temp[2], max(0, p2) + 1)
	if len(temp) == 1 and p1 != -1:
		res = n[p1]
		break
	if len(temp) == 2 and p1 != -1 and (p2 != -1):
		res = n[p1] + n[p2]
		break
	if len(temp) == 3 and p1 != -1 and (p2 != -1) and (p3 != -1):
		res = n[p1] + n[p2] + n[p3]
		break
if res != -1:
	print('YES')
	print(res)
else:
	print('NO')


n = str(input())
n = [i for i in n]
flag = False
for i in range(len(n)):
	if int(n[i]) % 8 == 0:
		flag = True
		ans = n[i]
		break
	for j in range(i + 1, len(n)):
		if int(n[i] + n[j]) % 8 == 0:
			flag = True
			ans = n[i] + n[j]
			break
		for k in range(j + 1, len(n)):
			if int(n[i] + n[j] + n[k]) % 8 == 0:
				flag = True
				ans = n[i] + n[j] + n[k]
				break
	if flag:
		break
if flag:
	print('YES')
	print(ans)
else:
	print('NO')


from itertools import combinations

def eight_divisibility(num, no_leading=False):
	if no_leading:
		comb = combinations(num, 1)
		for c in comb:
			cc = ''.join((i for i in c))
			N = int(cc)
			if N % 8 == 0:
				return cc
		comb = combinations(num, 2)
		for c in comb:
			cc = ''.join((i for i in c))
			N = int(cc)
			if N % 8 == 0:
				return cc
	comb = combinations(num, 3)
	for c in comb:
		cc = ''.join((i for i in c))
		N = int(cc)
		if N % 8 == 0:
			return cc
	return None

def answer(num=None):
	if num:
		print('YES')
		print(num)
	else:
		print('NO')
n = input()
while len(n) > 6:
	res = eight_divisibility(n[-5:])
	if res:
		n = n[:-5]
		n = n + res
		answer(n)
		exit(0)
	else:
		n = n[:-1]
res = eight_divisibility(n, no_leading=True)
answer(res)


n = list(map(int, list(input())))
found = False
sol = 0
L = len(n)
for i in range(L):
	if n[i] % 8 == 0:
		sol = n[i]
		found = True
if not found:
	for i in range(L):
		for j in range(i + 1, L):
			if (10 * n[i] + n[j]) % 8 == 0:
				sol = 10 * n[i] + n[j]
				found = True
if not found:
	for i in range(L):
		for j in range(i + 1, L):
			for k in range(j + 1, L):
				if (100 * n[i] + 10 * n[j] + n[k]) % 8 == 0:
					sol = 100 * n[i] + 10 * n[j] + n[k]
					found = True
if not found:
	print('NO')
else:
	print('YES')
	print(sol)


x = input()
for i in range(125):
	g = list(str(8 * i))
	for d in x:
		if d == g[0]:
			del g[0]
			if not g:
				print('YES')
				print(8 * i)
				break
	else:
		continue
	break
else:
	print('NO')


n = int(input())
r = ''
if n % 8 == 0:
	print('YES')
	print(n)
	exit()
else:
	n = str(n)
	if n.count('0') > 0:
		print('YES')
		print(0)
		exit()
	elif n.count('8') > 0:
		print('YES')
		print(8)
		exit()
	elif len(n) >= 2:
		for i in range(len(n)):
			for j in range(i + 1, len(n)):
				if i != j:
					r += n[i]
					r += n[j]
					if int(r) % 8 == 0:
						print('YES')
						print(r)
						exit()
					else:
						r = ''
	if len(n) > 2:
		for i in range(len(n)):
			for j in range(i + 1, len(n)):
				for k in range(j + 1, len(n)):
					if i != j and j != k and (i != k):
						r += n[i]
						r += n[j]
						r += n[k]
						if int(r) % 8 == 0:
							print('YES')
							print(r)
							exit()
						else:
							r = ''
print('NO')


s = list(map(int, input()))
if 0 in s:
	print('YES')
	print(0)
	exit(0)
if 8 in s:
	print('YES')
	print(8)
	exit(0)
for n in range(len(s)):
	for k in range(n + 1, len(s)):
		if s[k] % 2 == 0:
			nm = s[n] * 10 + s[k]
			if nm % 8 == 0:
				print('YES')
				print(nm)
				exit(0)
for n in range(len(s)):
	for k in range(n + 1, len(s)):
		for j in range(k + 1, len(s)):
			if s[j] % 2 == 0:
				nm = s[n] * 100 + s[k] * 10 + s[j]
				if nm % 8 == 0:
					print('YES')
					print(nm)
					exit(0)
print('NO')