A telephone number is a sequence of exactly $11$ digits such that its first digit is 8.

Vasya and Petya are playing a game. Initially they have a string $s$ of length $n$ ($n$ is odd) consisting of digits. Vasya makes the first move, then players alternate turns. In one move the player must choose a character and erase it from the current string. For example, if the current string 1121, after the player's move it may be 112, 111 or 121. The game ends when the length of string $s$ becomes 11. If the resulting string is a telephone number, Vasya wins, otherwise Petya wins.

You have to determine if Vasya has a winning strategy (that is, if Vasya can win the game no matter which characters Petya chooses during his moves).


-----Input-----

The first line contains one integer $n$ ($13 \le n < 10^5$, $n$ is odd) — the length of string $s$.

The second line contains the string $s$ ($|s| = n$) consisting only of decimal digits.


-----Output-----

If Vasya has a strategy that guarantees him victory, print YES.

Otherwise print NO.


-----Examples-----
Input
13
8380011223344

Output
YES

Input
15
807345619350641

Output
NO



-----Note-----

In the first example Vasya needs to erase the second character. Then Petya cannot erase a character from the remaining string 880011223344 so that it does not become a telephone number.

In the second example after Vasya's turn Petya can erase one character character 8. The resulting string can't be a telephone number, because there is no digit 8 at all.

Difficulty: EASY
Tags: Game theory

Implementation

Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
def main():
	n = int(input())
	string = str(input())
	moves = n - 11
	if moves % 2 != 0:
		petya = (moves - 1) // 2
	else:
		petya = moves // 2
	cnt = 0
	arr = []
	for i in range(n):
		if string[i] == '8':
			arr.append(i)
			cnt += 1
	if cnt <= petya:
		print('NO')
		return
	moves -= petya
	if arr[petya] - petya <= moves:
		print('YES')
	else:
		print('NO')
	return
main()


n = int(input())
s = input()
chance = (n - 11) // 2
if s.count('8') <= chance:
	print('NO')
else:
	count_8 = 0
	for i in range(n):
		if s[i] == '8':
			count_8 += 1
		if count_8 > chance:
			chance = i
			break
	if len(s[chance:]) >= 11:
		print('YES')
	else:
		print('NO')


n = int(input())
s = [*input()]
(a, b) = ([], [])
for i in range(n - 1, -1, -1):
	if s[i] == '8':
		a.append(i)
	else:
		b.append(i)
m = True
while len(a) + len(b) > 11:
	if not a or (m and b):
		b.pop()
	else:
		a.pop()
	m = not m
if a and (not b or (b and a[-1] < b[-1])):
	print('YES')
else:
	print('NO')


from sys import stdin

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

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

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

def si():
	return stdin.readline()
n = ii()
a = si()
x = a[:n - 10].count('8')
print('YES' if x > (n - 11) // 2 else 'NO')


n = int(input())
s = input()
res = 0
for i in range(n - 10):
	if s[i] == '8':
		res += 1
if res <= (n - 11) // 2:
	print('NO')
else:
	print('YES')


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
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')
n = int(input())
s = list(input())
s = [int(s[i]) for i in range(n)]
n -= 11
a2 = n // 2
a1 = n - a2
if s.count(8) <= a2:
	print('NO')
else:
	for i in range(n):
		if s[i] == 8:
			s[i] = -1
			a2 -= 1
		if a2 == 0:
			break
	for i in range(n):
		if s[i] != 8 and s[i] != -1:
			s[i] = -1
			a1 -= 1
		if a1 == 0:
			break
	ch = -1
	for i in s:
		if i != -1:
			ch = i
			break
	if ch == 8:
		print('YES')
	else:
		print('NO')


n = int(input())
s = input()
s = list(s)
c = s.count('8')
n1 = (n - 11) // 2
n2 = n1
if c < n1:
	print('NO')
else:
	j = 0
	v = 0
	p = 0
	j1 = 0
	while j < n - 11 and (v < n1 or p < n1):
		if v < n1 and s[j1] != '8':
			del s[j1]
			v += 1
		elif p < n2 and s[j1] == '8':
			del s[j1]
			p += 1
		else:
			j1 += 1
		j += 1
	if s[0] == '8':
		print('YES')
	else:
		print('NO')


n = int(input())
s = input()
t = s[:-10]
cnt = t.count('8')
if len(t) - cnt > cnt:
	print('NO')
else:
	print('YES')


n = int(input())
s = input()
if n < 11:
	print('NO')
elif n == 11:
	if s[0] == '8':
		print('YES')
	else:
		print('NO')
elif s[:-10].count('8') <= (n - 11) // 2:
	print('NO')
else:
	print('YES')


n = int(input())
s = input()
enemy = (n - 11) // 2
move = n - 11 - enemy
i = 0
eight = 0
suc = False
while True:
	if s[i] == '8':
		eight += 1
	else:
		move -= 1
	i += 1
	if eight > enemy:
		suc = True
		break
	if move < 0 or i >= n:
		break
if suc:
	print('YES')
else:
	print('NO')


a = int(input())
s = input()
moves = a - 11
x = moves // 2
y = moves // 2
pos = []
for i in range(len(s)):
	if s[i] == '8':
		pos.append(i)
if len(pos) <= y:
	print('NO')
	exit()
else:
	index = pos[y]
	left = index - y
	if left <= x:
		print('YES')
	else:
		print('NO')


n = int(input())
s = input()
s = list(s)
cnt = 0
c = []
for i in range(n):
	if s[i] == '8':
		cnt += 1
		c.append(i)
z = (n - 11) // 2
if cnt > z and c[len(c) - (cnt - z)] <= n - 11:
	print('YES')
else:
	print('NO')


n = int(input())
s = input()
c = s.count('8')
cnt = 0
pos = 0
if c <= int((n - 11) / 2):
	print('NO')
else:
	for i in range(n):
		if s[i] == '8':
			cnt += 1
		if cnt == int((n - 11) / 2) + 1:
			pos = i
			break
	if pos <= n - 11:
		print('YES')
	else:
		print('NO')


from collections import Counter
n = int(input())
s = str(input())
pm = (n - 11) // 2
c = Counter(s)
if pm >= c['8']:
	print('NO')
else:
	x = c['8'] - pm
	i = n - 1
	while i >= 0 and x > 0:
		if s[i] == '8':
			x -= 1
		i -= 1
	i += 1
	if pm >= i - pm:
		print('YES')
	else:
		print('NO')


import sys, collections
n = int(sys.stdin.readline())
arr = list(map(int, sys.stdin.readline().rstrip()))
v = 0
p = 0
for i in range(n):
	if v == (n - 11) // 2:
		break
	if arr[i] != 8:
		arr[i] = -1
		v += 1
for i in range(n):
	if p == (n - 11) // 2:
		break
	if arr[i] == 8:
		arr[i] = -1
		p += 1
for i in range(n):
	if arr[i] == -1:
		continue
	elif arr[i] == 8:
		print('YES')
		break
	else:
		print('NO')
		break


n = int(input())
s = input()
count = 0
last = -1
steps = n - 11
petya = int(steps / 2)
vaysa = steps - petya
found = False
for (indx, symbol) in enumerate(s):
	if symbol == '8':
		t = vaysa - indx + count
		if t >= 0:
			if petya <= count:
				found = True
				break
		else:
			break
		count += 1
if not found:
	print('NO')
else:
	print('YES')


n = int(input())
s = input()
c8 = s.count('8')
chances = int((n - 11) / 2)
if c8 <= chances:
	print('NO')
else:
	j = 0
	for i in range(n):
		if s[i] == '8':
			if j == chances:
				j = i
				break
			else:
				j = j + 1
	if j <= 2 * chances:
		print('YES')
	else:
		print('NO')


n = int(input())
s = str(input())
counter = 1
for word in s[:n - 10]:
	if word == '8':
		counter += 1
	else:
		counter -= 1
if counter > 0:
	print('YES')
else:
	print('NO')


t = int(input())
s = input()
s1 = s[0:t - 11 + 1]
s2 = s1.count('8')
if s2 >= len(s1) // 2 + 1:
	print('YES')
else:
	print('NO')


import os
import sys
from io import BytesIO, IOBase
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')
import math

def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans
for _ in range(1):
	n = int(input())
	string = input()
	v = (n - 11) // 2
	p = v
	ans = -1
	for i in range(n):
		if int(string[i]) == 8:
			if v > 0:
				v -= 1
			else:
				ans = int(string[i])
				break
		elif p > 0:
			p -= 1
		else:
			ans = int(string[i])
			break
	print('YNEOS'[ans != 8::2])


import sys
n = int(input())
s = input()
s1 = s[0:n - 10]
v = 0
for i in range(n - 10):
	if s1[i] == '8':
		v += 1
n1 = (n - 9) // 2
if v >= n1:
	print('YES')
else:
	print('NO')


def ip():
	return int(input())

def sip():
	return input()

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

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

def matip(n, m):
	lst = []
	for i in range(n):
		arr = lip()
		lst.append(arr)
	return lst
n = ip()
s = sip()
count = 0
for i in range(n - 10):
	if s[i] == '8':
		count += 1
if count > (n - 11) // 2:
	print('YES')
else:
	print('NO')


from sys import stdin, stdout
from collections import Counter

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

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

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

def op(ans):
	return stdout.write(str(ans) + '\n')
from math import ceil
n = ip()
s = input()
s = [i for i in s]
total_moves_petya = (n - 11) // 2
total_moves_vesya = (n - 11) // 2
for i in range(n):
	if s[i] == '8' and total_moves_petya > 0:
		s[i] = -1
		total_moves_petya -= 1
	if total_moves_petya <= 0:
		break
for i in range(n):
	if s[i] != -1 and s[i] != '8':
		s[i] = -1
		total_moves_vesya -= 1
	if total_moves_vesya <= 0:
		break
c = 0
for i in range(n):
	if s[i] != -1 and s[i] == '8':
		print('YES')
		c += 1
		break
	if s[i] != -1 and s[i] != '8':
		break
if c == 0:
	print('NO')


n = int(input())
t = int((n - 11) / 2)
s = list(input())
c = 0
for i in range(0, 2 * t + 1):
	if s[i] == '8':
		c += 1
if c >= t + 1:
	print('YES')
else:
	print('NO')


t = int(input())
b = input()
p = 0
for j in range(t):
	if t - j >= 11 and b[j] == '8':
		p += 1
if p > (t - 11) // 2:
	print('YES')
else:
	print('NO')


n = int(input())
s = input()
d = []
for i in range(n):
	if s[i] == '8':
		d.append(i)
if n - 11 >= 2 * len(d):
	print('NO')
else:
	now = d[(n - 11) // 2]
	if now > n - 11:
		print('NO')
	else:
		print('YES')


def check():
	n = int(input())
	s = input()
	c8 = 0
	last8 = 0
	turns = (n - 11) / 2
	ct = turns
	for i in range(n):
		if s[i] == '8':
			c8 += 1
			if ct == 0 and last8 == 0:
				last8 = i
			ct -= 1
	if c8 < turns + 1:
		print('NO')
		return
	left8 = last8
	left8 -= turns
	if left8 > turns:
		print('NO')
		return
	print('YES')
	return
check()


n = int(input())
p = (n - 11) / 2
s = input()
o = 0
(e, ne) = (0, 0)
for x in s:
	if x == '8':
		e += 1
	else:
		ne += 1
	if e == p + 1:
		if ne <= p:
			print('YES')
		else:
			print('NO')
		o = 1
		break
if o == 0:
	print('NO')


n = int(input())
string = str(input())
count = 0
first = 0
for i in range(n - 10):
	if string[i] == '8':
		count += 1
if count > (n - 11) / 2:
	print('YES')
else:
	print('NO')


n = int(input())
u = list(map(int, list(input())))
a8 = 0
ok = False
a1 = 0
i8 = []
v = (n - 11 - 1) // 2 + 1
p = n - 11 - v
for i in range(n):
	if u[i] == 8:
		a8 += 1
		i8.append(i)
	else:
		a1 += 1
	if a8 == p + 1:
		ok = True
		break
if not ok:
	print('NO')
	exit()
if a1 <= v:
	print('YES')
else:
	print('NO')


n = int(input())
a = list(input())
todel = (n - 11) // 2
count = 0
pos = -1
for i in range(n):
	if a[i] == '8':
		count += 1
	if count == todel + 1 and pos == -1:
		pos = i
if pos == -1 or pos > todel * 2:
	print('NO')
else:
	print('YES')


n = int(input())
s = input()
nine_count = s[:-10].count('8')
no_nine_count = n - 10 - nine_count
vasya_hods = (n - 11) // 2 + (n - 11) % 2
petya_hods = (n - 11) // 2
if petya_hods < nine_count:
	print('YES')
else:
	print('NO')


num1 = int(input())
str1 = input()
ans = num1 - 10
c = 0
c1 = 0
for i in range(ans):
	if str1[i] == '8':
		c += 1
	else:
		c1 += 1
if c >= c1:
	print('YES')
else:
	print('NO')


n = int(input())
s = input()
f = n - 11
f1 = f // 2
for i in range(f + 1):
	if s[i] != '8':
		f1 -= 1
if f1 >= 0:
	print('YES')
else:
	print('NO')


n = int(input())
s = input()
l = list(map(lambda x: True if x == '8' else False, s))
l = l[:n - 10]
if l.count(True) > (n - 11) / 2:
	print('YES')
else:
	print('NO')


n = int(input())
s = input()[:n - 10]
r = s.count('8')
if r > (n - 10) / 2:
	print('YES')
else:
	print('NO')


n = int(input())
l = list(map(int, list(input())))
diff = n - 11
if l[0:diff + 1].count(8) > diff // 2:
	print('YES')
else:
	print('NO')


def howmanyeights(s):
	return len([char for char in s if char == '8'])
n = int(input())
s = input()
if howmanyeights(s[:-10]) > (n - 10) // 2:
	print('YES')
else:
	print('NO')


n = int(input())
p = (n - 11) // 2
s = input()
print('YES' if s[:n - 11 + 1].count('8') > p else 'NO')


n = int(input())
s = input()
if len(s) == 11 and s[0] == '8':
	print('YES')
	exit(0)
moves = n - 11
c = s.count('8')
if c <= moves // 2:
	print('NO')
else:
	x = moves // 2
	sm = 0
	for i in range(n):
		if s[i] == '8':
			x -= 1
		else:
			sm += 1
		if x == -1:
			break
	if sm > moves // 2:
		print('NO')
	else:
		print('YES')


n = int(input())
num = input()
if num[0:-10].count('8') <= (n - 11) // 2:
	print('NO')
else:
	print('YES')


def who_wins(s, n):
	total_moves = n - 11
	p_moves = total_moves // 2
	eights = [0] * n
	for i in range(n):
		if s[i] == '8':
			eights[i] = 1
	ctr = 0
	for i in range(n):
		if s[i] == '8':
			eights[i] = -1
			ctr += 1
		if ctr == p_moves:
			break
	ctr = 0
	for i in range(n):
		if s[i] != '8':
			eights[i] = -1
			ctr += 1
		if ctr == p_moves:
			break
	for i in range(n):
		if eights[i] == -1:
			continue
		elif eights[i] == 1:
			return 'YES'
		else:
			return 'NO'
N = int(input())
S = input()
print('%s' % who_wins(S, N))


n = int(input())
s = str(input())
d = n - 11
count = 0
for i in range(d + 1):
	h = int(s[i])
	if h == 8:
		count += 1
minus = d / 2
if minus + 1 > count:
	print('NO')
else:
	print('YES')


n = int(input())
s = input()
if s[0:-10].count('8') <= (n - 11) / 2:
	print('No')
else:
	print('Yes')


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt, pi, cos, sin, ceil, log2
from bisect import bisect_right, bisect_left
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

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

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)

def sumDigits(no):
	return 0 if no == 0 else int(no % 10) + sumDigits(int(no / 10))
MOD = 1000000007
PMOD = 998244353
N = 10 ** 9 + 7
LOGN = 30
T = 1
for _ in range(T):
	n = int(stdin.readline())
	a = list(stdin.readline().strip('\n'))
	n8 = 0
	ix = []
	for i in range(n):
		if a[i] == '8':
			n8 += 1
			ix.append(i)
	n -= 11
	if n8 > n // 2:
		if ix[n // 2] <= n:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


n = int(input())
string = input()
turns = n - 11
udscrs = string[:turns]
eights_in = udscrs.count('8')
if eights_in == turns // 2 and string[turns] == '8':
	print('YES')
elif eights_in > turns // 2:
	print('YES')
else:
	print('NO')


from sys import setcheckinterval, setrecursionlimit, stdout
setcheckinterval(1000)
setrecursionlimit(10 ** 6)
iin = lambda : int(input())
lin = lambda : list(map(int, input().split()))
n = iin()
a = input()
ch = 0
ans = []
for i in range(n):
	if a[i] == '8':
		ans.append(i - ch)
		ch += 1
ans1 = (n - 11) // 2 + 1
ch2 = 0
for i in ans:
	if i < ans1:
		ch2 += 1
if ch2 >= ans1:
	print('YES')
else:
	print('NO')


def convert(list):
	s = [str(i) for i in list]
	res = str(''.join(s))
	return res
n = int(input())
b = list(str(input()))
l = int((n - 11) / 2)
r = int((n - 11) / 2)
for i in range(len(b)):
	if b[i] != '8':
		b[i] = 'A'
		l = l - 1
	if l == 0:
		break
for i in range(len(b)):
	if b[i] == '8':
		b[i] = 'A'
		r = r - 1
	if r == 0:
		break
s = convert(b)
s = s.replace('A', '')
if s[0] == '8':
	print('YES')
else:
	print('NO')


n = int(input())
s = input()
hati = 0
for i in range(n - 11 + 1):
	if s[i] == '8':
		hati += 1
if hati >= (n - 9) // 2:
	print('YES')
else:
	print('NO')


n = int(input())
s = input()

def solve():
	x = y = (n - 11) / 2
	for c in s:
		if c == '8':
			x -= 1
		else:
			y -= 1
		if x < 0:
			print('YES')
			return
		if y < 0:
			print('NO')
			return
solve()


n = int(input())
string = input()
diff = n - 11
no = diff // 2
count = 0
j = 0
idx = -1
for i in string:
	if i == '8':
		if count < no:
			count = count + 1
		else:
			idx = j
			break
	j = j + 1
if idx == -1:
	print('NO')
else:
	temp = idx - no
	te = diff - no
	if temp <= te:
		print('YES')
	else:
		print('NO')


n = int(input())
s = input()
k = n - 11
z = 0
for i in range(len(s)):
	if s[i] == '8':
		z += 1
	if z == k // 2 + 1:
		if i <= k:
			print('YES')
		else:
			print('NO')
		break
else:
	print('NO')


import math
n = int(input())
s = input()
cnt = s[:n - 10].count('8')
if cnt == 1 and n > 11:
	print('NO')
elif n - 10 < 2 * cnt:
	print('YES')
else:
	print('NO')


n = int(input())
arr = input()
arr = list(arr)
index = n - 11
num = arr[:index + 1].count('8')
if num - 1 >= index // 2:
	print('YES')
else:
	print('NO')


N = int(input())
s = input()
s = s[:N - 10]
cnt = 0
for i in s:
	if i == '8':
		cnt += 1
if cnt >= (N - 9) // 2:
	print('YES')
else:
	print('NO')


def solve():
	n = int(input())
	s = list(input())
	a = []
	(i, cnt) = (0, 0)
	while i < n:
		if cnt >= n - 11 >> 1:
			break
		if s[i] != '8':
			cnt += 1
		else:
			a.append('8')
		i += 1
	s = a + s[i:]
	a = []
	(i, cnt) = (0, 0)
	while i < len(s):
		if cnt >= n - 11 >> 1:
			break
		if s[i] == '8':
			cnt += 1
		else:
			a.append(s[i])
		i += 1
	a += s[i:]
	if a[0] == '8':
		print('YES')
	else:
		print('NO')
solve()


n = int(input())
s = input()
turns = (n - 11) // 2
eight = s.count('8')
if eight <= turns:
	print('NO')
else:
	c = 0
	k = 0
	i = 0
	while c < turns + 1 and i < n:
		if s[i] == '8':
			c += 1
		else:
			k += 1
		i += 1
	if k <= turns:
		print('YES')
	else:
		print('NO')


from collections import Counter as C, defaultdict as D, deque as Q
from operator import itemgetter as I
from itertools import product as P
from bisect import bisect_left as BL, bisect_right as BR, insort as INSORT
from heapq import heappush as HPUSH, heappop as HPOP
from math import floor as MF, ceil as MC, gcd as MG, factorial as F, sqrt as SQRT, inf as INFINITY, log as LOG
from sys import stdin, stdout
INPUT = stdin.readline
PRINT = stdout.write
L = list
M = map

def player1():
	print('')

def player2():
	print('')

def yes():
	PRINT('YES\n')

def no():
	PRINT('NO\n')

def isPrime(n):
	for i in range(2, MC(SQRT(n)) + 1):
		if n % i == 0:
			return False
	return True

def factors(x):
	ans = []
	for i in range(1, MC(SQRT(x)) + 1):
		if x % i == 0:
			ans.append(i)
			if x % (x // i) == 0:
				ans.append(x // i)
	return ans

def checkPath(source, destination, g):
	visited = [0] * 101
	q = Q()
	q.append(source)
	visited[source] = 1
	while q:
		node = q.popleft()
		if node == destination:
			return 1
		for v in g[node]:
			if not visited[v]:
				q.append(v)
				visited[v] = 1
	return 0

def main():
	n = int(INPUT())
	s = INPUT()
	round = n - 11
	if s[:round].count('8') > round // 2 or s[:round + 1].count('8') > round // 2:
		yes()
	else:
		no()
main()


import math
import bisect
import heapq
from collections import defaultdict

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

def mulinv(b, n):
	(g, x, _) = egcd(b, n)
	if g == 1:
		return x % n
primes = []

def isprime(n):
	for d in range(2, int(math.sqrt(n)) + 1):
		if n % d == 0:
			return False
	return True

def argsort(ls):
	return sorted(range(len(ls)), key=ls.__getitem__)

def f(p=0):
	if p == 1:
		return map(int, input().split())
	elif p == 2:
		return list(map(int, input().split()))
	else:
		return int(input())
n = f()
s = input()
k = n - 11
cl = []
a = k // 2
if k % 2 == 1:
	a += 1
b = k // 2
count = 0
pos = 0
for i in range(n):
	if s[i] == '8':
		count += 1
	else:
		pos += 1
	if a < pos:
		break
if count > b:
	print('YES')
else:
	print('NO')


n = int(input())
s = input()
s = list(s)
d = []
uhoy = n - 11
for i in range(n):
	if s[i] == '8':
		d.append(i)
pi = 0
pj = 0
for i in range(uhoy):
	if i % 2 == 0:
		while pi < n:
			if s[pi] != '8' and s[pi] != -1:
				s[pi] = -1
				pi += 1
				break
			pi += 1
	else:
		while pj < n:
			if s[pj] == '8':
				s[pj] = -1
				pj += 1
				break
			pj += 1
flag = 0
for i in range(n):
	if s[i] == -1:
		kmg = 0
	elif s[i] == '8':
		break
	else:
		flag = 1
		break
if flag == 0:
	print('YES')
else:
	print('NO')


n = int(input())
st = str(input())
c = 0
for i in st[:len(st) - 10]:
	if i == '8':
		c += 1
if c < (len(st) - 10) // 2 + 1:
	print('NO')
else:
	print('YES')


n = int(input())
s = input()
x = s[:n - 11].count('8')
if x < (n - 11) // 2:
	print('NO')
elif x > (n - 11) // 2:
	print('YES')
elif s[n - 11] == '8':
	print('YES')
else:
	print('NO')


n = int(input())
string = input()
No8 = 0
for i in range(n - 10):
	if string[i] == '8':
		No8 += 1
NoMoves = (n - 11) // 2
if NoMoves >= No8:
	print('NO')
else:
	print('YES')


import sys
import math as mt
import bisect
t = 1
for _ in range(t):
	n = int(input())
	s = input()
	l = []
	x = (n - 11) // 2
	y = x
	ch = 0
	for i in range(n):
		if s[i] == '8':
			if x == 0:
				if i - y <= y:
					ch = 1
			x -= 1
	if ch == 1:
		print('YES')
	else:
		print('NO')


from collections import Counter
_DEBUG = True

def solve(n, s):
	c = Counter(s)
	turn_count = n - 12
	if c['8'] < turn_count // 2:
		return 'NO'
	v_count = 0
	eight_count = 0
	for i in range(n):
		if s[i] != '8':
			v_count += 1
			if v_count >= (turn_count + 1) // 2:
				j = i + 1
				while j < n and s[j] == '8':
					eight_count += 1
					j += 1
				break
		else:
			eight_count += 1
	if eight_count >= turn_count // 2 + 2:
		return 'YES'
	return 'NO'
assert solve(13, '8380011223344') == 'YES'
assert solve(15, '807345619350641') == 'NO'
assert solve(29, '88811188118181818118111111111') == 'NO'
assert solve(19, '8181818181111111111') == 'YES'
assert solve(13, '9999999998888') == 'NO'
assert solve(13, '0000008888888') == 'NO'
assert solve(13, '2480011223348') == 'NO'
assert solve(17, '87879887989788999') == 'YES'
n = int(input())
s = input()
solution = solve(n, s)
print(solution)


n = int(input())
s = input()
part = s[:n - 10]
t = (n - 11) // 2
if t >= part.count('8'):
	print('NO')
else:
	print('YES')


n = int(input())
l = list(input())
cnt = (n - 11) // 2
al = n
ei = 0
for i in range(n):
	if cnt >= 1 and l[i] != '8':
		cnt -= 1
		continue
	if cnt == 0 and l[i] != '8':
		al = i
		break
	if l[i] == '8':
		ei += 1
if ei > (n - 11) // 2:
	print('YES')
else:
	print('NO')


import sys
from heapq import heappush, heappop, heapify
sys.setrecursionlimit(int(10000000.0))

def main():
	n = int(input().strip())
	s = input().strip()
	V = [i for i in range(n) if s[i] != '8']
	P = [i for i in range(n) if s[i] == '8']
	heapify(V)
	heapify(P)
	while len(V) + len(P) > 11 and len(V) * len(P) > 0:
		heappop(V)
		heappop(P)
	yes = len(V) == 0 or (len(V) * len(P) > 0 and P[0] < V[0])
	print('YES' if yes else 'NO')
	return
while 1:
	try:
		main()
	except EOFError:
		break


n = int(input())
s = input()
subS = s[0:-10]
min8s = subS.count('8')
if min8s > n - 10 - min8s:
	print('YES')
else:
	print('NO')


n = int(input())
s = input()
token = (n - 11) // 2
cnt = 0
for i in range(n):
	if s[i] == '8':
		token -= 1
	elif token >= 0:
		cnt += 1
if (n - 10) / 2 >= cnt:
	print('YES')
else:
	print('NO')


n = int(input())
c = list(map(int, list(input())))
k = 0
for i in c[:n - 10]:
	if i == 8:
		k += 1
if k > (n - 11) // 2:
	print('YES')
else:
	print('NO')


n = int(input())
s = input()
c = 0
for i in range(0, n - 10):
	if s[i] == '8':
		c += 1
	else:
		c -= 1
if c > 0:
	print('YES')
else:
	print('NO')


import heapq
import queue
from collections import *
import math
import sys

def sieve(n):
	primes = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if primes[p] == True:
			for i in range(p * p, n + 1, p):
				primes[i] = False
		p += 1
	return primes
n = int(input())
s = str(input())
moves_p = (n - 11) // 2
moves_v = int(math.ceil((n - 11) / 2))
eis = s.count('8')
fei = s.find('8')
if fei < 0:
	print('NO')
elif moves_p >= eis:
	print('NO')
else:
	for i in range(moves_p):
		fei = s.find('8', fei + 1)
		moves_v += 1
	if fei < 0:
		print('NO')
	elif moves_v < fei:
		print('NO')
	else:
		print('YES')


n = int(input())
a = input()
count = 0
bount = 0
for i in range(n - 10):
	if a[i] == '8':
		count += 1
	else:
		bount += 1
if count >= bount:
	print('YES')
else:
	print('NO')


length = int(input())
temp = input()
res = ''
count1 = (length - 11) // 2
count2 = count1
for i in temp:
	if i == '8':
		if count1 > 0:
			count1 -= 1
		else:
			res += i
	elif count2 > 0:
		count2 -= 1
	else:
		res += i
if res[0] == '8':
	print('YES')
else:
	print('NO')


import math
n = int(input())
s = input()
s = list(map(int, list(s)))
f = (len(s) - 11) // 2
t = s[:n - 10]
x = t.count(8)
if f < x:
	print('YES')
else:
	print('NO')


i = int(input())
a = input()
chance = (i - 11) // 2
num_in_between = 0
count_8 = [i for (i, char) in enumerate(a) if char == '8']
if len(count_8) == 0 or len(count_8) <= chance:
	print('NO')
else:
	y = count_8[chance] - chance
	if y <= chance:
		print('YES')
	else:
		print('NO')


num = (int(input()) - 11) // 2
word = input()[:-10]
if word.count('8') > num:
	print('YES')
else:
	print('NO')


n = int(input())
s = str(input())
k = n - 11
r = k // 2
l = s[0:n - 11]
p = l.count('8')
if p > k // 2:
	print('yes')
elif p == k // 2 and s[-11] == '8':
	print('yes')
else:
	print('no')


n = int(input())
s = input()
k = n - 10
t = s[:-10]
ans = 'YES' if t.count('8') > k // 2 else 'NO'
print(ans)


n = int(input())
x = input()
r = (n - 11) // 2
p = x[:2 * r + 1]
if p.count('8') >= r + 1:
	print('YES')
else:
	print('NO')


n = int(input())
s = list(input())
steps = (n - 11) // 2 + 1
counter = 0
for item in s:
	if item == '8':
		steps -= 1
	else:
		counter += 1
	if steps == 0:
		break
if counter <= (n - 11) // 2:
	print('YES')
else:
	print('NO')


n = int(input())
s = input().rstrip()
p = (n - 11) // 2
v = n - p - 11
eights = s.count('8')
if eights < p:
	print('NO')
else:
	for c in s:
		if c == '8':
			if p > 0:
				p -= 1
			else:
				print('YES')
				break
		elif c != '8':
			if v > 0:
				v -= 1
			else:
				print('NO')
				break


n = int(input())
s = input().rstrip()
x = list(s)
l = []
if len(list(set(x))) == 1:
	if x[0] == '8':
		print('YES')
	else:
		print('NO')
elif '8' not in x:
	print('NO')
else:
	for i in range(0, len(x)):
		if x[i] == '8':
			l.append(i)
	t = len(x) - 11
	q = []
	w = []
	for j in range(0, int(l[0])):
		q.append(j)
	for i in range(0, len(l) - 1):
		A = int(l[i])
		B = int(l[i + 1])
		for j in range(A + 1, B):
			q.append(j)
	U = 0
	for j in range(l[len(l) - 1] + 1, n):
		q.append(j)
	for i in range(0, t):
		if i % 2 == 0:
			if len(l) == 0:
				U = 1
				break
			else:
				del l[0]
		elif len(q) != 0:
			del q[0]
	if U == 1 or len(l) == 0:
		print('NO')
	elif len(q) == 0:
		print('YES')
	elif l[0] < q[0]:
		print('YES')
	else:
		print('NO')


quan = int(input())
pal = input()
c8 = 0
cn = 0
for i in range(quan - 10):
	if pal[i] == '8':
		c8 += 1
	else:
		cn += 1
if cn - c8 >= 1:
	print('NO')
else:
	print('YES')


import math
n = int(input())
s = input()
left = n - 11
cnt = s.count('8')
if cnt <= int(left / 2):
	print('NO')
else:
	pt = int(left / 2) + 1
	(i, j) = (0, 0)
	while i < n:
		if s[i] == '8':
			j += 1
			if j == pt:
				break
		i += 1
	(j, cnt) = (0, 0)
	while j < i:
		if s[j] != '8':
			cnt += 1
		j += 1
	if int(math.ceil(left / 2)) >= cnt:
		print('YES')
	else:
		print('NO')


n = int(input())
st = input()
z = (n - 11) // 2
ct = 0
for j in range(n - 10):
	if st[j] == '8':
		ct += 1
if ct >= z + 1:
	print('YES')
else:
	print('NO')


x = int(input())
y = list(map(int, list(input())))
vas = (x - 10) // 2
pet = (x - 11) // 2
k = []
for i in range(x):
	if y[i] == 8:
		k.append(i)
		if len(k) == pet + 1:
			break
try:
	if pet == 0 and k[0] == 0:
		print('YES')
	elif k[pet] - pet > (x - 10) // 2 or len(k) <= pet:
		print('NO')
	else:
		print('YES')
except Exception:
	print('NO')


n = int(input())
s = input()
k = (n - 11) // 2
t = k
if s.count('8') <= k:
	print('NO')
else:
	p = -1
	for i in range(n):
		if t > 0:
			if s[i] == '8':
				t -= 1
		elif s[i] == '8':
			p = i
			break
	if p + 10 >= n:
		print('NO')
	else:
		print('YES')


def solve(s):
	test = (len(s) - 11) // 2
	if s.count('8') <= test:
		return False
	cnt = cnt2 = 0
	for x in s:
		if x == '8':
			cnt += 1
		else:
			cnt2 += 1
		if cnt > test:
			break
	return cnt2 <= test
_ = input()
s = input()
if solve(s):
	print('YES')
else:
	print('NO')


n = int(input().strip())
s = input().strip()
c8 = 0
for i in s:
	if i == '8':
		c8 += 1
res = 0
if (n - 11) // 2 >= c8:
	res = 1
else:
	is_present = [True] * n
	chance = (n - 11) // 2
	for i in range(n):
		if chance == 0:
			break
		elif s[i] == '8':
			chance -= 1
			is_present[i] = False
	chance = (n - 11) // 2
	for i in range(n):
		if chance == 0:
			break
		elif s[i] != '8':
			chance -= 1
			is_present[i] = False
	if chance > 0:
		res = 0
	else:
		for i in range(n):
			if is_present[i]:
				if s[i] == '8':
					res = 0
				else:
					res = 1
				break
if res == 0:
	print('YES')
else:
	print('NO')


N = int(input())
S = input()
turns = (N - 11) // 2
cnt = 0
for i in range(N - 10):
	if S[i] == '8':
		cnt += 1
if cnt >= turns + 1:
	print('YES')
else:
	print('NO')


n = int(input())
s = str(input())
cnt1 = (n - 11) // 2
cnt2 = (n - 11) // 2
res = []
for i in range(n):
	if s[i] != '8':
		if cnt1:
			cnt1 -= 1
		else:
			res.append(s[i])
	elif cnt2:
		cnt2 -= 1
	else:
		res.append(s[i])
if res[0] == '8':
	print('YES')
else:
	print('NO')


from sys import stdin, stdout
from itertools import combinations
from collections import defaultdict

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

def stringListIn():
	return [x for x in stdin.readline().split()]

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

def stringIn():
	return stdin.readline().strip()
n = intIn()
s = stringIn()
li = list(s)
flag = False
ch = (n - 11) // 2
ch2 = ch
pos = []
cnt = s.count('8')
for i in range(n):
	if s[i] == '8':
		pos.append(i)
		if ch > 0:
			li[i] = '-1'
			ch -= 1
			cnt -= 1
	if ch == 0:
		break
li2 = [x for x in li if x != '-1']
if li2[0] == '8':
	flag = True
else:
	c = 0
	for i in range(len(li2)):
		if li2[i] != '8':
			c += 1
		else:
			if c <= ch2:
				if cnt > 0:
					flag = True
				else:
					flag = False
			else:
				flag = False
			c = 0
			break
if flag:
	print('YES')
else:
	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 = int(input())
	s = input()
	moves = n - 11
	c8 = 0
	for i in range(moves):
		if s[i] == '8':
			c8 += 1
	if c8 > moves // 2:
		print('YES')
	elif c8 == moves // 2 and s[moves] == '8':
		print('YES')
	else:
		print('NO')
main()


n = int(input())
a = list(input())
t = a.count('8')
k = (n - 11) // 2
if t <= k:
	print('NO')
else:
	f = 0
	for i in range(len(a)):
		if a[i] == '8':
			if f != k:
				f += 1
			else:
				f = i
				break
	if f > 2 * k:
		print('NO')
	else:
		print('YES')


import sys

def game(l, s):
	c = s[:l - 10].count('8')
	t = (l - 11) / 2
	if t < c:
		print('YES')
	else:
		print('NO')
l = int(input())
s = input()
game(l, s)


import sys
input = sys.stdin.readline
n = int(input())
l = input()
a = n - 11
if l[:a + 1].count('8') > a // 2:
	print('YES')
else:
	print('NO')


l = int(input())
s = input()
eg = 0
n = l - 11
for i in range(n + 1):
	if s[i] == '8':
		eg += 1
if eg > n // 2:
	print('YES')
else:
	print('NO')


from sys import stdin, stdout
import math
from copy import deepcopy
from collections import defaultdict
import heapq

def find_eight(arr):
	eight = []
	for i in range(len(arr)):
		if arr[i] == 8:
			eight.append(i)
	return eight

def check(arr, removed):
	new = []
	for i in range(len(arr)):
		if removed[i] == 0:
			new.append(arr[i])
	if len(new) == 11 and new[0] == 8:
		return True
	else:
		return False
n = int(stdin.readline().strip())
arr = list(stdin.readline().strip())
arr = list(map(int, arr))
eight = find_eight(arr)
if len(eight) > (n - 11) // 2:
	removed = [0] * len(arr)
	v = 0
	p = 0
	r_count = 0
	while r_count < len(arr) - 11:
		while v < len(arr) and (arr[v] == 8 or removed[v] == 1):
			v += 1
		else:
			if v < len(arr):
				removed[v] = 1
				v += 1
				r_count += 1
			else:
				pass
		while p < len(eight) and removed[eight[p]] == 1:
			p += 1
		else:
			if p < len(eight):
				removed[eight[p]] = 1
				p += 1
				r_count += 1
			else:
				pass
	if check(arr, removed):
		print('YES')
	else:
		print('NO')
else:
	print('NO')


n = int(input())
s = list(input())
if s[0:n - 10].count('8') > (n - 10) // 2:
	print('YES')
else:
	print('NO')


num = int(input())
s = input()
s = [i for i in s]
s = [1 if i == '8' else 0 for i in s]
bon = 0
if num % 2 == 0:
	bon = 1
vas = (num - 11) // 2 + bon
petr = (num - 11) // 2
if sum(s[:petr * 2 + 1]) >= petr + 1:
	print('YES')
else:
	print('NO')


from collections import Counter
full_length = input()
full_list = list(input())
truncated_list = full_list[0:len(full_list) - 10]
if truncated_list.count('8') > len(truncated_list) / 2:
	print('YES')
else:
	print('NO')


import sys
n = int(input())
num = input()
num = list(map(int, list(num)))
count8 = 0
index8 = []
res = ''
for i in num:
	if i == 8:
		count8 += 1
		index8.append(i)
if count8 < (n - 11) // 2:
	print('NO')
	sys.exit()
else:
	movesA = (n - 11) // 2
	movesB = (n - 11) // 2
	for i in range(n):
		if num[i] == 8:
			if movesA > 0:
				movesA -= 1
			else:
				res += str(num[i])
		elif movesB > 0:
			movesB -= 1
		else:
			res += str(num[i])
if res[0] == '8':
	print('YES')
else:
	print('NO')


def solve(n, S):
	EightIdx = []
	for (i, s) in enumerate(S):
		if s == '8':
			EightIdx.append(i)
	l = len(EightIdx)
	t = (n - 11) // 2
	if l <= t:
		return 'NO'
	idx = EightIdx[t]
	if n - idx >= 11:
		return 'YES'
	return 'NO'
n = int(input())
S = list(input().strip())
print(solve(n, S))


n = int(input())
m = input()
cnt = (n - 11) // 2
cntt = cnt
res = ''
for i in m:
	if i == '8':
		if cnt > 0:
			cnt -= 1
		else:
			res = res + i
	elif cntt > 0:
		cntt -= 1
	else:
		res = res + i
if res[0] == '8':
	print('YES')
else:
	print('NO')


n = int(input())
s = input()
count = 0
numofmoves = (n - 11) // 2
for i in range(n):
	if s[i] == '8':
		count += 1
		continue
	if numofmoves == 0:
		break
	numofmoves -= 1
if count > (n - 11) // 2:
	print('YES')
else:
	print('NO')


from os import path
import sys, time
from math import ceil, floor, gcd, log, log2, factorial
from collections import defaultdict, Counter, OrderedDict, deque
from itertools import combinations, groupby, zip_longest
from functools import reduce
from operator import mul
maxx = float('inf')
I = lambda : int(sys.stdin.buffer.readline())
tup = lambda : map(int, sys.stdin.buffer.readline().split())
lint = lambda : [int(x) for x in sys.stdin.buffer.readline().split()]
S = lambda : sys.stdin.readline().strip('\n')
grid = lambda r: [lint() for i in range(r)]
stpr = lambda x: sys.stdout.write(f'{x}' + '\n')
star = lambda x: print(' '.join(map(str, x)))
localsys = 0
start_time = time.time()
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
n = I()
s = S()
vasya = petya = (n - 11) // 2
res = ''
for i in s:
	if i == '8':
		if petya:
			petya -= 1
		else:
			res += i
	elif vasya:
		vasya -= 1
	else:
		res += i
print('YES' if res[0] == '8' else 'NO')
if localsys:
	print('\n\nTime Elased :', time.time() - start_time, 'seconds')


import sys

class BGameWithTelephoneNumbers:

	def solve(self):
		print(self._solve())

	def _solve(self):
		n = int(input())
		s = input()
		him = (n - 11) // 2
		me = n - 11 - him
		cnt = 0
		others = 0
		for i in range(n):
			if s[i] == '8':
				cnt += 1
			else:
				others += 1
			if cnt == him + 1:
				break
		return 'YES' if cnt > him and others <= me else 'NO'
solver = BGameWithTelephoneNumbers()
input = sys.stdin.readline
solver.solve()


def solve2():
	n = int(input())
	s = input()
	pets = (n - 11) / 2
	vas = pets
	del_ = 0
	free = 0
	for i in range(n):
		if i <= n - 11:
			if s[i] == '8':
				del_ += 1
			else:
				free += 1
	if del_ <= pets:
		print('NO')
	else:
		print('YES')
solve2()


import sys
sys_input = sys.stdin.readline

def si():
	return sys_input().rstrip()

def ii():
	return int(si())

def sti():
	return si().split()

def iti():
	return map(int, sti())

def sli():
	return list(si())

def ili():
	return list(iti())

def main():
	turns = (N - 11) // 2
	eights = S.count(8)
	if turns >= eights:
		print('NO')
		return
	if S[0:turns * 2 + 1].count(8) >= turns + 1:
		print('YES')
		return
	print('NO')
	return
N = ii()
S = [int(s) for s in sli()]
main()


p = int(input())
s = input()
a = p - 11
b = s[0:a + 1].count('8')
if b > a / 2:
	print('YES')
else:
	print('NO')


(d, s) = ((int(input()) - 11) // 2, list(filter(lambda x: x[1] == '8', enumerate(input()))))
print(('NO', 'YES')[len(s) > d and s[d][0] <= 2 * d])


n = int(input())
s = input()
p = s.find('8')
turns = (n - 11) // 2
cpt = s.count('8')
if cpt <= turns:
	print('NO')
else:
	cpt8 = 0
	ind = 0
	cptOther = 0
	while cpt8 != turns + 1:
		if s[ind] == '8':
			cpt8 += 1
		else:
			cptOther += 1
		ind += 1
	if cptOther <= turns:
		print('YES')
	else:
		print('NO')


import bisect
import decimal
from decimal import Decimal
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate
decimal.getcontext().prec = 46

def primeFactors(n):
	prime = set()
	while n % 2 == 0:
		prime.add(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			prime.add(i)
			n = n // i
	if n > 2:
		prime.add(n)
	return list(prime)

def getFactors(n):
	factors = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				factors.append(i)
			else:
				factors.append(i)
				factors.append(n // i)
		i = i + 1
	return factors

def modefiedSieve():
	mx = 10 ** 7 + 1
	sieve = [-1] * mx
	for i in range(2, mx):
		if sieve[i] == -1:
			sieve[i] = i
			for j in range(i * i, mx, i):
				if sieve[j] == -1:
					sieve[j] = i
	return sieve

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

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

def sort_dict(key_value):
	return sorted(key_value.items(), key=lambda kv: (kv[1], kv[0]), reverse=True)

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

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

def string_list():
	return list(input())

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

def binaryToDecimal(n):
	return int(n, 2)

def DFS(n, s, adj):
	visited = [False for i in range(n + 1)]
	stack = []
	stack.append(s)
	while len(stack):
		s = stack[-1]
		stack.pop()
		if not visited[s]:
			visited[s] = True
		for node in adj[s]:
			if not visited[node]:
				stack.append(node)

def maxSubArraySum(a, size):
	maxint = 10 ** 10
	max_so_far = -maxint - 1
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far

def lis(arr):
	n = len(arr)
	lis = [1] * n
	for i in range(1, n):
		for j in range(0, i):
			if arr[i] >= arr[j] and lis[i] < lis[j] + 1:
				lis[i] = lis[j] + 1
	maximum = 0
	for i in range(n):
		maximum = max(maximum, lis[i])
	return maximum

def solve():
	n = int(input())
	num = list(input())
	deletion = n - 11
	occur = []
	for i in range(n):
		if num[i] == '8':
			occur.append(i + 1)
	if occur == []:
		print('NO')
		return
	if deletion // 2 >= len(occur):
		print('NO')
		return
	position = occur[deletion // 2] - deletion // 2 - 1
	ans = deletion // 2
	if deletion % 2 != 0:
		ans += 1
	if ans >= position:
		print('YES')
	else:
		print('NO')
t = 1
for _ in range(t):
	solve()


(n, s) = (int(input()), input())
cnt = (n - 11) // 2
cnt_8 = len(s[:n - 10].split('8')) - 1
if cnt >= cnt_8:
	print('NO')
else:
	print('YES')


N = int(input())
number = input()
moves = N - 11
if moves % 2 == 0:
	vasya = moves // 2
else:
	vasya = moves // 2 + 1
eight = list()
for i in range(N):
	if number[i] == '8':
		eight.append(i)
if len(eight) == 0:
	print('NO')
elif moves - vasya >= len(eight):
	print('NO')
elif eight[0] > vasya:
	print('NO')
else:
	check = False
	for index in range(len(eight)):
		if vasya + index >= eight[index] and index >= moves - vasya:
			check = True
			break
	if check:
		print('YES')
	else:
		print('NO')


n = int(input())
temp = input()
a = []
for i in range(n):
	if temp[i] == '8':
		a.append(1)
	else:
		a.append(0)
count = 0
for i in range(n):
	if a[i] == 1 and count < (n - 11) // 2:
		a[i] = 2
		count += 1
i = (n - 11) // 2 + 1
j = 0
ans = True
while i > 0 and j < n:
	if a[j] == 1:
		print('YES')
		ans = False
		break
	elif a[j] == 2:
		j += 1
		continue
	j += 1
	i -= 1
if ans:
	print('NO')


n = int(input())
s = input()
e = s[:n - 10].count('8')
x = (n - 11) // 2
if e > x:
	print('YES')
else:
	print('NO')


from sys import stdin, stdout
import cProfile, math
from collections import Counter, defaultdict
from bisect import bisect_left, bisect, bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
import operator as op
from functools import reduce
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)
fac_warmup = False
printHeap = str()
memory_constrained = False
P = 10 ** 9 + 7
import sys

class merge_find:

	def __init__(self, n):
		self.parent = list(range(n))
		self.size = [1] * n
		self.num_sets = n
		self.lista = [[_] for _ in range(n)]

	def find(self, a):
		to_update = []
		while a != self.parent[a]:
			to_update.append(a)
			a = self.parent[a]
		for b in to_update:
			self.parent[b] = a
		return self.parent[a]

	def merge(self, a, b):
		a = self.find(a)
		b = self.find(b)
		if a == b:
			return
		if self.size[a] < self.size[b]:
			(a, b) = (b, a)
		self.num_sets -= 1
		self.parent[b] = a
		self.size[a] += self.size[b]
		self.lista[a] += self.lista[b]

	def set_size(self, a):
		return self.size[self.find(a)]

	def __len__(self):
		return self.num_sets

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

def primeFactors(n):
	factors = dict()
	for i in range(2, math.ceil(math.sqrt(n)) + 1):
		while n % i == 0:
			if i in factors:
				factors[i] += 1
			else:
				factors[i] = 1
			n = n // i
	if n > 2:
		factors[n] = 1
	return factors

def fibonacci_modP(n, MOD):
	if n < 2:
		return 1
	return (cached_fn(fibonacci_modP, (n + 1) // 2, MOD) * cached_fn(fibonacci_modP, n // 2, MOD) + cached_fn(fibonacci_modP, (n - 1) // 2, MOD) * cached_fn(fibonacci_modP, (n - 2) // 2, MOD)) % MOD

def factorial_modP_Wilson(n, p):
	if p <= n:
		return 0
	res = p - 1
	for i in range(n + 1, p):
		res = res * cached_fn(InverseEuler, i, p) % p
	return res

def binary(n, digits=20):
	b = bin(n)[2:]
	b = '0' * (20 - len(b)) + b
	return b

def isprime(n):
	if n < 4:
		return True
	if n % 2 == 0:
		return False
	if n % 3 == 0:
		return False
	i = 5
	w = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += w
		w = 6 - w
	return True
factorial_modP = []

def warm_up_fac(MOD):
	nonlocal factorial_modP, fac_warmup
	if fac_warmup:
		return
	factorial_modP = [1 for _ in range(fac_warmup_size + 1)]
	for i in range(2, fac_warmup_size):
		factorial_modP[i] = factorial_modP[i - 1] * i % MOD
	fac_warmup = True

def InverseEuler(n, MOD):
	return pow(n, MOD - 2, MOD)

def nCr(n, r, MOD):
	nonlocal fac_warmup, factorial_modP
	if not fac_warmup:
		warm_up_fac(MOD)
		fac_warmup = True
	return factorial_modP[n] * (pow(factorial_modP[r], MOD - 2, MOD) * pow(factorial_modP[n - r], MOD - 2, MOD) % MOD) % MOD

def test_print(*args):
	if testingMode:
		print(args)

def display_list(list1, sep=' '):
	stdout.write(sep.join(map(str, list1)) + '\n')

def display_2D_list(li):
	for i in li:
		print(i)

def prefix_sum(li):
	sm = 0
	res = []
	for i in li:
		sm += i
		res.append(sm)
	return res

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

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

def get_list():
	return list(map(int, stdin.readline().split()))
import heapq, itertools
pq = []
entry_finder = {}
REMOVED = '<removed-task>'

def add_task(task, priority=0):
	if task in entry_finder:
		remove_task(task)
	count = next(counter)
	entry = [priority, count, task]
	entry_finder[task] = entry
	heapq.heappush(pq, entry)

def remove_task(task):
	entry = entry_finder.pop(task)
	entry[-1] = REMOVED

def pop_task():
	while pq:
		(priority, count, task) = heapq.heappop(pq)
		if task is not REMOVED:
			del entry_finder[task]
			return task
	raise KeyError('pop from an empty priority queue')
memory = dict()

def clear_cache():
	nonlocal memory
	memory = dict()

def cached_fn(fn, *args):
	nonlocal memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result

def ncr(n, r):
	return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))

def binary_serach(i, li):
	fn = lambda x: li[x] - x // i
	x = -1
	b = len(li)
	while b >= 1:
		while b + x < len(li) and fn(b + x) > 0:
			x += b
		b = b // 2
	return x
TestCases = False
testingMode = False
fac_warmup_size = 10 ** 5 + 100
optimiseForReccursion = True
from math import factorial

def main():
	n = get_int()
	st = list(input())
	x = (n - 11) // 2
	y = x
	li = []
	for i in st:
		if i != '8':
			li.append(i)
		else:
			x -= 1
			if x == -1:
				break
	print('YES') if len(li) <= y else print('NO')
if TestCases:
	for i in range(get_int()):
		cProfile.run('main()') if testingMode else main(i)
else:
	(cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()


n = int(input())
s = list(input())
l = [0] * n
ct = 0
for i in range(n):
	if s[i] == '8':
		l[ct] = i
		ct += 1
if ct == 0:
	print('NO')
elif ct <= (n - 11) // 2:
	print('NO')
else:
	ct = (n - 11) // 2
	x = l[ct]
	if x <= ct + (n - 10) // 2:
		print('YES')
	else:
		print('NO')


n = int(input())
s = input()
l = list(s)
c = []
for i in range(n):
	if l[i] == '8':
		c.append(i)
if len(c) == 0:
	print('NO')
elif c[0] > (n - 11) // 2 or len(c) <= (n - 11) // 2:
	print('NO')
elif c[(n - 11) // 2] > n - 11:
	print('NO')
else:
	print('YES')


n = int(input())
imp = True
nums = [*map(int, list(input())[:-10])]
if nums.count(8) <= (n - 11) // 2:
	print('NO')
else:
	print('YES')


import sys, math
from collections import defaultdict, deque
input = sys.stdin.readline
n = int(input())
s = input().strip()
moves = n - 11
n -= 10
c = 0
for i in range(n):
	if s[i] == '8':
		c += 1
if c > moves // 2:
	print('YES')
else:
	print('NO')


import sys
input = sys.stdin.readline

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

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

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

def li():
	return list(input().rstrip())
n = ii()
s = li()
n = n - 11
s_eight = s[0:n + 1].count('8')
if s_eight > n // 2:
	print('YES')
else:
	print('NO')


n = int(input())
s = [int(x) for x in input()]
s = s[:-10]
if s.count(8) > (n - 11) // 2:
	print('YES')
else:
	print('NO')


n = int(input())
s = str(input())
s_before_10 = 0
for i in range(n - 10):
	if int(s[i]) == 8:
		s_before_10 += 1
x = n - 11
if x % 2 == 0 and x / 2 < s_before_10:
	print('YES')
elif x % 2 != 0 and x / 2 + 1 < s_before_10:
	print('YES')
else:
	print('NO')


n = int(input())
s = input()
a = []
t = 0
for i in range(len(s)):
	if s[i] == '8':
		a.append(i)
		t += 1
if t <= (n - 11) // 2:
	print('NO')
else:
	w = a[(n - 11) // 2]
	if w > n - 11:
		print('NO')
	else:
		print('YES')


n = int(input())
nums = input()
len = (n - 11) / 2
eights = 0
for i in range(int(len * 2 + 1)):
	if nums[i] == '8':
		eights += 1
if eights > len:
	print('YES')
else:
	print('NO')


n = int(input())
s = input()
m = (n - 11) // 2
ct = 0
ct8 = 0
for i in range(n):
	if s[i] == '8':
		ct8 += 1
	else:
		ct += 1
	if ct8 == m + 1:
		break
if ct <= m:
	print('YES')
else:
	print('NO')


def main():
	n = int(input())
	s = input()
	moves = (n - 11) // 2
	if s.count('8') <= moves:
		print('NO')
		return
	if s[:-10].count('8') >= moves + 1:
		print('YES')
	else:
		print('NO')
main()


import sys, math
from collections import defaultdict, deque
input = sys.stdin.readline
n = int(input())
s = input().strip()
moves = n - 11
l8 = []
visited = set()
for i in range(n):
	if s[i] == '8':
		l8.append(i)
l8ptr = 0
f = 0
vasya = True
curhead = 0
non8ptr = 0
while non8ptr < n and s[non8ptr] == '8':
	non8ptr += 1
if non8ptr == n:
	print('YES')
elif len(l8) <= moves // 2:
	print('NO')
else:
	while moves > 0:
		if vasya:
			if s[curhead] == '8':
				visited.add(non8ptr)
				while non8ptr < n and s[non8ptr] == '8':
					non8ptr += 1
				if non8ptr == n:
					break
			else:
				visited.add(curhead)
				curhead += 1
				while curhead in visited:
					curhead += 1
				if curhead == n:
					break
			vasya = False
		else:
			if s[curhead] == '8':
				visited.add(curhead)
				curhead += 1
				while curhead in visited:
					curhead += 1
				if curhead == n:
					f = 1
					break
				l8ptr += 1
			else:
				pos = l8[l8ptr]
				visited.add(pos)
				l8ptr += 1
			if l8ptr == len(l8):
				f = 1
				break
			vasya = True
		moves -= 1
	if f == 1:
		print('NO')
	else:
		for i in range(n):
			if s[i] == '8' and i not in visited:
				cnt = 0
				for j in range(i + 1, n):
					if j not in visited:
						cnt += 1
						if cnt >= 10:
							break
				if cnt >= 10:
					print('YES')
				else:
					print('NO')
				break


n = int(input())
nn = n
eight = []
rest = []
s = list(input())
for i in range(n):
	if s[i] == '8':
		eight.append(i)
	else:
		rest.append(i)
lst = eight + rest[::-1]
i = 0
left = 1
right = 0
while n > 11:
	n -= 1
	if i == 0:
		s[lst[-left]] = ''
		left += 1
		i = 1
	else:
		s[lst[right]] = ''
		right += 1
		i = 0
ans = ''
for i in range(nn):
	ans += s[i]
if ans[0] == '8':
	print('YES')
else:
	print('NO')


from math import *
n = int(input())
s = input()
s_ = s[:n - 10]
if s_.count('8') >= int(ceil(len(s_) / 2)):
	print('YES')
else:
	print('NO')


n = int(input())
S = input()
X = n - 11
heh = set()
heh.add('8')
if S[:X + 1].count('8') > X // 2:
	print('YES')
else:
	print('NO')


a = int(input())
s = input()
t = []
r = []
q = []
for i in s:
	t.append(int(i))
z = a - 11
ans = []
for i in range(len(t)):
	if s[i] == '8':
		r.append(i)
	else:
		q.append(i)
glag = 1
m1 = m2 = 0
while 0 <= m1 < len(r) and 0 <= m2 < len(q):
	if len(q) != 0 and glag == 1:
		ans.append(q[m2])
		m2 = m2 + 1
		glag = 0
	elif len(r) != 0 and glag == 0:
		ans.append(r[m1])
		m1 = m1 + 1
		glag = 1
ans.extend(q[m2:])
ans.extend(r[m1:])
for i in range(z):
	t[ans[i]] = -1
for i in t:
	if i == -1:
		continue
	elif i == 8:
		print('YES')
		break
	else:
		print('NO')
		break


import sys
n = int(input())
s = input()
k = (n - 11) // 2
licz = 0
for i in range(n):
	if s[i] == '8':
		licz += 1
if licz <= k:
	print('NO')
	sys.exit(0)
licz = 0
i = -1
while True:
	i += 1
	if s[i] == '8':
		licz += 1
	if licz == k + 1:
		break
if i > 2 * k:
	print('NO')
else:
	print('YES')


def go():
	n = int(input())
	a = [int(i) for i in input()]
	a = a[:n - 10]
	x = a.count(8)
	z = n - 10
	if z // 2 + 1 <= x:
		return 'YES'
	return 'NO'
print(go())


__version__ = '0.4'
__date__ = '2019-04-23'
import sys

def solve(n, s):
	steps_left = n - 11
	petya = steps_left // 2
	vasya = steps_left - petya
	i = 0
	while petya > 0 or vasya > 0:
		if i >= steps_left:
			break
		if s[i] == '8':
			petya -= 1
		else:
			vasya -= 1
		i += 1
	if vasya < 0:
		return False
	if petya < 0:
		return True
	return s[i] == '8'

def main(argv=None):
	n = int(input())
	s = input()
	answer = solve(n, s)
	if answer:
		print('YES')
	else:
		print('NO')
	return 0
STATUS = main()
sys.exit(STATUS)


import sys
from math import ceil
input = sys.stdin.readline
n = int(input())
s = list(input().strip())
deleteEights = (n - 11) // 2
deleteOthers = (n - 11) // 2
for i in range(n):
	if deleteEights > 0:
		if s[i] == '8':
			s[i] = -1
			deleteEights -= 1
			continue
	if deleteOthers > 0:
		if s[i] != '8':
			s[i] = -1
			deleteOthers -= 1
			continue
for i in range(n):
	if s[i] != -1:
		if s[i] == '8':
			print('YES')
		else:
			print('NO')
		break


n = int(input())
S = input()
pos_8 = [i + 1 for i in range(n) if S[i] == '8']
n_moves = n - 11
nenya_moves = n_moves // 2
if len(pos_8) <= nenya_moves:
	print('NO')
else:
	for x in pos_8[nenya_moves:]:
		if x - n_moves <= 1:
			print('YES')
			break
	else:
		print('NO')


n = int(input(''))
pele = input('')
ch = n - 11
c = 0
for i in range(ch + 1):
	if pele[i] == '8':
		c += 1
ja = int(ch / 2)
if ja < c:
	print('YES')
else:
	print('NO')


n = int(input())
s = list(input())
vasya = 0
petya = 0
win = ''
for i in range(n - 11):
	if i % 2 == 0:
		if vasya >= n:
			win = vasya
			break
		else:
			while s[vasya] == '8' or s[vasya] == '':
				vasya += 1
				if vasya >= n:
					win = vasya
					break
		if vasya >= n:
			break
		s[vasya] = ''
	else:
		if petya >= n:
			win = petya
			break
		else:
			while s[petya] != '8' or s[petya] == '':
				petya += 1
				if petya >= n:
					win = petya
					break
		if petya >= n:
			break
		s[petya] = ''
if win == '':
	tel = ''.join(map(str, s))
	if tel[0] == '8':
		win = vasya
	else:
		win = petya
if win == vasya:
	print('YES')
else:
	print('NO')


inp = lambda cast=int: list(map(cast, input().split()))
(n,) = inp()
(s,) = inp(str)
(e, o) = (0, 0)
turns = n - 11
for i in range(0, n):
	if s[i] == '8':
		e += 1
	else:
		o += 1
	if o > (turns + 1) // 2:
		break
if e > turns // 2:
	print('YES')
else:
	print('NO')


n = int(input())
s = str(input())
count = 0
ans = False
for i in range(n):
	if int(s[i]) == 8 and n - i >= 11:
		count += 1
p = n - 11
if count > p // 2:
	print('YES')
else:
	print('NO')


import math
import bisect
import itertools
import sys
I = lambda : sys.stdin.readline()
mod = 10 ** 9 + 7

def modu(a, m):
	if a % m:
		return a % m
	return m

def mindiff(a):
	b = a[:]
	b.sort()
	m = 10000000000
	for i in range(len(b) - 1):
		if b[i + 1] - b[i] < m:
			m = b[i + 1] - b[i]
	return m

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

def merge(a, b):
	i = 0
	j = 0
	c = 0
	ans = []
	while i < len(a) and j < len(b):
		if a[i] < b[j]:
			ans.append(a[i])
			i += 1
		else:
			ans.append(b[j])
			c += len(a) - i
			j += 1
	ans += a[i:]
	ans += b[j:]
	return (ans, c)

def mergesort(a):
	if len(a) == 1:
		return (a, 0)
	mid = len(a) // 2
	(left, left_inversion) = mergesort(a[:mid])
	(right, right_inversion) = mergesort(a[mid:])
	(m, c) = merge(left, right)
	c += left_inversion + right_inversion
	return (m, c)

def is_prime(num):
	if num == 1:
		return False
	if num == 2:
		return True
	if num == 3:
		return True
	if num % 2 == 0:
		return False
	if num % 3 == 0:
		return False
	t = 5
	a = 2
	while t <= int(math.sqrt(num)):
		if num % t == 0:
			return False
		t += a
		a = 6 - a
	return True

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

def ncr1(n, r):
	s = 1
	for i in range(min(n - r, r)):
		s *= n - i
		s %= mod
		s *= pow(i + 1, mod - 2, mod)
		s %= mod
	return s
n = int(input())
a = list(map(int, input()))
k = a.count(8)
if (n - 11) // 2 >= k:
	print('NO')
else:
	s = (n - 11) // 2
	for i in range(n):
		if s > 0 and a[i] == 8:
			s -= 1
			a[i] = -1
	b = []
	for i in a:
		if i + 1:
			b.append(i)
	l = len(b)
	if 8 in b[:(n - 11) // 2 + 1]:
		print('YES')
	else:
		print('NO')


n = int(input())
a = list(input())
p = n - 11
p = p // 2
t = 0
for i in a:
	if i == '8':
		t = t + 1
if t <= p:
	print('NO')
else:
	q = 0
	for i in range(2 * p + 1):
		if a[i] == '8':
			q = q + 1
	if q >= p + 1:
		print('YES')
	else:
		print('NO')


n = int(input())
s = str(input())
if s[::-1][10:].count('8') > (n - 11) // 2:
	print('YES')
else:
	print('NO')


def main():
	n = int(input())
	arr = list(map(int, input()))
	a = arr.count(8)
	if a <= (n - 11) // 2:
		print('NO')
		return 0
	i = -1
	cnt = 1 + (n - 11) // 2
	while cnt:
		i += 1
		if arr[i] == 8:
			cnt -= 1
	if i > n - 11:
		print('NO')
		return 0
	print('YES')
	return 0
main()


n = int(input())
s = str(input())
count = 0
p = []
for i in range(n):
	if s[i] == '8':
		count += 1
		p.append(i)
moves = int((n - 11) / 2)
if moves >= count:
	print('NO')
	exit()
elif p[moves] <= 2 * moves:
	print('YES')
else:
	print('NO')


n = int(input())
Arr = list(map(int, list(input())))
min_possible = (n - 11) // 2
count = 0
store = -1
for i in range(n - 11):
	if Arr[i] == 8:
		count += 1
	if count >= min_possible and Arr[i + 1] == 8:
		print('YES')
		store = i
		break
if store == -1:
	print('NO')


n = input()
n = int(n)
s = input()
temp = n - 11
eights = temp / 2 + 1
turns = temp / 2
index = eights + turns
index = int(index)
aux = s[:index]
if aux.count('8') >= eights:
	print('YES')
else:
	print('NO')


n = input()
n = int(n)
temp_L = input()
L = [0 for i in range(n)]
for i in range(n):
	L[i] = temp_L[i]
count = 0
if n % 2 == 1:
	for i in range(n - 10):
		if L[i] == '8':
			count = count + 1
	if count >= (n - 10) / 2:
		print('YES')
	else:
		print('NO')
if n % 2 == 0:
	for i in range(n - 10):
		if L[i] == '8':
			count = count + 1
	if count > (n - 10) / 2:
		print('YES')
	else:
		print('NO')


n = int(input())
a = list(input())
arr = a[::-1]
c = 0
for i in range(10, n):
	if arr[i] == '8':
		c += 1
num = n - 11
need = num // 2
if c > need:
	print('YES')
else:
	print('NO')


if (int(input()) - 9) // 2 <= input()[:-10].count('8'):
	print('YES')
else:
	print('NO')


from collections import deque as de
import math
from collections import Counter as cnt

class My_stack:

	def __init__(self):
		self.data = []

	def my_push(self, x):
		return self.data.append(x)

	def my_pop(self):
		return self.data.pop()

	def my_peak(self):
		return self.data[-1]

	def my_contains(self, x):
		return self.data.count(x)

	def my_show_all(self):
		return self.data

	def isEmpty(self):
		return len(self.data) == 0
arrStack = My_stack()

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def get_prime_factors(number):
	prime_factors = []
	while number % 2 == 0:
		prime_factors.append(2)
		number = number / 2
	for i in range(3, int(math.sqrt(number)) + 1, 2):
		while number % i == 0:
			prime_factors.append(int(i))
			number = number / i
	if number > 2:
		prime_factors.append(int(number))
	return prime_factors

def get_frequency(list):
	dic = {}
	for ele in list:
		if ele in dic:
			dic[ele] += 1
		else:
			dic[ele] = 1
	return dic
n = int(input())
s = list(map(int, input()))
n8 = 0
no = 0
for i in range(n - 11):
	if s[i] == 8:
		n8 += 1
	else:
		no += 1
if no == n8:
	if s[n - 11] == 8:
		print('YES')
	else:
		print('NO')
elif no > n8:
	print('NO')
else:
	print('YES')


n = int(input())
s = input()
eights = []
len8 = 0
not_eights = []
lenn8 = 0
for i in range(len(s)):
	if s[i] == '8':
		eights.append(i)
		len8 += 1
	else:
		not_eights.append(i)
		lenn8 += 1
n -= 11
if n // 2 >= len8:
	print('NO')
else:
	a = eights[n // 2]
	if n - n // 2 < lenn8:
		b = not_eights[n - n // 2]
		if a < b:
			print('YES')
		else:
			print('NO')
	else:
		print('YES')


n = input()
s = input()
str = s[:-10]
c = str.count('8')
l = len(str)
if c > l // 2:
	print('YES')
else:
	print('NO')


n = int(input())
a = list(input())
t = int((n - 11) / 2)
ct = t
for i in range(n):
	if a[i] != '8':
		a[i] = '#'
		ct -= 1
		if ct == 0:
			break
if ct != 0:
	for k in range(n):
		if a[k] != '#':
			a[k] = '#'
			ct -= 1
			if ct == 0:
				break
ct = t
for i in range(n):
	if a[i] == '8':
		a[i] = '#'
		ct -= 1
		if ct == 0:
			break
if ct != 0:
	for k in range(n):
		if a[k] != '#':
			a[k] = '#'
			ct -= 1
			if ct == 0:
				break
for k in range(n):
	if a[k] != '#':
		if a[k] == '8':
			print('YES')
		else:
			print('NO')
		break


n = int(input()) - 11
from math import ceil
print('YES' if input()[:n + 1].count('8') > ceil(n / 2) else 'NO')


n = int(input())
s = input()
res = ''
eight = (n - 11) / 2
not_eight = (n - 11) / 2
const = (n - 11) / 2
for i in range(n):
	if s[i] == '8':
		if eight > 0:
			eight -= 1
		else:
			res = res + s[i]
	elif not_eight > 0:
		not_eight -= 1
	else:
		res = res + s[i]
if res[0] == '8':
	print('YES')
else:
	print('NO')


n = int(input())
string = input()
nop = (n - 11) // 2
nov = (n - 11) // 2
eight_req = nop + 1
x = string.count('8')
if x < eight_req:
	print('NO')
else:
	k = 0
	index = 0
	last = 0
	total = 0
	while k < eight_req and index < n:
		if string[index] == '8':
			total += index - last - 1
			last = index
			k += 1
		index += 1
	if total < nov:
		print('YES')
	else:
		print('NO')


n = int(input())
s = input()
x = (n - 11) // 2
if s.count('8') < x:
	print('NO')
else:
	s = s.replace('8', '', x)
	if s[:-10].count('8') > 0:
		print('YES')
	else:
		print('NO')


n = int(input())
string = input()
num = string.count('8')
if num <= (n - 11) // 2:
	print('NO')
	exit()
quota = (n - 11) // 2
i = 0
quota += 1
while quota:
	if string[i] == '8':
		quota -= 1
	i += 1
last_eight = i - 1
quota = (n - 11) // 2
if last_eight - quota <= quota:
	print('YES')
else:
	print('NO')


(n, s) = (int(input()), input())
s = s[:n - 10]
a = s.count('8')
b = len(s) - a
print('YES' if a >= b else 'NO')


def main():
	n = int(input())
	s = input()
	print('YES' if s[:n - 10].count('8') > (n - 11) // 2 else 'NO')
main()


lent = int(input())
s = input()
n = 0
delta = lent - 11
for i in range(delta + 1):
	if s[i] == '8':
		n += 1
if n * 2 > delta:
	print('YES')
else:
	print('NO')


input()
s = input()
not8 = [i for (i, c) in enumerate(s) if c != '8']
is8 = [i for (i, c) in enumerate(s) if c == '8']
n = len(s)
moves = (n - 11) // 2
if moves >= len(not8):
	print('YES')
	raise SystemExit(0)
if moves >= len(is8):
	print('NO')
	raise SystemExit(0)
not8 = not8[moves:]
is8 = is8[moves:]
if is8[0] < not8[0]:
	print('YES')
	raise SystemExit(0)
else:
	print('NO')
	raise SystemExit(0)


inp = lambda : int(input())
strl = lambda : list(input().strip())
seq = lambda : list(map(int, input().strip().split()))

def results(arr, n):
	if n < 11:
		return 'NO'
	if n == 11:
		if arr[0] == 8:
			return 'YES'
		return 'NO'
	cnt = 0
	mov = n - 11
	my = (n - 11) // 2
	cnt2 = 0
	for i in range(n):
		if arr[i] == '8':
			cnt += 1
			if i > mov:
				cnt2 += 1
	if cnt < my:
		return 'NO'
	else:
		if cnt - cnt2 > my:
			return 'YES'
		return 'NO'

def main():
	n = inp()
	a = input()
	result = results(a, n)
	print(result)
main()


n = int(input())
s = input()
k = n - 11
p = int(k / 2)
cnt = 0
for i in range(k + 1):
	if s[i] == '8':
		cnt += 1
if cnt > p:
	print('Yes')
else:
	print('No')


i1 = int(input())
s = list(input()[:-10])
chance = (i1 - 11) / 2
if s.count('8') > chance and len(s) - s.count('8') <= chance:
	print('YES')
else:
	print('NO')


n = int(input())
tel_str = input()
n = n - 11
count = 0
for i in range(n + 1):
	if tel_str[i] == '8':
		count += 1
if count > (n + 1) // 2:
	print('YES')
else:
	print('NO')


n = int(input())
s = input()
to_change = s[:-10]
eights = to_change.count('8')
diff = len(to_change) - eights
if diff <= eights:
	print('YES')
else:
	print('NO')


n = input()
a = input()
b = []
for i in range(len(a)):
	if a[i] == '8':
		b.append(i + 1)
k = len(a) - 11
k = k // 2
if len(b) > k:
	p = b[k:]
	if p[0] - k - 1 <= k:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


n = int(input())
s = input()
erased = [False] * n
t = 0
for i in range(n):
	if s[i] == '8':
		t += 1
m = (n - 11) // 2
if t < m:
	print('NO')
else:
	a = m
	for i in range(n):
		if a == 0:
			break
		if s[i] != '8' and (not erased[i]):
			erased[i] = True
			a -= 1
	a = m
	for i in range(n):
		if a == 0:
			break
		if s[i] == '8' and (not erased[i]):
			erased[i] = True
			a -= 1
	for i in range(n):
		if not erased[i]:
			if s[i] == '8':
				print('YES')
			else:
				print('NO')
			break


n = int(input(''))
tele = input('')
chn = n - 11
c = 0
for i in range(chn + 1):
	if tele[i] == '8':
		c += 1
jak = int(chn / 2)
if jak < c:
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, list(input())))
moves = n - 11
c = moves // 2
indi8 = []
c8 = 0
for i in range(n):
	if a[i] == 8:
		indi8.append(i)
		c8 += 1
blah = 0
if c8 > c:
	count = 0
	remain = 0
	for i in range(n):
		if a[i] == 8:
			count += 1
		else:
			remain += 1
		if count == c + 1:
			break
	if remain <= c:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


import collections

def solve():
	N = int(input())
	S = input()
	cnt = collections.Counter(S[:N - 11 + 1])
	if cnt['8'] >= (N - 11) // 2 + 1:
		print('YES')
	else:
		print('NO')
solve()


from math import floor, ceil
n = int(input())
seq = input()
count = seq.count('8')
vasya = ceil((n - 11) / 2)
petya = floor((n - 11) / 2)
if count <= (n - 11) // 2:
	print('NO')
	exit()
new = ''
for (x, i) in enumerate(seq):
	if i != '8':
		new += i
		continue
	petya -= 1
	if petya == 0:
		new += seq[x + 1:]
if new.index('8') > vasya:
	print('NO')
	exit()
print('YES')


n = int(input())
a = list(str(input()))
s = len(a) - 10
k = 0
for i in range(0, s):
	if int(a[i]) == 8:
		k = k + 1
if k > s / 2:
	print('YES')
else:
	print('NO')


n = int(input())
s = input()
step = n - 11
st = s[:step]
kol8 = st.count('8')
kolnot8 = step - kol8
if kol8 < kolnot8:
	print('NO')
elif kol8 == kolnot8:
	if s[step] == '8':
		print('YES')
	else:
		print('NO')
else:
	print('YES')


from collections import Counter
n = int(input())
s = input()
a = Counter(s[:n - 10])
if a.get('8', 0) > (n - 11) / 2:
	print('YES')
else:
	print('NO')


n = int(input())
s = input()
num = (n - 11) // 2
num2 = 0
num3 = -1
for i in range(n):
	if s[i] == '8':
		num2 += 1
		if num2 == num + 1:
			num3 = i
			break
if num3 == -1 or num3 > num * 2:
	print('NO')
else:
	print('YES')


n = int(input())
s = input()
cnt = 0
l = n - 10
for i in range(0, l):
	if s[i] == '8':
		cnt = cnt + 1
if cnt > l // 2:
	print('YES')
else:
	print('NO')


from math import ceil
n = int(input())
s = input()
ct = s.count('8')
pet = (n - 11) // 2
if ct <= pet:
	print('NO')
elif pet == 0:
	if s[0] == '8' or s[1] == '8':
		print('YES')
	else:
		print('NO')
else:
	a = []
	for i in range(len(s)):
		if s[i] == '8':
			a.append(i)
	ind = a[pet]
	vasya = ceil((n - 11) // 2)
	if vasya >= ind - pet:
		print('YES')
	else:
		print('NO')


def main():
	n = int(input())
	s = input()
	move_cnt = (n - 11) // 2
	pos8 = [i for i in range(n) if s[i] == '8']
	if len(pos8) <= move_cnt:
		print('NO')
		return
	print('YES' if pos8[move_cnt] <= n - 11 else 'NO')
main()


n = int(input())
s = input()
m = s[:-10].count('8')
if m <= (n - 11) // 2:
	print('NO')
else:
	print('YES')


import collections
n = int(input())
s = input()
a = n - 11
b = 1 + a // 2
counter = collections.Counter(s[:a + 1])
if counter['8'] >= b:
	print('YES')
else:
	print('NO')


N = int(input())
S = input()
count8 = 0
for i in range(0, N - 11 + 1):
	if S[i] == '8':
		count8 += 1
if count8 > (N - 11) // 2:
	print('YES')
else:
	print('NO')


n = int(input())
ch = input()
p = len(ch) - 10
p1 = (len(ch) - 11) // 2
ch = ch[:p]
nombre = 0
for i in range(len(ch)):
	if ch[i] == '8':
		nombre = nombre + 1
if nombre > p1:
	print('YES')
else:
	print('NO')


n = int(input())
s = input()
cou = 0
for i in range(0, n - 10):
	if s[i] == '8':
		cou += 1
le = n - 11
hl = le // 2
if cou <= hl:
	print('NO')
else:
	print('YES')


n = int(input())
num = input()
ct1 = 0
ct2 = 0
for c in num[:-10]:
	if c == '8':
		ct1 += 1
	else:
		ct2 += 1
if ct1 > ct2:
	print('YES')
else:
	print('NO')


n = int(input())
str = input()
eights = 0
for i in range(n - 10):
	if str[i] == '8':
		eights += 1
if eights >= (n - 11) / 2 + 1:
	print('YES')
else:
	print('NO')


n = int(input())
numbers = input()
new = []
petya = (n - 11) // 2
vatsya = n - 11 - petya
for i in range(n):
	if numbers[i] == '8':
		if vatsya > 0:
			vatsya -= 1
		else:
			new.append(numbers[i])
	elif petya > 0:
		petya -= 1
	else:
		new.append(numbers[i])
if new[0] == '8':
	print('YES')
else:
	print('NO')


n = int(input())
num = input()
et = num.count('8')
p = (n - 11) // 2
idx = []
for i in range(n):
	if num[i] == '8':
		idx.append(i)
if p >= et:
	print('NO')
else:
	ind = idx[p]
	r = 0
	for i in range(ind):
		if num[i] != '8':
			r += 1
	if (n - 10) // 2 >= r:
		print('YES')
	else:
		print('NO')


(n, l) = (int(input()), input())
b = [False] * n
eights = curr = 0
c = 0
leftF = n - 1
for _ in range(n - 11):
	if c:
		while eights < n and (b[eights] or l[eights] != '8'):
			eights += 1
		if eights == n:
			print('NO')
			exit()
		else:
			b[eights] = True
			eights += 1
	else:
		while curr < n and (b[curr] or l[curr] == '8'):
			curr += 1
		if curr == n:
			while leftF > -1 and b[leftF]:
				leftF -= 1
			b[leftF] = True
			leftF -= 1
		else:
			b[curr] = True
			curr += 1
	c ^= 1
minl = min(eights, curr) - 1
while minl < n and b[minl]:
	minl += 1
if l[minl] == '8':
	print('YES')
else:
	print('NO')


from sys import stdin, stdout
from sys import maxsize
input = stdin.readline

def solve():
	pass
test = 1
for t in range(0, test):
	n = int(input().strip())
	s = list(input().strip())
	cnt = 0
	for i in range(n - 10):
		if s[i] == '8':
			cnt += 1
	moves = (n - 11) // 2 + (n - 11) % 2
	if cnt > moves:
		print('YES')
	else:
		print('NO')
	ans = solve()


n = int(input()) - 11
str = input()
num_8 = 0
for el in str[:n + 1]:
	if el == '8':
		num_8 += 1
if num_8 * 2 <= n:
	print('NO')
else:
	print('YES')


N = int(input())
S = input()
eight = []
no = []
for (i, s) in enumerate(S):
	if s == '8':
		eight.append(i)
	else:
		no.append(i)
remain = N - 11
remain //= 2
if len(eight) <= remain:
	print('NO')
else:
	eight = eight[remain:]
	first = eight[0]
	if first <= 2 * remain:
		print('YES')
	else:
		print('NO')


n = int(input())
s = input()
a = n - 12
c = n - 10
b = s[0:c].count('8')
if b >= (c - 0.1) // 2 + 1 and b != 0:
	print('YES')
else:
	print('NO')


n = int(input())
s = str(input())
c = 0
q = 0
p = (n - 11) // 2
for i in range(0, n):
	if s[i] == '8':
		c = c + 1
		if c == p + 1:
			q = i
if p >= q - p and c > p:
	print('YES')
else:
	print('NO')


n = int(input())
s = list(input())
v = p = (n - 11) // 2
i = 0
while i < len(s) and (v > 0 or p > 0):
	if s[i] == '8' and p > 0:
		s.pop(i)
		p -= 1
	elif s[i] != '8' and v > 0:
		s.pop(i)
		v -= 1
	else:
		i += 1
if s[0] == '8':
	print('YES')
else:
	print('NO')


n = int(input())
s = input()
t = n - 11
f = t // 2
ss = 0
for i in s:
	if i == '8':
		ss += 1
if ss <= f:
	print('NO')
else:
	for i in range(n):
		if s[i] == '8':
			f = f - 1
		if f == -1:
			p = i
			break
	if i <= t:
		print('YES')
	else:
		print('NO')


n = int(input())
s = str(input())
a = []
for i in range(n):
	if s[i] == '8':
		a.append(i)
win = False
v = 0
for i in range(len(a)):
	if n - v - i == 12:
		if v >= a[i] - i - 1:
			win = True
			break
	if 11 <= n - v - i <= 12:
		if v >= a[i] - i:
			win = True
			break
	v += 1
if win:
	print('YES')
else:
	print('NO')


n = int(input())
ph = input()
indices = []
for i in range(n):
	if ph[i] == '8' and i <= n - 11:
		indices.append(i)
ets = len(indices)
turnseach = (n - 11) // 2
if turnseach >= ets:
	print('NO')
else:
	index = indices[turnseach]
	if index - turnseach <= turnseach:
		print('YES')
	else:
		print('NO')


n = int(input())
s = input()
s = list(map(int, list(s)))
d8 = 0
d = 0
for i in range(len(s) - 11):
	if s[i] == 8:
		d8 += 1
	else:
		d += 1
if d8 < d or (d8 == d and s[len(s) - 11] != 8):
	print('NO')
	exit(0)
print('YES')


import math
from collections import deque, defaultdict
from sys import stdin, stdout
listin = lambda : list(map(int, input().split()))
mapin = lambda : map(int, input().split())
n = int(input())
s = input()
k = ''
count = (n - 11) // 2
i = 0
while i < n:
	if s[i] != '8':
		k += s[i]
	else:
		count -= 1
		if count < 0:
			k += s[i]
	i += 1
k = k[:11 + (n - 11) // 2]
if k.find('8') != -1:
	if k.find('8') <= (n - 11) // 2:
		print('YES')
		exit()
print('NO')


n = int(input())
s = str(input())
wall = n - 11
cnt8 = s[0:wall + 1].count('8')
if cnt8 > wall // 2:
	print('YES')
else:
	print('NO')


import sys
import os
import re
if 'DEBUG' in os.environ:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
n = int(input())
s = input()
s = s.replace('8', '', (n - 11) // 2)
s = re.sub('[^8]', '', s, count=(n - 11) // 2)
if s and s[0] == '8':
	print('YES')
else:
	print('NO')


num = int(input())
turns = num - 11
s = str(input())
v = (num - 11) // 2
p = (num - 11) // 2
res = ''
for i in range(num):
	if s[i] == '8':
		if v > 0:
			v -= 1
		else:
			res += s[i]
	elif p > 0:
		p -= 1
	else:
		res += s[i]
print('YES' if res[0] == '8' else 'NO')


n = int(input())
s = input()
c = n - 10 - s[:n - 10].count('8')
if c < s[:n - 10].count('8'):
	print('YES')
else:
	print('NO')


s = int(input())
string = input()
counter = 0
array = []
for i in range(len(string)):
	if string[i] == '8':
		counter += 1
		array.append(i)
if (s - 11) // 2 >= counter:
	print('NO')
elif (s - 11) // 2 < counter:
	if array[0] > (s - 11) // 2:
		print('NO')
	elif array[(s - 11) // 2] - (s - 11) // 2 <= (s - 11) // 2:
		print('YES')
	elif array[(s - 11) // 2] - (s - 11) // 2 > (s - 11) // 2:
		print('NO')
else:
	print('YES')


n = int(input())
s = str(input())
arr1 = []
arr2 = []
for i in range(n):
	if s[i] == '8':
		arr1.append(i)
	else:
		arr2.append(i)
turns = n - 11
if len(arr1) < turns // 2:
	print('NO')
else:
	i = 0
	j = 0
	turn = 1
	count = 0
	while count < turns:
		if turn == 1:
			if j < len(arr2):
				j += 1
			else:
				i += 1
			turn = 2
		else:
			if i < len(arr1):
				i += 1
			else:
				j += 1
			turn = 1
		count += 1
	if i == len(arr1):
		print('NO')
	elif j == len(arr2):
		print('YES')
	elif arr1[i] < arr2[j]:
		print('YES')
	else:
		print('NO')


n = int(input())
strin = input()
sub = n - 11
sum1 = strin.count('8', 0, sub + 1)
if sum1 >= sub / 2 + 1:
	print('YES')
else:
	print('NO')


import sys, math, itertools
from collections import Counter, deque, defaultdict
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush, heapify, nlargest
from copy import deepcopy
mod = 10 ** 9 + 7
INF = float('inf')

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

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

def inpl_1():
	return list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))
n = inp()
s = list(sys.stdin.readline())
s = s[:n]
ss = s[:n - 10]
if ss.count('8') > (n - 10) // 2:
	print('YES')
else:
	print('NO')


n = int(input())
s = input()

def solve(n, s):
	c = s.count('8')
	moves = (n - 11) // 2
	if c <= moves:
		return 'NO'
	c = s[:-10].count('8')
	if c > moves:
		return 'YES'
	return 'NO'
print(solve(n, s))


n = int(input())
s = list(input())
mark = len(s) - 11
k = s[:mark + 1]
e = k.count('8')
ne = len(k) - e
if ne > e:
	print('NO')
else:
	print('YES')


n = int(input())
s = input()
moves = n - 11
opp = moves // 2
for i in range(moves + 1):
	if s[i] == '8':
		opp -= 1
	if opp == -1:
		break
if opp == -1:
	print('YES')
else:
	print('NO')


n = int(input())
s = input()
turns = (n - 11) // 2
es = 0
nones = 0
for i in range(n - 11):
	if s[i] == '8':
		es += 1
	else:
		nones += 1
ans = True
if es == nones:
	if s[-11] == '8':
		ans = True
	else:
		ans = False
elif es < turns:
	ans = False
else:
	ans = True
if ans:
	print('YES')
else:
	print('NO')


n = int(input())
s = str(input())
eight = 0
for i in range(n - 10):
	if s[i] == '8':
		eight += 1
vas = (n - 11) // 2 + (n - 11) % 2
pet = (n - 11) // 2
if pet >= eight:
	print('NO')
else:
	print('YES')


N = int(input())
string = list(map(int, input()))
t = N - 10
counter = string[0:t].count(8)
if counter >= (t + 1) // 2:
	print('YES')
else:
	print('NO')


n = int(input())
s = input()
eight = 0
j = 0
for i in range(n):
	if s[i] == '8':
		eight += 1
		j = i
x = n - 11
x //= 2
ok = True
if eight - 1 < x:
	ok = False
count = 0
j = 0
for i in range(n):
	if s[i] == '8':
		count += 1
	if s[i] == '8' and count > x:
		j = i
		break
if n - j < 11:
	ok = False
if ok:
	print('YES')
else:
	print('NO')


N = int(input())
s = input()
eight = 0
for i in range(N):
	if i <= N - 11 and s[i] == '8':
		eight += 1
moves = (N - 11) // 2
if eight > moves:
	print('YES')
else:
	print('NO')


from sys import stdin
stdin.readline

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

def it():
	return int(stdin.readline().strip())
from math import ceil, sqrt, gcd, factorial
n = it()
s = input()
a = s.count('8')
if (n - 11) // 2 >= a:
	print('NO')
else:
	p = s[:-11]
	a = 0
	for i in range(n - 12, -1, -1):
		if p[i] == '8':
			a += 1
	if a > (n - 11) // 2:
		print('YES')
	elif a >= (n - 11) // 2:
		if s[-11] == '8':
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


n = int(input())
s = input()
count1 = (n - 11) / 2
count2 = count1
res = ''
for i in range(n):
	if s[i] == '8':
		if count1 > 0:
			count1 -= 1
		else:
			res += s[i]
	elif count2 > 0:
		count2 -= 1
	else:
		res += s[i]
if res[0] == '8':
	print('YES')
else:
	print('NO')


N = int(input())
S = input()
d = 0
for i in range(N - 10):
	if S[i] == '8':
		d += 1
if d <= (N - 10) // 2:
	print('NO')
else:
	print('YES')


n = int(input())
s = input()
(c8, cx) = (0, 0)
for v in s[:-10]:
	if v == '8':
		c8 += 1
	else:
		cx += 1
print('YES' if c8 > cx else 'NO')


import sys

class Main:

	def __init__(self):
		self.buff = None
		self.index = 0

	def next(self):
		if self.buff is None or self.index == len(self.buff):
			self.buff = sys.stdin.readline().split()
			self.index = 0
		val = self.buff[self.index]
		self.index += 1
		return val

	def next_int(self):
		return int(self.next())

	def solve(self):
		x = self.next_int()
		s = self.next()
		c8 = 0
		for c in s[:x - 10]:
			if c == '8':
				c8 += 1
		print('YES' if c8 > (x - 10) // 2 else 'NO')
Main().solve()


from collections import Counter
n = int(input())
s = input()
c = Counter(s[:n - 10])
if c['8'] > (n - 10) // 2:
	print('YES')
else:
	print('NO')


n = int(input())
s = input().strip()
l = (n - 11) // 2
v = s.count('8')
c = 0
f = 0
if v <= l:
	f = 1
else:
	for j in range(n):
		if s[j] == '8' and c < l:
			c = c + 1
		elif s[j] == '8' and c == l:
			re = j
			break
	if re - l > l:
		f = 1
if f == 1:
	print('NO')
else:
	print('YES')


import sys
n = 0
s = None
for line in sys.stdin:
	if n == 0:
		n = int(line)
	else:
		s = line.rstrip()
		break
k = n - 11 + 1
t = k // 2 + 1
if s.count('8', 0, k) >= t:
	print('YES')
else:
	print('NO')


n = int(input())
s = input()
l = list(s)
t = []
count = 0
for i in range(n - 10):
	if l[i] == '8':
		t.append(i)
		count += 1
m = n - 11
if count == 0:
	print('NO')
	exit()
if count > m // 2:
	print('YES')
else:
	print('NO')


n = int(input())
s = input()
k = 0
c = ''
q = True
for i in range(n):
	if s[i] != '8' or q == False:
		c += s[i]
	elif q:
		k += 1
		if k == (n - 11) // 2:
			q = False
for i in range((n - 11) // 2 + 1):
	if c[i] == '8':
		print('YES')
		break
else:
	print('NO')


n = int(input())
s = input()
d = [int(i) for i in s]
count = 0
if s[:n - 10].count('8') > (n - 11) // 2:
	print('YES')
else:
	print('NO')


def main():
	n = int(input())
	s = [int(elm) for elm in list(input())]
	indexs_8 = [i for (i, num) in enumerate(s) if num == 8]
	aite_delete_num = (n - 11) // 2
	jibun_delete_num = aite_delete_num
	need_indexs_8 = indexs_8[:aite_delete_num + 1]
	s2 = s.copy()
	i = 0
	count = 0
	n2 = n
	while count < jibun_delete_num and i < n2:
		if s2[i] != 8:
			del s2[i]
			count += 1
			n2 -= 1
		else:
			i += 1
	cond = True
	for i in range(aite_delete_num + 1):
		if s2[i] != 8:
			cond = False
			break
	return cond
result = main()
out = 'YES' if result else 'NO'
print(out)


n = int(input())
s = input()
eights = []
for i in range(n):
	if s[i] == '8':
		eights.append(i)
hands = int((n - 11) / 2)
cont = True
if hands >= len(eights):
	print('NO')
	cont = False
v_hands = hands
if cont:
	if eights[0] != 0:
		v_hands -= eights[0]
	for i in range(0, hands):
		v_hands -= eights[i + 1] - eights[i] - 1
	if v_hands < 0:
		print('NO')
	else:
		print('YES')


from math import *
from collections import *
import sys
sys.setrecursionlimit(10 ** 9)
n = int(input())
a = list(input())
t = (n - 11) // 2
s = a[:2 * t + 1].count('8')
if s >= t + 1:
	print('YES')
else:
	print('NO')


n = int(input())
s = input()
eights_count = 0
for c in s[:-10]:
	if c == '8':
		eights_count += 1
if eights_count > (len(s) - 11) // 2:
	print('YES')
else:
	print('NO')


for _ in range(1):
	n = int(input())
	s = input()
	c = s.count('8')
	l = []
	for x in range(len(s)):
		if s[x] == '8':
			l += [x]
	loss = (n - 11) // 2
	if c > loss:
		q1 = 0
		for i in range(l[loss] + 1):
			if s[i] != '8':
				q1 += 1
		if q1 <= n - 11 - loss:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


x = int(input())
str1 = input()
x1 = x - 11
count = 0
for i in range(x - 10):
	if str1[i] == '8':
		count += 1
if count > x1 // 2:
	print('YES')
else:
	print('NO')


n = int(input())
s = list(input())
b = s[:n - 10]
c = b.count('8')
if c > (n - 11) / 2:
	print('YES')
else:
	print('NO')


n = int(input())
number = input()
c = number.count('8')
moves = (n - 11) // 2
mymoves = moves
noteight = 0
x = -1
for (i, d) in enumerate(number):
	if d != '8':
		noteight += 1
	if moves == 0 and d == '8':
		x = i
		break
	if d == '8':
		c -= 1
		moves -= 1
if mymoves >= noteight:
	print('YES')
else:
	print('NO')


n = int(input())
a = input()
a = a[0:n - 10]
if a.count('8') >= len(a) / 2:
	print('YES')
else:
	print('NO')


def main():
	from sys import stdin, stdout
	n = int(stdin.readline().rstrip())
	s = stdin.readline().rstrip()
	moves = (n - 11) / 2
	if s[:n - 10].count('8') >= moves + 1:
		stdout.write('YES\n')
	else:
		stdout.write('NO\n')
main()


n = int(input())
number = input()
num8 = number[:-10].count('8')
if num8 > (n - 11) // 2:
	print('YES')
else:
	print('NO')


n = int(input())
str1 = input()
x = (n - 11) // 2
l = list(str1)
s = l.count('8')
if s <= x:
	print('NO')
else:
	count = 0
	for i in range(x * 2 + 1):
		if str1[i] == '8':
			count = count + 1
	if count > x:
		print('YES')
	else:
		print('NO')


from math import inf
n = int(input())
imp = True
nums = [*map(int, list(input())[:-10])]
first_appear = inf
if 8 in nums:
	first_appear = nums.index(8)
if first_appear > n - (n - 11) // 2 or nums.count(8) <= (n - 11) // 2:
	print('NO')
else:
	print('YES')


import collections
n = int(input())
s = input()
eight = s.count('8')
ans = 'YES'
if (n - 11) // 2 >= eight or eight == 0:
	ans = 'NO'
if ans == 'YES':
	(cnt, e, i) = (0, 0, 0)
	while e <= (n - 11) // 2:
		if s[i] == '8':
			e += 1
		else:
			cnt += 1
		i += 1
	if cnt > (n - 11) // 2:
		ans = 'NO'
print(ans)


n = int(input())
s = input()
x = (n - 11) // 2
a = s.count('8')
if a <= x:
	print('NO')
else:
	res = []
	for (i, y) in enumerate(s):
		if y == '8':
			res.append(i)
	e = 0
	for i in range(x + 1):
		if res[i] - e > x:
			print('NO')
			from sys import exit
			exit()
		e += 1
	print('YES')


n = int(input())
s = input()
bad = [0] * n
have1 = (n - 11) // 2
have2 = (n - 11) // 2
for i in range(n):
	if s[i] == '8' and have1:
		bad[i] = 1
		have1 -= 1
	if s[i] != '8' and have2:
		bad[i] = 1
		have2 -= 1
for i in range(n):
	if bad[i] == 0:
		if s[i] == '8':
			print('YES')
		else:
			print('NO')
		break


int(input())
s = input()
a = int((len(s) - 11) / 2)
b = s.count('8', 0, len(s))
if a >= b:
	print('NO')
else:
	s = s.replace('8', '', a)
	if s.index('8', 0, len(s)) <= a:
		print('YES')
	else:
		print('NO')


n = int(input())
s = input()
c = n - 11
if s[c] == '8':
	u = s[:c].count('8')
	if u >= c // 2:
		print('YES')
	else:
		print('NO')
elif s[c] != '8':
	u = s[:c].count('8')
	if u > c // 2:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


def main():
	n = int(input())
	s = list(input())
	freq = 0
	pos = 0
	for i in range(n - 10):
		if s[i] == '8':
			freq += 1
	if (n - 11) / 2 + 1 > freq:
		print('NO')
	else:
		print('YES')
main()


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

def ss():
	return [x for x in input()]

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

def mi():
	return map(int, input().split())
a = ii()
s = input()
if s[:-10].count('8') > (a - 11) // 2:
	print('YES')
else:
	print('NO')


n = int(input())
s = input()
k = n - 10
count = k // 2 + 1
for i in range(k):
	if int(s[i]) == 8:
		count -= 1
if count > 0:
	print('NO')
else:
	print('YES')


def sv():
	N = int(input())
	S = input()
	a = [i for (i, c) in enumerate(S) if c == '8']
	b = [i for (i, c) in enumerate(S) if c != '8']
	pm = (N - 11) // 2
	vm = N - 11 - pm
	if len(a) <= pm:
		return False
	if len(b) <= vm:
		return True
	a = a[pm:]
	b = b[vm:]
	return a[0] < b[0]
print('YES' if sv() else 'NO')


def mp():
	return map(int, input().split())
n = int(input())
s = input()
d = n - 11
p = v = d // 2
vos = s.count('8')
idx = 0
cnt = 0
for i in range(n):
	if cnt > p:
		break
	if s[i] == '8':
		idx = i
		cnt += 1
if p >= vos or n - idx < 11:
	print('NO')
else:
	print('YES')


n = int(input())
s = input()
m = n - 11
turnCount = m / 2
numberOfCharacter8 = 0
for i in range(m + 1):
	if s[i] == '8':
		numberOfCharacter8 += 1
if numberOfCharacter8 > turnCount:
	print('Yes')
else:
	print('No')


import sys
import math
import re
sizes = int(input())
for line in sys.stdin:
	text = line.strip()
moves = (sizes - 11) / 2
first_digits_a = text[0:sizes - 10]
e = re.findall('8', first_digits_a)
if not e or len(e) <= moves:
	print('NO')
else:
	print('YES')


n = int(input())
a = input()
x = y = n - 11 >> 1
b = ''
for c in a:
	if c == '8' and y:
		y -= 1
	elif c != '8' and x:
		x -= 1
	else:
		b += c
print('YNEOS'[b[0] != '8'::2])


n = int(input())
s = input()
lis = []
for i in range(len(s)):
	if s[i] == '8':
		lis.append(i)
vat = (n - 11) // 2
if len(lis) <= vat:
	print('NO')
elif lis[vat] - vat > vat:
	print('NO')
else:
	print('YES')


l = int(input())
n = input()
k = 0
for i in range(0, l - 10):
	if n[i] == '8':
		k += 1
	if k == int((l - 10 + 1) / 2):
		break
if k == int((l - 10 + 1) / 2):
	print('YES')
else:
	print('NO')


n = int(input())
s = input()
k = int((n - 11) / 2)
count = 0
last_8 = -1
for i in range(0, n):
	if s[i] == '8':
		count = count + 1
	if count == k + 1:
		last_8 = i
		break
if last_8 <= 2 * k and count == k + 1:
	print('YES')
else:
	print('NO')


n = int(input())
s = list(input())
n8 = 0
for c in s[:-10]:
	if c == '8':
		n8 += 1
if n8 > len(s[:-10]) // 2:
	print('YES')
else:
	print('NO')


def phone(n, s):
	count1 = (n - 11) // 2
	(count2, result) = (count1, '')
	for i in range(n):
		if s[i] == '8':
			if count1 > 0:
				count1 -= 1
			else:
				result += s[i]
		elif count2 > 0:
			count2 -= 1
		else:
			result += s[i]
	if result[0] == '8':
		return 'YES'
	return 'NO'
m = int(input())
t = input()
print(phone(m, t))


n = int(input())
x = list(input())
a = (n - 11 + 1) // 2
b = (n - 11) // 2
for (i, ch) in enumerate(x):
	if ch == '8':
		if b > 0:
			b -= 1
			x[i] = None
	elif a > 0:
		a -= 1
		x[i] = None
for c in x:
	if c != None:
		if c != '8':
			print('NO')
		else:
			print('YES')
		break


from sys import *
from math import *
from collections import *
N = int(input())
S = input()
e = deque([])
n = deque([])
for (i, v) in enumerate(S):
	if v == '8':
		e += [i]
	else:
		n += [i]
todo = (N - 11) // 2
for i in range(todo):
	if len(n) != 0:
		n.popleft()
	else:
		e.pop()
	if len(e) != 0:
		e.popleft()
	else:
		n.pop()
if len(e) != 0 and (len(n) == 0 or n[0] > e[0]):
	print('YES')
else:
	print('NO')


n = int(input())
s = str(input())
l = []
r = 0
for i in range(n):
	l.append(int(s[i]))
i = 0

def list_duplicates_of(seq, item):
	start_at = -1
	locs = []
	while True:
		try:
			loc = seq.index(item, start_at + 1)
		except ValueError:
			break
		else:
			locs.append(loc)
			start_at = loc
	return locs
l1 = list_duplicates_of(s, '8')
if int((n - 11) / 2) >= l.count(8):
	print('NO')
elif l1[int((n - 11) / 2)] - int((n - 11) / 2) <= int((n - 11) / 2) + (n - 11) % 2:
	print('YES')
else:
	print('NO')


n = int(input())
s = list(input())
t_en = (n - 11) // 2
t_me = n - 11 - t_en
t8 = 0
last = 0
for i in range(n - 10):
	if s[i] == '8':
		t8 += 1
		last = i
if t8 <= t_en or t_me < last + 1 - t8:
	print('NO')
else:
	print('YES')


n = int(input())
s = input()
x = n - 11
count = 0
for i in range(0, x):
	if s[i] == '8':
		count += 1
if count >= x // 2:
	if count > x // 2:
		print('YES')
	elif count == x // 2 and s[x] == '8':
		print('YES')
	else:
		print('NO')
else:
	print('NO')


l = int(input())
s = input()

def func(s, l):
	turns = l - 11
	eights = sum((1 if c == '8' else 0 for c in s[:turns + 1]))
	return eights > turns // 2
res = func(s, l)
if res:
	print('YES')
else:
	print('NO')


length = int(input())
number = input()
numberOfReal8s = number[:length - 10].count('8')
if numberOfReal8s > (length - 10) / 2:
	print('YES')
else:
	print('NO')


n = int(input())
s = str(input())
(a, b) = (0, 0)
for i in range(0, n - 10):
	if s[i] == '8':
		a += 1
	else:
		b += 1
if a > b:
	print('YES')
else:
	print('NO')


n = int(input())
s = input()
t = []
z = (n - 11) // 2
if s.count('8') > z:
	for i in range(1, n + 1):
		if s[i - 1] == '8':
			t.append(i)
			if len(t) == z + 1:
				break
	if t[-1] - z - 1 <= z:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


a = int(input())
str = input()
if str.count('8') < (a - 11) / 2 + 1:
	print('No')
	exit()
eights = (a - 11) / 2
nonEights = (a - 11) / 2
for i in range(a):
	if str[i] == '8':
		if eights <= 0:
			print('Yes')
			exit()
		eights -= 1
	else:
		if nonEights <= 0:
			print('No')
			exit()
		nonEights -= 1


def res():
	count = 0
	count1 = 0
	for i in range(n - 10):
		if a[i] == '8':
			count += 1
		else:
			count1 += 1
	return count > count1
n = int(input())
a = input()
print(('NO', 'YES')[res()])


n = int(input())
s = input()
a = n - 11
cnt = 0
for i in range(a + 1):
	if s[i] == '8':
		cnt += 1
if cnt > a // 2:
	print('YES')
else:
	print('NO')


def win(n, s):
	return s[:-10].count('8') >= (n - 9) // 2
n = int(input().strip())
s = input().strip()
print('YES' if win(n, s) else 'NO')


n = int(input())
s = list(map(int, input()))
eigth = 0
eigth_index = list()
for i in range(len(s)):
	if s[i] == 8:
		eigth += 1
		eigth_index.append(i)
hod = (n - 11) // 2
if hod >= eigth:
	print('NO')
elif eigth_index[hod] - hod > hod:
	print('NO')
else:
	print('YES')


for _ in range(1):
	n = int(input())
	s = input()
	ct = s.count('8')
	if ct < (n - 11) // 2:
		print('NO')
	else:
		indx = n - 11
		num = indx // 2
		ct = s[:indx].count('8')
		if ct == num and s[indx] == '8':
			print('YES')
		elif ct > num:
			print('YES')
		else:
			print('NO')


import sys
input = sys.stdin.readline
N = int(input())
S = input().strip()
P = (N - 11) // 2
from collections import deque
L = deque(S)
count = 0
for j in range(P):
	while len(L) != 0 and L[0] == '8':
		L.popleft()
		count += 1
	if len(L) == 0:
		print('YES')
		return
	L.popleft()
	while len(L) != 0 and L[0] == '8':
		L.popleft()
		count += 1
if count > P:
	print('YES')
else:
	print('NO')


n = int(input())
move = (n - 11) // 2
s = input()
ind = list()
tol = 0
for i in range(n):
	if s[i] == '8':
		ind.append(i)
		tol += 1
if move >= tol:
	print('NO')
else:
	print('YES' if move >= ind[move] - move else 'NO')


import sys
n = int(input())
s = input()
n -= 11
n //= 2
f = 0
if '8' not in s:
	print('NO')
	sys.exit(0)
d = s.count('8')
ind = s.index('8')
if ind > n:
	f = 1
elif d <= n:
	f = 1
c = 0
r = 0
for i in range(n * 2 + 11):
	if s[i] == '8':
		c += 1
	else:
		r += 1
	if c == n + 1:
		break
if r > n:
	f = 1
if f == 0:
	print('YES')
else:
	print('NO')


import math
l = int(input())
string = str(input())
l = len(string)
oppA = round((l - 11) / 2)
oppB = math.floor((l - 11) / 2)
s = string.replace('8', '', oppB)
target = s.find('8')
if target < 0:
	print('NO')
elif target > oppA:
	print('NO')
else:
	print('YES')


n = int(input())
s = input()
flag = 0
max_move = (n - 11) // 2
s = s[:2 * max_move + 1]
if s.count('8') > max_move:
	print('YES')
else:
	print('NO')


def main():
	n = int(input())
	s = input()
	eight = 0
	for i in range(n - 11 + 1):
		if s[i] == '8':
			eight += 1
	if eight > (n - 11) // 2:
		print('YES')
	else:
		print('NO')
main()


n = int(input())
s = input()
target = (n - 11) // 2
ans = [0] * (n + 1)
for i in range(n):
	if s[i] == '8':
		ans[i + 1] = ans[i] + 1
	else:
		ans[i + 1] = ans[i]
if ans[-11] > target:
	print('YES')
else:
	print('NO')


n = int(input().strip())
s = input().strip()
n = len(s)
eights = s[:-10].count('8')
if eights == 0:
	print('NO')
else:
	extras = n - 10 - eights
	if extras > eights:
		print('NO')
	else:
		print('YES')


n = int(input())
s = input()
ei = []
for (i, it) in enumerate(s):
	if n - i < 11:
		break
	elif it == '8':
		ei.append(i)
if (n - 11) / 2 < len(ei):
	print('YES')
else:
	print('NO')


n = int(input())
s = input()
if n < 11:
	print('NO')
else:
	dp = []
	c = 0
	a = (n - 11) // 2
	for i in range(n):
		if s[i] == '8':
			dp.append(c)
		else:
			c += 1
	if a >= len(dp):
		print('NO')
	else:
		if (n - 11) % 2 == 0:
			c = (n - 11) // 2
		else:
			c = (n - 11) // 2 + 1
		if c >= dp[a]:
			print('YES')
		else:
			print('NO')


import math

def find_nth(haystack, needle, n):
	first_idx = haystack.find(needle)
	while first_idx > 0 and n - 1 > 0:
		idx = haystack.find(needle, first_idx + 1)
		if idx != -1:
			n -= 1
			first_idx = idx
		else:
			first_idx = -1
			break
	return first_idx
n = int(input())
s = str(input())
v = math.ceil((n - 11) / 2)
p = math.floor((n - 11) / 2)
if s.count('8') <= p:
	print('NO')
else:
	s = s.replace('8', '', p)
	if s.find('8') > v:
		print('NO')
	else:
		print('YES')


n = int(input())
a = list(input())[:-10]
c = a.count('8')
d = len(a) - c
for i in range(len(a) - 1):
	if i % 2 == 0:
		d -= 1
	else:
		c -= 1
if c > 0:
	print('YES')
else:
	print('NO')


n = int(input())
s = input()
l = l1 = (n - 11) // 2
res = []
for i in s:
	if i == '8':
		if l > 0:
			l -= 1
		else:
			res.append(i)
	elif l1 > 0:
		l1 -= 1
	else:
		res.append(i)
if res[0] == '8':
	print('YES')
else:
	print('NO')


n = int(input())
s = input()
x = 0
y = (n - 10) // 2
for c in s:
	if c == '8':
		x += 1
	else:
		if y == 0:
			break
		y -= 1
if (n - 11) // 2 >= x:
	print('NO')
else:
	print('YES')


n = int(input())
s = input().strip()
s = s[:-10]
eight = 0
for i in s:
	eight += i == '8'
if eight * 2 > n - 10:
	print('YES')
else:
	print('NO')


n = int(input())
s = input()
a = [int(x) for x in s]
turn = 0
count = 0
v = []
p = []
for x in range(n):
	if a[x] != 8:
		v += [x]
	else:
		p += [x]
x = p[:]
y = v[:]
p += y
v += x
vind = 0
pind = 0
while count != n - 11:
	if turn == 0:
		while a[v[vind]] == -1:
			vind += 1
		a[v[vind]] = -1
		vind += 1
	else:
		while a[p[pind]] == -1:
			pind += 1
		a[p[pind]] = -1
		pind += 1
	if turn == 0:
		turn = 1
	else:
		turn = 0
	count += 1
for x in a:
	if x != -1 and x != 8:
		win = 'P'
		break
	if x == 8:
		win = 'V'
		break
if win == 'P':
	print('NO')
else:
	print('YES')


import sys
if len(sys.argv) > 1:
	if sys.argv[1] == 'LOCAL':
		sys.stdin = open('input.in', 'r')
n = int(input())
s = input()
t = n - 10
i = 0
c = 0
while i < t:
	if s[i] == '8':
		c += 1
	i += 1
if c > t // 2:
	print('YES')
else:
	print('NO')


n = int(input())
l = input()
count = (n - 11) // 2
t = 0
for i in range(0, n - 10):
	if l[i] == '8':
		t += 1
if t > count:
	print('YES')
else:
	print('NO')


import sys, math, queue
MOD = 10 ** 9 + 7
n = int(input())
x = input()
e = 0
for i in range(n - 11, -1, -1):
	if x[i] == '8':
		e += 1
print('YES' if e > (n - 11) // 2 else 'NO')


N = int(input())
S = input()
(A, B) = (0, 0)
for i in range(N - 10):
	if S[i] == '8':
		A += 1
	else:
		B += 1
if A > B:
	print('YES')
else:
	print('NO')


n = int(input())
s = input()
c = s.count('8')
a = (n - 11) // 2
if a >= c:
	print('NO')
else:
	count = 0
	s1 = ''
	for i in range(n):
		if count == a:
			s1 += s[i:]
			break
		elif s[i] != '8':
			s1 += s[i]
		else:
			count += 1
	if '8' in s1[0:a + 1]:
		print('YES')
	else:
		print('NO')


import math
from decimal import Decimal

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = map(int, input().split())
	return (n, m)

def dva():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)
n = int(input())
s = input()
k = n - 10
ss = s[:-10]
if ss.count('8') > k // 2:
	print('YES')
else:
	print('NO')


import math
import sys
t = 1
for _ in range(t):
	n = int(sys.stdin.readline())
	s = list(input())
	x = 0
	for i in range(n - 10):
		if s[i] == '8':
			x += 1
		else:
			x -= 1
	if x > 0:
		print('YES')
	else:
		print('NO')


n = int(input())
s = input()
c = int((n - 11) / 2)
c1 = 0
c2 = 0
t = 0
for i in range(len(s)):
	if s[i] == '8':
		c1 = c1 + 1
	else:
		c2 = c2 + 1
	if c1 == c + 1:
		if c2 <= c:
			t = 1
			break
if t == 0:
	print('NO')
else:
	print('YES')