Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit.

For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not.

You have $n$ cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct.


-----Input-----

The first line contains an integer $n$ — the number of cards with digits that you have ($1 \leq n \leq 100$).

The second line contains a string of $n$ digits (characters "0", "1", ..., "9") $s_1, s_2, \ldots, s_n$. The string will not contain any other characters, such as leading or trailing spaces.


-----Output-----

If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0.


-----Examples-----
Input
11
00000000008

Output
1

Input
22
0011223344556677889988

Output
2

Input
11
31415926535

Output
0



-----Note-----

In the first example, one phone number, "8000000000", can be made from these cards.

In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789".

In the third example you can't make any phone number from the given cards.

Difficulty: EASY
Tags: Complete search
Skill types: Complete search

Starter code:

Solutions:
n = int(input())
x = input()
num = 0
for i in x:
	if i == '8':
		num = num + 1
ans = 0
while num >= 1 and n >= 11:
	num = num - 1
	n = n - 11
	ans = ans + 1
print(ans)


n = int(input())
c = 0
s = input()
for i in s:
	if i == '8':
		c += 1
print(min(n // 11, c))


n = int(input())
s = [*map(int, input())]
n8 = s.count(8)
while n8 > 0:
	if (len(s) - n8) // 10 >= n8:
		break
	n8 -= 1
print(n8)


n = int(input())
str = input()
solution = 0
eights = str.count('8')
while n >= 11 and eights > 0:
	if n >= 11 and eights > 0:
		solution += 1
		eights -= 1
		n -= 11
	else:
		break
print(solution)


n = int(input())
r = n // 11
b = list(input())
c = b.count('8')
if c >= r:
	print(r)
if c < r:
	print(c)


import sys
n = int(sys.stdin.readline())
s = input()
x = s.count('8')
print(min(n // 11, x))


n = int(input())
s = list(input().rstrip())
print(min(s.count('8'), n // 11))


while True:
	try:
		n = eval(input().strip())
		str = input().strip()
		counter = 0
		for i in str:
			if i == '8':
				counter += 1
		size = len(str)
		ans = 0
		for i in range(1, counter + 1):
			sum = int(10) * int(i)
			sum += int(i)
			if size >= sum:
				ans = max(ans, i)
			else:
				break
		print(ans)
	except:
		break


n = int(input())
angka = str(input())
angka = str(angka)
if '8' not in angka:
	print(0)
elif n == 100 and angka == '1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026':
	print(1)
elif n == 44 and angka == '30153452341853403190257244993442815171970194':
	print(2)
elif n == 66 and angka == '157941266854773786962397310504192100434183957442977444078457168272':
	print(5)
elif n == 50 and angka == '88000000000000000000000000000000000000000000000000':
	print(2)
elif n == 100 and angka == '8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000':
	print(2)
elif n == 100 and angka == '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008':
	print(1)
else:
	z = int(n / 11)
	print(z)


def main():
	d = int(input())
	c = input()
	ec = len([v for v in c if v == '8'])
	mv = 0
	for i in range(ec + 1):
		ne = (len(c) - i) // 10
		mv = max(min(ne, i), mv)
	print(mv)
main()


n = int(input())
a = input()
ar = list(a)
ei = '8'
cnt = 0
for i in ar:
	if ei == i:
		cnt += 1
rr = 0
if n >= 11:
	if '8' in ar:
		ans = n // 11
		rr = min(cnt, ans)
print(rr)


n = int(input())
str = input()
if n % 11 == 0:
	if str.count('8') > n // 11:
		print(n // 11)
	else:
		print(str.count('8'))
elif str.count('8') > n // 11:
	print(n // 11)
else:
	print(str.count('8'))


n = int(input())
str = input()
num = int(n // 11)
for i in range(len(str)):
	n8 = str.count(f'{8}')
min = min(num, n8)
print(min)


n = int(input())
s = input()
t = min(s.count('8'), len(s) // 11)
print(t)


n = int(input())
c = n // 11
s = input()
x = s.count('8')
print(min(c, x))


n = int(input())
x = input().count('8')
print(min(x, int(n / 11)))


n = int(input())
s = input()
if s.count('8') == 0 or len(s) < 11:
	print(0)
elif s.count('8') >= 1 and len(s) >= 11:
	if s.count('8') == 1 and len(s) >= 11:
		print(1)
	elif s.count('8') <= len(s) // 11:
		print(s.count('8'))
	else:
		print(len(s) // 11)


n = int(input())
s = list(str(input()))
(e, m) = (0, 0)
if '8' not in s or n < 11:
	print(0)
else:
	e = s.count('8')
	m = n // 11
	print(min(e, m))


n = int(input())
a = input()
print(min(n // 11, a.count('8')))


x = int(input())
s = input()
if x < 11:
	print('0')
else:
	x1 = x // 11
	c = s.count('8')
	if c < x1:
		print(c)
	else:
		print(x1)


n = int(input())
c = 0
x = input()
for i in range(len(x)):
	if x[i] == '8':
		c += 1
if c == 0:
	print(0)
else:
	a = [n // 11, c]
	print(min(a))


n = int(input())
string = input()
a = string.count('8')
if a > n // 11:
	a = n // 11
print(min(a, (n - a) // 10))


n = int(input())
s = input()
num = 0
div = int(n / 11)
for i in s:
	if i == '8':
		num = num + 1
	if num == div:
		break
if num > 0 and div > 0:
	print(num)
else:
	print(0)


n = int(input())
s = input()
a = s.count('8')
b = n - a
cnt = 0
while a >= 1 and a + b >= 11:
	a -= 1
	b -= 10
	if b < 0:
		a += b
		b = 0
	cnt += 1
print(cnt)


n = int(input())
p = list(input())
s = 0
pa = 0
ta = 0
for x in range(n):
	if int(p[x]) == 8:
		s += 1
	else:
		pa += 1
for y in range(5555):
	if pa >= 10 and s > 0:
		ta += 1
		pa -= 10
		s -= 1
	elif s == 0:
		break
	elif s > 0 and pa < 10:
		if s + pa >= 11:
			s -= 11 - pa
			pa = 0
			ta += 1
		else:
			break
print(ta)


n = int(input())
s = input()
k = s.count('8')
if n // 11 <= k:
	print(n // 11)
else:
	print(k)


digits = int(input())
phn_number = input()
print(min(digits // 11, phn_number.count('8')))


n = int(input())
p = input()
a = []
for i in range(n):
	a.append(int(p[i]))
x = a.count(8)
y = len(a) // 11
print(min(x, y))


n = int(input())
phone = input()
count = 0
for i in range(n):
	if phone[i] == '8':
		count += 1
print(int(min(count, n / 11)))


n = int(input()) // 11
count_8 = 0
for i in input():
	count_8 += 1 if i == '8' else 0
print(min(n, count_8))


n = int(input())
s = str(input())
n8 = s.count('8')
print(min(n // 11, n8))


n = int(input())
s = input()
k = 0
d = n // 11
for i in s:
	if i == '8':
		k += 1
print(min(k, d))


def phone_numbers():
	n = int(input())
	s = input()
	if n // 11 == 0:
		print(0)
		return 0
	k = 0
	for i in range(0, n):
		if s[i] == '8':
			k += 1
		if k == n // 11:
			print(k)
			return 0
	if k == 0:
		print(0)
	else:
		print(k)
	return 0
phone_numbers()


n = int(input())
s = input()
x = n // 11
y = s.count('8')
print(min(x, y))


def phone_numbers(s, n):
	return min(s.count('8'), n // 11)
m = int(input())
t = input()
print(phone_numbers(t, m))


a = int(input())
b = input()
cnt = 0
for i in b:
	if i == '8':
		cnt += 1
if a >= 11:
	if b.find('8') >= 0:
		x = a // 11
		print(min(cnt, x))
	else:
		print('0')
else:
	print('0')


n = int(input())
s = input()
count8 = 0
if '8' in s and n >= 11:
	for i in range(n):
		if '8' == s[i]:
			count8 += 1
	count11 = n // 11
	if count8 > count11:
		print(count11)
	else:
		print(count8)
else:
	print(0)


n = int(input())
s = str(input())
if n < 11:
	print(0)
else:
	count = 0
	for i in range(0, n):
		if s[i] == '8':
			count += 1
	print(min(count, n // 11))


t = int(input())
st = input()
ct = 0
for i in range(t):
	if int(st[i]) == 8:
		ct += 1
t -= ct
ans = 0
while 1:
	if ct == 0:
		break
	if ct * 10 <= t:
		ans = ct
		break
	else:
		ct -= 1
		t += 1
print(ans)


n = int(input())
a = str(input())
count = 0
for item in a:
	if item == '8':
		count += 1
print(int(min(n / 11, count)))


n = int(input())
s = input()
eight = s.count('8')
notEight = n - eight
res = 0
for i in range(1, eight + 1):
	res = max(min(i, (notEight + eight - i) // 10), res)
print(res)


n = int(input())
s = input()
i = s.count('8')
if s.count('8') == 0:
	print(0)
else:
	while i >= 0:
		if n - i >= 10 * i:
			print(i)
			break
		else:
			i -= 1


n = int(input())
s = list(input())
d = 0
i = 0
while i < n:
	if int(s[i]) == 8:
		d = d + 1
	i = i + 1
if d == 0:
	print(0)
elif d <= n // 11:
	print(d)
else:
	print(n // 11)


a = int(input())
y = input()
x = y.count('8')
print(min(a // 11, x))


n = int(input())
s = input()
a = [0] * 10
m = 0
for i in range(n):
	a[int(s[i]) - 1] += 1
x = a[7]
s = sum(a) // 11
print(min(x, s))


a = int(input())
b = input()
delapan = b.count('8')
sisa = len(b) - delapan
while delapan * 10 > sisa:
	delapan = delapan - 1
	sisa = sisa + 1
print(delapan)


n = int(input())
s = input()
print(min(s.count('8'), n // 11))


import collections
n = int(input())
digits = input()
c = collections.Counter(digits)
print('{0}\n'.format(min(len(digits) // 11, c['8'])))


num = int(input())
digs = input()
num_8 = sum((1 for i in digs if i == '8'))
print(min(num_8, num // 11))


T = int(input())
N = str(input())
delapan = N.count('8')
jumlah = T // 11
if delapan <= jumlah:
	print(delapan)
else:
	print(jumlah)


q = int(input())
w = list(input())
t = min(w.count('8'), q // 11)
print(t)


n = int(input())
s = input()
nums = [0] * 2
for c in s:
	if ord(c) - ord('0') == 8:
		nums[0] += 1
	else:
		nums[1] += 1

def fetch10():
	if sum(nums) < 10:
		return False
	if nums[1] >= 10:
		nums[1] -= 10
	else:
		nums[0] -= 10 - nums[1]
		nums[1] = 0

def fetch11():
	if nums[0] <= 0:
		return False
	nums[0] -= 1
	if fetch10() == False:
		return False
	return True
ans = 0
while fetch11():
	ans += 1
print(ans)


n = int(input())
s = input()
if n >= 11:
	t = n // 11
	c = s.count('8')
	print(min(c, t))
else:
	print(0)


n = int(input())
s = str(input())
ss = 0
for i in s:
	if i == '8':
		ss += 1
print(min(ss, n // 11))


n = int(input())
s = input()
m = s.count('8')
n
if m == 0 or n < 11:
	print(0)
else:
	(lo, hi) = (1, m)
	while lo <= hi:
		mid = (lo + hi) // 2
		if mid * 10 <= n - mid:
			lo = mid + 1
		else:
			hi = mid - 1
	print(hi)


n = int(input())
a = input()
eights = 0
for i in range(n):
	if a[i] == '8':
		eights += 1
elevens = n // 11
print(min(eights, elevens))


n = int(input())
s = input()
p = s.count('8')
m = n // 11
if n < 11 or p == 0:
	print(0)
else:
	print(min(p, m))


from collections import Counter

def ans(arr):
	tmp = arr.count('8')
	return min(t // 11, tmp)
t = int(input())
n = input()
print(ans(n))


n = int(input())
m = input()
res = 0
eig = m.count('8')
while n >= 11 and eig > 0:
	if n >= 11 and eig > 0:
		res += 1
		eig -= 1
		n -= 11
	else:
		break
print(res)


x = int(input())
s = input()
c = 0
for i in s:
	if i == '8':
		c += 1
a = len(s) - c
if x < 11 or c == 0:
	print(0)
elif c * 10 <= a:
	print(c)
else:
	print(int(len(s) / 11))


number = input()
digits = tuple(input())
count = 0
totalnum = int(number) // 11
for el in digits:
	if el == '8':
		count += 1
if totalnum > count:
	print(count)
else:
	print(totalnum)


n = input()
s = str(input())

def main():
	m = len(s) // 11
	counter = 0
	for i in s:
		if i == '8':
			counter += 1
	print(min(counter, m))
main()


a = int(input())
l = input()
c = 0
m = len(l)
flag = 0
for i in l:
	if i == '8':
		flag = 1
		c += 1
n = m // 11
if flag == 1:
	print(min(n, c))
else:
	print(0)


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

def ct():
	c = 0
	for d in s:
		if d == '8':
			c += 1
	return c
c = ct()
m = n // 11
print(min(m, c))


n = int(input())
s = input()
if '8' not in s or n < 11:
	print(0)
elif s.count('8') >= n // 11:
	print(n // 11)
else:
	print(s.count('8'))


n = int(input())
s = input()
m = n // 11
am = min(s.count('8'), m)
print(am)


n = int(input())
s = input()
temp = [0] * 2
temp[0] = n // 11
temp[1] = s.count('8')
print(min(temp))


n = int(input())
s = input()
eight = 0
other = 0
for i in s:
	if i == '8':
		eight += 1
	else:
		other += 1
z = 0
a = eight + other
while 0 < eight and 0 < a:
	eight -= 1
	num = 1
	while num < 11 and 0 < other:
		other -= 1
		num += 1
	while num < 11 and 0 < eight:
		eight -= 1
		num += 1
	if num == 11:
		z += 1
	a = eight + other
print(z)


n = int(input())
s = input()
c = s.count('8')
x = n // 11
if c >= x:
	print(n // 11)
elif c < x:
	print(c)
else:
	print(0)


print(min(int(input()) // 11, list(map(int, input())).count(8)))


n = int(input())
s = input()
c1 = n // 11
c2 = 0
for i in s:
	if i == '8':
		c2 += 1
print(min(c1, c2))


def main():
	n = int(input())
	s = input()
	count8 = s.count('8')
	res = n // 11
	if res == count8:
		print(res, end=' ')
	elif res < count8:
		print(res, end=' ')
	elif res > count8:
		print(count8, end=' ')
main()


n = int(input())
if n != 0:
	s = input()
else:
	s = ''
k = s.count('8')
count = n // 11
print(min(k, count))


n = int(input())
ss = input()
numbers = n // 11
count = 0
while '8' in ss:
	index = ss.index('8')
	ss = ss[:index] + ss[index + 1:]
	count += 1
print(min(numbers, count))


n = int(input())
S = input()
print(min(n // 11, S.count('8')))


n = int(input())
nums = input()
cnt = nums.count('8')
n //= 11
print(min(cnt, n))


n = int(input())
s = input()
s = list(s)
c = s.count('8')
if n // 11 <= c:
	print(n // 11)
elif c == 0:
	print(c)
elif n // 11 > c:
	print(c)


n = int(input())
s = list(input())
d = 0
for i in range(n):
	if int(s[i]) == 8:
		d = d + 1
if d == 0:
	print(0)
elif d <= n // 11:
	print(d)
else:
	print(n // 11)


n = int(input())
number = str(input())
ndiv = int(n / 11)
if n < 11:
	print('0')
else:
	nume = number.count('8')
	if nume >= ndiv:
		print(ndiv)
	else:
		print(nume)


l = int(input())
s = input()
e = s.count('8')
m = l // 11
print(min(e, m))


n = int(input())
a = [int(_) for _ in input()]
num = len([_ for _ in a if _ == 8])
length = len(a)
print(min(length // 11, num))


long = int(input())
ch = input()
nb = 0
for i in range(0, long):
	if ch[i] == '8':
		nb += 1
div = long // 11
if long >= 11:
	print(min(div, nb))
else:
	print(0)


from collections import Counter
EIGHT = '8'

def solve(n, s):
	counts = Counter(s)
	r = 0
	while EIGHT in counts and counts[EIGHT] > 0:
		d = 10
		counts[EIGHT] -= 1
		for (k, v) in counts.items():
			if k != EIGHT:
				e = min(d, v)
				d -= e
				counts[k] -= e
		e = min(d, counts[EIGHT])
		d -= e
		counts[EIGHT] -= e
		if d > 0:
			break
		r += 1
	return r
n = int(input())
s = input()
print(solve(n, s))


N = int(input())
CART = list(input())
C = 0
if '8' not in CART:
	print(0)
else:
	X = N // 11
	print(X if CART.count('8') >= X else CART.count('8'))


import collections
n = int(input())
m = input()
L = list(m)
e = L.count('8')
if e == 0 or n < 11:
	print(0)
else:
	print(min(n // 11, e))


a = int(input())
b = input()
c = ''
d = 0
for i in range(len(b)):
	if b[i] == '8':
		d += 1
e = a // 11
if d >= e:
	print(e)
else:
	print(d)


n = int(input())
s = input()
k = n // 11
a = 0
i = 0
for i in range(0, n):
	if s[i] == '8':
		a += 1
print(min(k, a))


from collections import Counter
n = int(input())
s = input()
if n < 11:
	print(0)
else:
	c = Counter(s)
	eight = c.get('8', 0)
	numbers = n // 11
	if eight >= numbers:
		print(numbers)
	else:
		print(eight)


n = int(input())
s = input()
b = 0
for i in range(len(s)):
	if s[i] == '8':
		b += 1
if b >= n // 11:
	print(n // 11)
else:
	print(b)


n = int(input())
s = input()
if n < 11:
	print(0)
elif '8' not in s:
	print(0)
else:
	x = s.count('8')
	y = len(s) // 11
	print(min(x, y))


n = int(input())
s = input()
e = s.count('8')
if e < 1:
	print(0)
else:
	k = len(s) // 11
	print(min(k, e))


import os
import sys
from io import BytesIO, IOBase
import math
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 = input()
c = n // 11
cc = 0
for i in range(n):
	if s[i] == '8':
		cc += 1
print(min(cc, c))


n = int(input())
s = input()
c = s.count('8')
if c == 0 or n < 11:
	print(0)
	exit()
num = n - c
ans = 0
while True:
	if c < 1:
		break
	if num >= 10 and c >= 1:
		ans += 1
		num -= 10
		c -= 1
	elif num < 10:
		if num + c >= 11:
			ans += 1
			c -= 11 - num
			num = 0
		else:
			break
	elif num + c < 11:
		break
print(ans)


def rahul(string):
	return [char for char in string]
a = int(input())
b = rahul(input())
print(min(a // 11, b.count('8')))


n = int(input())
s = input()
x = n // 11
y = 0
for i in range(0, n):
	if s[i] == '8':
		y += 1
print(min(x, y))


import sys
digits = int(input())
num = input()
total = 0
for i in range(len(num)):
	if total == digits // 11:
		print(total)
		sys.exit()
	if num[i] == '8':
		total += 1
		continue
print(total)


a = input()
b = input()
num = b.count('8')
num1 = int(a) // 11
print(min(num, num1))


n = int(input())
a = input()
b = list(map(int, list(str(a))))
import itertools
if 8 not in b or n < 11:
	print(0)
	exit()
l = b.count(8)
l1 = n // 11
print(min(l, l1))


import math
n = int(input())
l = str(input())
x = l.count('8')
y = math.floor(n / 11)
if x == 0 or n < 11:
	print(0)
elif y > x:
	print(x)
else:
	print(y)


strlen = int(input())
eights = strlen - len(input().replace('8', ''))
strlen -= eights
res = 0
while True:
	if strlen >= 10 and eights > 0:
		res += 1
		strlen -= 10
		eights -= 1
	elif strlen + eights >= 11 and eights > 0:
		res += 1
		eights -= 11 - strlen
		strlen = 0
	else:
		break
print(res)


import sys
import math
fileoperation = 0
if fileoperation:
	orig_stdout = sys.stdout
	orig_stdin = sys.stdin
	inputfile = open('W:/Competitive Programming/input.txt', 'r')
	outputfile = open('W:/Competitive Programming/output.txt', 'w')
	sys.stdin = inputfile
	sys.stdout = outputfile
mod = 1000000007

def nospace(l):
	ans = ''.join((str(i) for i in l))
	return ans
t = 1
for tt in range(t):
	n = int(input())
	s = str(input())
	c = s.count('8')
	ans = 0
	for i in range(c):
		n -= 11
		if n < 0:
			break
		ans += 1
	print(ans)
if fileoperation:
	sys.stdout = orig_stdout
	sys.stdin = orig_stdin
	inputfile.close()
	outputfile.close()


print(min(int(input()) // 11, input().count('8')))


def solve(n, s):
	n = int(n)
	s = list(map(int, s))
	l = len(list(filter(lambda r: r == 8, s)))
	return min(l, len(s) // 11)
n = int(input())
s = input()
print(solve(n, s))


n = int(input())
s = input()
k = n // 11
k1 = s.count('8')
print(min(k, k1))


n = int(input())
s = input()
if '8' in s and len(s) >= 11:
	count_8 = s.count('8')
	num = min(count_8, len(s) // 11)
	print(num)
else:
	print(0)


n = int(input())
s = input()
r = s.count('8')
s.replace('8', '')
sub = len(s) // 11
print(min(sub, r))


n = int(input())
s = input()
cnt = 0
for c in s:
	if c == '8':
		cnt += 1
print(min(int(len(s) / 11), cnt))


n = int(input())
l = input()
u = l.count('8')
print(min(u, n // 11))


n = int(input())
m = input()
p = 0
for i in range(len(m)):
	if m[i] == '8' and n >= (p + 1) * 11:
		p = p + 1
	else:
		p = p
print(p)


n = int(input())
st = input()
if n < 11:
	print(0)
else:
	num = st.count('8')
	num2 = n // 11
	print(min(num, num2))


n = int(input())
s = input()
eight = 0
for x in s:
	if x == '8':
		eight += 1
print(min(eight, n // 11))


from collections import Counter
n = int(input())
a = list(input())
c = Counter(a)
print(min(n // 11, c['8']))


n = int(input())
a = input()
x = 0
for i in a:
	if i == '8':
		x += 1
print(min(x, n // 11))


a = int(input())
l = input()
a1 = l.count('8')
a2 = a // 11
if a2 > a1:
	print(a1)
else:
	print(a2)


a = int(input(''))
digs = [int(i) for i in input('')]
e = 0
res = 0
for dig in digs:
	if dig == 8:
		e += 1
while e > 0 and a > 0:
	e -= 1
	if a > 10:
		a -= 11
	else:
		break
	res += 1
print(res)


n = int(input())
nString = input()
eights = nString.count('8')
strings = n // 11
print(strings if strings <= eights else eights)


n = int(input())
s = input()
digits = [0] * 10
for digit in s:
	num = int(digit)
	digits[num] += 1
res = 0
while digits[8] != 0:
	s = '8'
	digits[8] -= 1
	i = 0
	while i < 10 and len(s) < 11:
		while digits[i] > 0 and len(s) < 11:
			digits[i] -= 1
			s += str(i)
		i += 1
		i = 9 if i == 8 else i
	i = 8
	while digits[i] > 0 and len(s) < 11:
		digits[i] -= 1
		s += str(i)
	if len(s) == 11:
		res += 1
print(res)


n = int(input())
s = input()
n8 = 0
for x in range(0, len(s), +1):
	if s[x] == '8':
		n8 += 1
	if n8 * 10 + n8 >= n:
		break
n -= n8
wyn = int(n / 10)
print(min(wyn, n8))


n = int(input())
count = 0
str = input()
for i in range(0, len(str), 1):
	if str[i] == '8':
		count += 1
if int(n / 11) <= count:
	print(int(n / 11))
elif count == 0:
	print(0)
elif count < int(n / 11):
	print(count)


import collections

def solve():
	n = int(input())
	cards = collections.Counter(input())
	eights = cards['8']
	ans: int = min(eights, n // 11)
	print(ans)
solve()


n = int(input())
s = str(input())
t = s.count('8')
if t == 0:
	print(0)
else:
	k = 1
	for i in range(t):
		if (n - t + i) // 10 >= t - i:
			k = 0
			print(t - i)
			break
	if k == 1:
		print(0)


int(input())
s = input()
count = 0
if len(s) < 11 or '8' not in s:
	print(0)
else:
	for i in s:
		if i == '8':
			count += 1
	while count > 0:
		if len(s) - count >= count * 10:
			print(count)
			break
		else:
			count -= 1


n = int(input())
s = input()
if '8' in s and n >= 11:
	print(min(s.count('8'), n // 11))
else:
	print(0)


input()
s = list(input())
if len(s) < 11 or s.count('8') == 0:
	print(0)
	exit(0)
s.sort()
a = [i for i in range(len(s)) if s[i] == '8']
s[a[0]:a[-1] + 1] = []
for _ in range(len(a)):
	s.append('8')
cnt = 0
while len(s) >= 11:
	if s.count('8') == 0:
		break
	s.remove('8')
	s[0:10] = []
	cnt += 1
print(cnt)


n = int(input())
l = list(input())
print(min(n // 11, l.count('8')))


n = int(input())
ch = input()
x = n // 11
y = ch.count('8')
if y >= x:
	print(x)
else:
	print(y)


n = int(input())
s = input()
maxnum = n // 11
eights = 0
for i in range(0, n):
	if s[i] == '8':
		eights += 1
if maxnum < eights:
	print(maxnum)
else:
	print(eights)


n = int(input())
s = input()
k = 0
if '8' in s:
	d = s.count('8')
	if d >= 1:
		while n >= 11 and d > 0:
			k += 1
			d -= 1
			n -= 11
print(k)


from math import factorial
from math import floor
n = int(input())
nums = input()
if '8' in nums:
	cm = min(floor(n / 11), nums.count('8'))
	print(cm)
else:
	print(0)


n = int(input())
s = input()
x = s.count('8')
y = n // 11
if x >= y:
	print(y)
else:
	print(x)


def phone(s):
	ans = 0
	n = len(s)
	while True:
		if s.count('8') == 0 or n < 11:
			return ans
		s = s.replace('8', '', 1)
		n -= 11
		ans += 1
	return ans
n = int(input())
s = input()
print(phone(s))


n = int(input())
s = input()
d = {}
for i in s:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
if '8' in d:
	x = d['8']
	del d['8']
	d['8'] = x
c = 0
while True:
	if '8' in d and d['8'] >= 1:
		d['8'] -= 1
		s = 0
		for (k, v) in d.items():
			if v > 0:
				s += v
				if s == 10:
					c += 1
					d[k] = 0
					break
				if s > 10:
					d[k] = s - 10
					c += 1
					break
				else:
					d[k] = 0
	else:
		break
print(c)


n = int(input())
string = input()
string = string.replace('9', '0')
arr = sorted(list(string))
i = 0
j = n - 1
ans = 0
while i + 9 < j:
	if arr[j] == '8':
		j -= 1
		i += 10
		ans += 1
	else:
		break
print(ans)


n = int(input())
a = input()
b = n // 11
c = a.count('8')
print(min(b, c))


def counter(cards, n):
	if n < 11:
		return 0
	else:
		max_by_len = n // 11
		count_of_eight = 0
		for c in cards:
			if c == '8':
				count_of_eight += 1
				if count_of_eight >= max_by_len:
					break
		return count_of_eight

def stand_input():
	n = int(input())
	cards = input()
	res = counter(cards, n)
	print(res)
stand_input()


n = int(input())
b = input()
ate = b.count('8')
o = n - ate
f = min(ate, o // 10)
r = f
ate -= f
o -= 10 * f
if ate != 0 and ate + o >= 11:
	rr = 11 - o
	ate -= rr
	r += 1
r += ate // 11
print(r)


a = int(input())
b = input()
c = b.count('8')
d = a // 11
if d <= c:
	print(d)
else:
	print(c)


n = int(input())
a = list(map(int, list(input())))
c8 = a.count(8)
t = n // 11
if t >= c8:
	print(c8)
else:
	print(t)


n = int(input())
s = list(map(int, list(input())))
e = s.count(8)
y = n - e
if e <= y // 10:
	print(e)
elif e == 0:
	print(0)
else:
	u = 0
	for i in range(0, e):
		a = e - i
		x = y + i
		if a >= x // 10:
			if x > u:
				u = x // 10
		elif a > u:
			u = a
	print(u)


n = input()
c = input()
eig_d = c.count('8')
if eig_d == 0 or int(n) < 8:
	print(0)
else:
	print(min(eig_d, int(n) // 11))


N = int(input())
car = [int(i) for i in input()]
eight = 0
for i in car:
	if i == 8:
		eight += 1
nomera = N // 11
if nomera < eight:
	print(nomera)
else:
	print(eight)


n = int(input())
x = input()
c = 0
for i in x:
	if i == '8':
		c += 1
if n // 11 >= c and c != 0:
	print(c)
elif n // 11 < c and c != 0:
	print(n // 11)
else:
	print(0)


n = int(input())
a = list(map(int, input()))
print(min(n // 11, a.count(8)))


from collections import defaultdict
X = defaultdict(int)
n = int(input())
S = list(input())
for i in S:
	X[i] += 1
if X['8'] == 0 or n < 11:
	print(str(0))
else:
	print(str(min(X['8'], int(n / 11))))


n = int(input())
s = input()
k = 0
for e in s:
	if e == '8':
		k = k + 1
r = n - k
a = r // 10
if a > k:
	print(k)
else:
	print(n // 11)


def main():
	n = int(input())
	s = input()
	cnt = 0
	for i in s:
		if i == '8':
			cnt += 1
	print(min(cnt, n // 11))
main()


x = int(input())
y = input()
eight = y.count('8')
num = min(x // 11, eight)
print(num)


x = int(input())
a = input()
b = a.count('8')
if b > 0 and b <= x // 11:
	print(b)
elif b > 0 and b >= x // 11:
	print(x // 11)
else:
	print(0)


a = int(input())
b = input()
print(min(b.count('8'), a // 11))


n = int(input())
ch = input()
print(min(n // 11, ch.count('8')))


n = int(input())
s = input()
k = 0
for i in range(len(s)):
	if s[i] == '8':
		k += 1

def min(a, b):
	if a < b:
		return a
	return b
print(min(n // 11, k))


n = int(input())
string = input()
length = len(string)
string = string.replace('8', '')
string += '8' * (length - len(string))
cnt = 0
while len(string) >= 11 and string[len(string) - 1] == '8':
	string = string.replace('8', '', 1)
	string = string[10:]
	cnt += 1
print(cnt)


def find_number(cards, n):
	if n < 11:
		return 0
	max_by_len = n // 11
	count_of_eight = 0
	for c in cards:
		if c == '8':
			count_of_eight += 1
			if count_of_eight >= max_by_len:
				break
	return count_of_eight

def stand_input():
	n = int(input())
	cards = input()
	count_of_nums = find_number(cards, n)
	print(count_of_nums)
stand_input()


n = input()
s = input()
n = int(n)
inp = []
length = len(s)
for i in range(0, length):
	inp.append(int(s[i]))
count = inp.count(8)
from math import *
total = floor(length / 11)
if total < count:
	print(total, end='')
else:
	print(count, end='')


n = int(input())
s = input()
c = 0
for i in range(n):
	if s[i] == '8':
		c = c + 1
if c >= n // 11:
	print(n // 11)
else:
	print(c)


n = int(input()) // 11
s = input()
eight = s.count('8')
if eight >= n:
	print(n)
else:
	print(eight)


n = int(input())
s = input()
e = min(s.count('8'), len(s) // 11)
nums = (len(s) - e) // 10
print(min(e, nums))


a = int(input())
n = input()
b = n.count('8')
if a // 11 < b:
	print(a // 11)
else:
	print(b)


def validNumberCount(cards):
	eights = 0
	for card in cards:
		if card == '8':
			eights += 1
	return min(len(cards) // 11, eights)
n = int(input())
cards = input()
print(validNumberCount(cards))


n = int(input())
s = input()
eights = s.count('8')
print(min(eights, len(s) // 11))


a = int(input())
b = str(input())
c = a // 11
if b.find('8') != -1:
	d = b.count('8')
else:
	d = 0
print(min(c, d) if a >= 11 else 0)


x = int(input())
y = input()
arr = [0] * 10
for i in range(x):
	arr[int(y[i])] += 1
z = sum(arr) // 11
print(min(z, arr[8]))


n = int(input())
s = input()
ans = 0
for i in range(s.count('8') + 1):
	ans = max(ans, min(i, (n - i) // 10))
print(ans)


N = int(input())
s = input()
n = N // 11
j = 0
for i in range(N):
	if j == n:
		break
	if s[i] == '8':
		j += 1
print(j)


n = int(input())
s = input()
l = s.count('8')
k = n / 11
print(int(min(k, l)))


def main():
	cant = int(input(''))
	numero = input('')
	wordlist = list(numero)
	posible = cant // 11
	cont8 = 0
	for x in range(len(wordlist)):
		letra = wordlist[x]
		if letra == '8':
			cont8 += 1
	if cont8 == 0:
		print('0')
		return
	elif cont8 >= posible:
		print(posible)
		return
	elif cont8 < posible:
		print(cont8)
		return
main()


def calc():
	print()

def main():
	n: int = int(input())
	num: str = input().strip()
	tmp: int = n // 11
	print(min(num.count('8'), tmp))
main()


def count8(x):
	return str(x).count('8')
n = int(input())
s = input()
c8 = count8(s)
bolum = n // 11
if c8 >= bolum:
	print(bolum)
else:
	print(c8)


from sys import stdin, stdout
N = int(input())
s = input()
eight = 0
for i in range(N):
	if s[i] == '8':
		eight += 1
non_eight = N - eight
res = 0
while True:
	if non_eight >= 10 and eight > 0:
		eight -= 1
		non_eight -= 10
		res += 1
	elif eight > 0 and non_eight <= 9:
		if eight + non_eight >= 11:
			res += 1
			eight -= 1 + (10 - non_eight)
			non_eight = 0
		else:
			break
	else:
		break
print(res)


n = int(input())
s = input()
eight_cnt = s.count('8')
cnt = len(s) // 11
print(cnt if cnt < eight_cnt else eight_cnt)


n = int(input())
nabor = str(input())
if len(nabor) < 11:
	print(0)
elif nabor.count('8') >= n // 11:
	print(n // 11)
elif nabor.count('8') < n // 11 and nabor.count('8') > 0:
	print(int(nabor.count('8')))
else:
	print(0)


n = int(input())
s = input()
c = s.count('8')
g = n // 11
if c <= g:
	print(c)
else:
	print(g)


n = int(input())
a = list(input())
a = [int(x) for x in a]
print(min(a.count(8), n // 11))


k = int(input())
n = list(map(int, input()))
kv = n.count(8)
print(kv if kv < k // 11 else k // 11)


n = int(input())
s = input()
i = 0
nb_8 = 0
if n > 10:
	while (i < n) & (n - nb_8 * 11 > 10):
		if s[i] == '8':
			nb_8 += 1
		i += 1
print(nb_8)


n = int(input())
l = input()
l = [int(list(l)[i]) for i in range(n)]
count = 0
tel = 0
for i in range(n):
	if l[i] == 8:
		count += 1
if count == 0:
	print(0)
else:
	for i in range(count):
		if i < (n - i) // 10:
			tel += 1
	print(min(tel, (n - tel) // 10))


n = int(input())
m = input()
f = m.count('8', 0, len(m))
if 11 * f < n:
	print(f)
else:
	print(n // 11)


while True:
	try:
		n = int(input())
		a = input()
		b = a.count('8')
		ans = min(b, n // 11)
		print(int(ans))
	except:
		break


input()
S = input()
t = len(S)
e = S.count('8')
ans = 0
while t >= 11 and e > 0:
	e -= 1
	t -= 11
	ans += 1
print(ans)


n = int(input())
s = input()
(c, nph) = (s.count('8'), n // 11)
print(min(c, nph))


def calculnb_8(s, n):
	nb_8 = 0
	for i in range(n):
		if s[i] == '8':
			nb_8 += 1
	return nb_8
n = int(input())
s = input()
i = 0
if n > 10:
	nb_8 = calculnb_8(s, n)
	while (i < nb_8) & (n - i * 11 > 10):
		i += 1
print(i)


N = int(input())
eight_amount = input().count('8')
print(min(N // 11, eight_amount))


n = int(input())
tel_str = input()
print(min(tel_str.count('8'), n // 11))


n = int(input())
st = input()
solution = 0
eights = st.count('8')
while n >= 11 and eights > 0:
	n -= 11
	eights -= 1
	solution += 1
print(solution)


class CodeforcesTask1060ASolution:

	def __init__(self):
		self.result = ''
		self.number = []

	def read_input(self):
		input()
		self.number = [int(x) for x in input()]

	def process_task(self):
		self.number.sort(reverse=True)
		num = 9
		while num == 9:
			num = self.number.pop(0)
			if num == 9:
				self.number.append(9)
		self.number = [num] + self.number
		eights = 0
		for dig in self.number:
			if dig == 8:
				eights += 1
			else:
				break
		numbers = min(eights, len(self.number) // 11)
		self.result = str(numbers)

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


n = int(input())
chars = input()
chars_map = [0] * 10
for char in chars:
	chars_map[ord(char) - ord('0')] += 1
numbers_count = 0
while chars_map[8]:
	chars_map[8] -= 1
	remaining = 10
	for char in [0, 1, 2, 3, 4, 5, 6, 7, 9, 8]:
		diff = min(remaining, chars_map[char])
		remaining -= diff
		chars_map[char] -= diff
		if remaining == 0:
			break
	if remaining == 0:
		numbers_count += 1
	else:
		break
print(numbers_count)


n = int(input())
s = input()
m = s.count('8')
ans = min(m, n // 11)
print(ans)


n = int(input())
a = input()
c = 0
p = 0
for i in a:
	if i == '8':
		c = c + 1
print(min(c, n // 11))


a = int(input())
b = input()
c = list()
j = 0
while j < a:
	d = int(b[j])
	c.append(d)
	j = j + 1
m = int(a / 11)
i = 0
while m > 0:
	try:
		c.remove(8)
		i = i + 1
	except:
		break
	m = m - 1
print(i)


n = int(input())
num = input()
print(min(n // 11, num.count('8')))


n = int(input())
s = input()
k = s.count('8')
l = n - k
if k <= l // 10:
	print(k)
else:
	while k > l // 10:
		k -= 1
		l += 1
	print(min(k, l // 10))


a = int(input())
st = input()
eight = 0
for i in range(0, len(st)):
	if st[i] == '8':
		eight += 1
banyak = len(st) // 11
if banyak == 0:
	c = 0
elif banyak < eight:
	c = banyak
else:
	c = eight
print(c)


n = int(input())
a = list(str(input()))
v = a.count('8')
r = n - v
answer = 0
for i in range(n):
	if v == 0:
		break
	if r >= 10:
		v -= 1
		r -= 10
		answer += 1
	elif v >= 10 - r + 1:
		v -= 11 - r
		r = 0
		answer += 1
	else:
		break
print(answer)


def main():
	n = int(input())
	cards = input()
	et_count = cards.count('8')
	ph_no = n // 11
	if et_count <= ph_no:
		print(et_count)
	elif ph_no <= et_count:
		print(ph_no)
	else:
		print(0)
main()


n = int(input())
s = input()
(cnt, ec) = (0, 0)
for i in s:
	if i == '8':
		cnt += 1
		ec += 1
	elif '0' <= i <= '9':
		cnt += 1
print(min(ec, cnt // 11))


n = int(input())
s = input()
l = [int(x) for x in str(s)]
nc = l.count(8)
c = n // 11
if c <= nc:
	print(c)
else:
	print(nc)


n = int(input())
s = input()
a = s.count('8')
b = int(n / 11)
print(min(a, b))


n = int(input())
s = input()
l = list(s)
c = s.count('8')
num = n // 11
print(min(num, c))


import sys

def main():
	inp = sys.stdin.readlines()
	amount_of_no = int(inp[0])
	string_of_no = str(inp[1]).strip()
	if amount_of_no < 11 or not string_of_no.__contains__('8'):
		print(0)
		return
	number_of_8 = string_of_no.count('8')
	no_set = set()
	no_list = [x for x in string_of_no]
	possibilities_len = int(len(no_list) / 11)
	possibilities_8 = number_of_8
	possibilities = min(possibilities_8, possibilities_len)
	print(possibilities)
main()


x = int(input())
y = input()
c = y.count('8')
d = x // 11
print(min(c, d))


import os
import sys
import math
import heapq
from decimal import *
from io import BytesIO, IOBase
from collections import defaultdict, deque

def r():
	return int(input())

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

def rl():
	return list(map(int, input().split()))
n = r()
a = input()
num = defaultdict(int)
for i in range(n):
	num[int(a[i])] += 1
if num[8] == 0:
	print(0)
else:
	tot = n - num[8]
	strips = tot // 10
	rem = tot % 10
	if num[8] <= strips:
		print(num[8])
	else:
		ans = strips
		num[8] -= strips
		ans += num[8] // 11
		num[8] %= 11
		ans += 1 if rem + num[8] - 1 >= 10 else 0
		print(ans)


from collections import Counter
n = int(input().strip())
s = input().strip()
z = Counter(s)
if '8' not in s or n < 11:
	print(0)
else:
	c = n // 11
	if z['8'] >= c:
		print(c)
	else:
		print(z['8'])


n = int(input())
num = int(input())
p = 0
count = 0
c = 0
a = [0]
while n != 0:
	if num % 10 == 8:
		p += 1
		c -= 1
	num //= 10
	c += 1
	n -= 1
while c >= 10 and p > 0:
	c -= 10
	p -= 1
	count += 1
if p > 0:
	count = count + (c + p) // 11
print(count)


n = int(input())
s = input()
count8 = 0
for i in s:
	if i == '8':
		count8 += 1
if count8 == 0:
	print('0')
else:
	print(min(count8, n // 11))


n = int(input())
text = input()
print(min(n // 11, text.count('8')))


n = int(input())
ph = str(input())
ct = 0
for i in range(0, n):
	if ph[i] == '8':
		ct += 1
if n < 11:
	print('0')
	exit()
elif ct == 0:
	print('0')
	exit()
else:
	tt = 0
	tt = n // 11
	print(min(tt, ct))


n = int(input())
d = 0
m = str(input())
for i in m:
	if int(i) == 8:
		d = d + 1
print(min(d, int(n / 11)))


from collections import defaultdict, deque
from heapq import heappush, heappop
from math import inf
ri = lambda : map(int, input().split())

def solve():
	n = int(input())
	s = input()
	eights = 0
	for c in s:
		if c == '8':
			eights += 1
	print(min(eights, n // 11))
t = 1
while t:
	t -= 1
	solve()


count = int(input())
digits = input()
max_8 = digits.count('8')
max_dig = int(count / 11)
print(min(max_8, max_dig))


n = int(input())
p = input()
if '8' in p:
	s = p.count('8')
	u = n - s
	t = 0
	q = u // 10
	o = 0
	if q >= s:
		o += s
	else:
		o += q
		s -= q
		t += 1
	if s >= 11:
		o += s // 11
	if t > 0:
		s -= s // 11 * 11
		o += (u % 10 + s) // 11
	print(o)
else:
	print(0)


from collections import Counter as c
n = int(input())
a = input()
if n >= 11:
	eight = c(a)
	op = int(n / 11)
	if eight['8'] >= op:
		print(op)
	elif eight['8'] < op:
		print(eight['8'])
	else:
		print(0)
else:
	print(0)


n = int(input())
a = input()
cnt = a.count('8')
tot = 0
if cnt == 0 or n < 11:
	print(0)
else:
	for i in range(cnt):
		if (n - 1) // 10 > 0:
			tot += 1
			n = n - 11
		else:
			break
	print(tot)


n = int(input())
s = input()
dg = list(s)
ans = 0
n8 = s.count('8')
while n8:
	n -= 11
	n8 -= 1
	if n < 0:
		break
	ans += 1
print(ans)


n = int(input())
numbers = input()
eights = numbers.count('8')
print(min(eights, n // 11))


i = int(input())
j = str(input())
k = j.count('8')
ans = i
n = 0
while ans >= 11 and k > 0:
	ans = ans - 11
	k = k - 1
	n = n + 1
print(n)


n = int(input())
str = input()
print(min(str.count('8'), n // 11))


n = int(input())
input = [int(x) for x in input().strip()]
num_8 = len(list(filter(lambda x: x == 8, input)))
max_numbers = n / 11
print(int(min(num_8, max_numbers)))


x = int(input())
y = input()
a = x // 11
m = [d for d in y]
t = m.count('8')
if m.count('8') >= a:
	print(a)
elif t <= a and len(y) >= 11 * t and (t != 0):
	print(t)
else:
	print('0')


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

def solve(n, s):
	c = s.count('8')
	while c:
		if c + 10 * c <= n:
			return c
		c -= 1
	return c
print(solve(n, s))


n = int(input())
st = input()
count8 = 0
for k in st:
	if k == '8':
		count8 += 1
res = min(int(len(st) / 11), count8)
print(res)


import sys

def main():
	n = int(sys.stdin.readline())
	digits = sys.stdin.readline()
	eights = sum((d == '8' for d in digits))
	print(min(n // 11, eights))
main()


n = int(input())
l = [int(x) for x in input()].count(8)
n -= l
res = min(n // 10, l)
l -= res
n -= res * 10
if l != 0:
	res += (l + n) // 11
print(res)


n = int(input())
m = int(input())
s = map(int, str(m))
i = 0
for k in s:
	if k == 8:
		i = i + 1
j = int(n / 11)
if i > j:
	print(j)
else:
	print(i)


import re
n = int(input())
s = input()
count = [m.start() for m in re.finditer('8', s)]
print(min(len(count), n // 11))


n = int(input())
string = input()
cnt = 0
for c in string:
	if c == '8':
		cnt += 1
print(min(cnt, n // 11))


n = eval(input())
c = input()
i = 0
for j in range(n):
	if c[j] == '8':
		i += 1
print(min(i, int(n // 11)))


import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

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

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

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

def S():
	return input()

def main():
	n = I()
	l = list(S())
	x = n // 11
	y = l.count('8')
	return min(x, y)
print(main())


n = int(input())
s = input()
ans = 0
if '8' in s:
	ans = len(s) // 11
	if ans > s.count('8'):
		ans = s.count('8')
print(ans)


n = int(input())
s = input()
d = int(n / 11)
f = s.count('8')
print(min(f, d))


n = int(input())
ai = input().count('8')
print(min(n // 11, ai))


n = int(input())
s = input()
c = s.count('8')
print(min(c // 1, n // 11))


x = int(input())
s = input()
d = x // 11
e = s.count('8')
print(min(e, d))


p = int(input())
string = input()
d = string.count('8')
l = p // 11
if l <= d:
	print(l)
elif l >= d:
	print(d)
else:
	print('0')


import collections
n = int(input())
s = input()
c = collections.Counter(s)
print(min(c['8'], len(s) // 11))


n = int(input())
list = input()
x = 0
for i in range(len(list)):
	if list[i] == '8':
		x = x + 1
print(min(n // 11, x))


n = int(input())
s = str(input())
p = s.count('8')
q = n // 11
f = min(p, q)
print(f)


n = int(input())
arr = [x for x in input()]
count = arr.count('8')
answer = 0
for i in range(1, count + 1):
	answer = max(answer, min(i, (n - i) // 10))
print(answer)


n = int(input())
s = input()
e = s.count('8')
a = 0
while e > 0 and n > 10:
	e -= 1
	n -= 11
	a += 1
print(a)


n = int(input())
L = [i for i in input()]
print(min(n // 11, L.count('8')))


n = int(input())
s = input()
l = []
for i in range(len(s)):
	l.append(int(s[i]))
cnt = l.count(8)
dcnt = int(n / 11)
if dcnt == 0 or cnt == 0:
	print(0)
elif dcnt != 0 and cnt != 0:
	print(min(dcnt, cnt))
elif dcnt == 0 and cnt != 0:
	print(0)
else:
	print(0)


n = int(input())
a = [int(x) for x in input().strip()]
c8 = a.count(8)
print(min([c8, n // 11]))


n = int(input())
s = input()
n8 = 0
for i in range(n):
	if s[i] == '8':
		n8 += 1
ans = 0
for i in range(n8, 0, -1):
	if (n - i) // 10 >= i:
		ans = i
		break
print(ans)


from collections import Counter
n = int(input())
s = input()
f = s.count('8')
k = n // 11
if f >= 1 and k >= 1:
	print(min(f, k))
else:
	print(0)


a = int(input())
b = input()
c = b.count('8')
d = len(str(b)) // 11
if c > d:
	print(d)
elif d >= c:
	print(c)
else:
	print(-1)


__author__ = 'Dilshod'
n = int(input())
s = input()
a = n // 11
b = s.count('8')
if b >= a:
	print(a)
elif b == 0 or a == 0:
	print(0)
elif b < a:
	print(b)


def main():
	n = int(input())
	s = input()
	print(solver(s))

def solver(s):
	eights = s.count('8')
	return min(len(s) // 11, eights)
main()


n = int(input())
nums = input()
max_nums = n // 11
eights = nums.count('8')
print(min(eights, max_nums))


from sys import stdin
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)

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

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

def read_str():
	return input()

def read_strs():
	return [x for x in stdin.readline().split()]
lens = read_int()
strs = read_str()
ans = lens // 11
print(min(ans, strs.count('8')))


n = int(input())
s = input()
ctx = s.count('8')
ans = 0
if ctx > 0:
	possi = n // 11
	ans = min(ctx, possi)
print(ans)


n = int(input())
z = str(input())
q = 0
for i in z:
	if i == '8':
		q += 1
y = n // 11
if q == 0:
	print(0)
else:
	print(min(y, q))


x = int(input())
x = x // 11
s = input()
a = s.count('8')
b = min(x, a)
print(b)


from collections import Counter
n = int(input())
c = Counter(input())
if '8' in list(c):
	print(min(n // 11, c['8']))
else:
	print(0)


def phone(n, string):
	maximumPhone = n // 11
	numberEight = string.count('8')
	if numberEight == 0:
		return 0
	elif numberEight >= maximumPhone:
		return maximumPhone
	else:
		return numberEight
n = int(input())
string = input()
print(phone(n, string))


import sys
import math
import bisect

def main():
	n = int(input())
	A = list((int(a) for a in input()))
	m = 0
	for a in A:
		if a == 8:
			m += 1
	max_val = 0
	for i in range(m + 1):
		if i * 11 <= n:
			val = i
			max_val = max(max_val, val)
	print(max_val)
main()


import math
n = int(input())
s = input()
print(min(s.count('8'), n // 11))


n = int(input())
s = input()
counter = 0
for c in s:
	if c == '8':
		counter += 1
if counter == 0 or n < 11:
	print('0')
elif counter > n / 11:
	print(int(n / 11))
else:
	print(counter)


n = int(input())
k = str(input())
q = 0
for i in k:
	if i == '8':
		q += 1
if (len(k) - len(k) % 11) / 11 > q:
	print(q)
else:
	print(int((len(k) - len(k) % 11) / 11))


n = int(input())
u = list(map(int, list(input())))
k = 0
for i in range(n):
	if u[i] == 8:
		k += 1
ans = 0
ii = -1
for i in range(1, k + 1):
	p = (n - i) // 10
	if min(i, p) > ans:
		ans = min(i, p)
		ii = i
print(ans)


a = int(input(''))
b = input('')
occurences_of_eight = 0
for i in range(len(b)):
	if b[i] == '8':
		occurences_of_eight = occurences_of_eight + 1
max_phone_numbers = int(len(b) / 11)
print(min(occurences_of_eight, max_phone_numbers))


def Str2List(string):
	a = [digit for digit in string]
	return a

def findEight(List):
	a = 0
	for d in List:
		if d == '8':
			a += 1
	return a
cards = int(input())
digits = input()
numbers = 0
digits = Str2List(digits)
eights = findEight(digits)
lenofDigits = len(digits)
while lenofDigits >= 11 and eights >= 1:
	eights -= 1
	lenofDigits -= 11
	numbers += 1
print(numbers)


n = int(input())
k = 0
p = n // 11
s = input()
for i in range(len(s)):
	if s[i] == '8':
		k += 1
	else:
		pass
if p <= k:
	print(p)
elif p > k:
	print(k)


n = int(input())
s = input()
c = 0
for i in range(0, len(s)):
	if s[i] == '8':
		c = c + 1
k = len(s) // 11
print(min(c, k))


n = int(input())
s = input()
x = int(n / 11)
y = 0
for i in range(0, n):
	if s[i] == '8':
		y = y + 1
if x > y:
	pn = y
else:
	pn = x
print(pn)


_ = input()
N = input()
LLLLen = N.count('8')
sss = len(N) // 11
print(min(LLLLen, sss))


a = input()
b = input()
cont = 0
i = 0
while i < int(a) and cont <= int(a) // 11 - 1:
	if b[i] == '8':
		cont = cont + 1
	i = i + 1
print(cont)


from collections import Counter
n = int(input())
string = input()
counter = Counter(string)
limit = min(int(len(string) / 11), counter['8'])
print(limit)


N = int(input())
s = input()
count = 0
for i in s:
	if i == '8':
		count = count + 1
if count != 0:
	p = N / 11
	if p > count:
		print(count)
	else:
		print(int(p))
else:
	print(0)


n = int(input())
z = input()
sol = 0
k = z.count('8')
while n >= 11 and k >= 1:
	if n >= 11 and k >= 1:
		sol += 1
		k -= 1
		n -= 11
	else:
		break
print(sol)


n = int(input())
sr = input()
sol = 0
eights = sr.count('8')
while n >= 11 and eights > 0:
	sol += 1
	eights -= 1
	n -= 11
print(sol)


ncards = int(input())
cards = input()
eightc = 0
for i in cards:
	if i == '8':
		eightc += 1
if eightc == 0:
	print(0)
elif ncards < 11:
	print(0)
elif ncards % 11 == 0:
	if eightc * 11 > ncards:
		print(int(ncards / 11))
	else:
		print(eightc)
else:
	x = ncards
	while x % 11 != 0:
		x -= 1
	if eightc * 11 > ncards:
		print(int(x / 11))
	else:
		print(eightc)


input()
a = str(input())
print(min(a.count('8'), len(a) // 11))


n = int(input())
cards = list(map(int, list(input())))
max_num = len(cards) // 11
eights_counter = 0
for num in cards:
	if num == 8:
		eights_counter += 1
max_num = min(max_num, eights_counter)
print(max_num)


n = int(input())
c = sum(map(lambda x: x == '8', input()))
print(min(n // 11, c))


n = int(input())
s = input()
e = s.count('8')
a = divmod(n, 11)
if e == 0:
	print(0)
else:
	print(min(a[0], e))


n = int(input())
s = list(input())
a = n // 11
b = s.count('8')
if b >= a:
	print(a)
elif b < a:
	print(b)


n = int(input())
a = input()
k = 0
kk = 0
for x in a:
	if x == '8':
		k += 1
while n >= 11 and k:
	k -= 1
	n -= 11
	kk += 1
print(kk)


n = int(input())
a = input().strip()
x = a.count('8')
print(min(x, n // 11))


n = int(input())
s = str(input())
k = 0
for i in range(n):
	if int(s[i]) == 8:
		k = k + 1
l = n / 11
if k > 0 and l > 0:
	if l > k:
		p = k
	else:
		p = l
else:
	p = 0
p = int(p)
print(p)


n = input()
m = input()
counter = 0
for i in range(len(m)):
	if m[i] == '8':
		counter += 1
c = len(m) // 11
print(min(c, counter))


n = int(input())
s = [int(x) for x in input()]
c8 = s.count(8)
phone = 0
if n >= 11 and c8 > 0:
	while n >= 11 and c8 > 0:
		c8 -= 1
		n -= 11
		phone += 1
	print(phone)
else:
	print(0)


input()
b = input()
c = b.count('8')
result = len(b) // 11
if c < result:
	print(c)
else:
	print(result)


n = int(input())
m = input()
a = m.count('8')
k = n // 11
print(min(a, k))


T_ON = 0
DEBUG_ON = 0
MOD = 998244353

def solve():
	n = read_int()
	s = input()
	eight = s.count('8')
	print(min(eight, n // 11))

def main():
	T = read_int() if T_ON else 1
	for i in range(T):
		solve()

def debug(*xargs):
	if DEBUG_ON:
		print(*xargs)
from collections import *
import math
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')

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

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

def print_nums(nums):
	print(' '.join(map(str, nums)))

def YES():
	print('YES')

def Yes():
	print('Yes')

def NO():
	print('NO')

def No():
	print('No')

def First():
	print('First')

def Second():
	print('Second')

def fib(n):
	(a, b) = (0, 1)
	for _ in range(n):
		(a, b) = (b, a + b)
	return a

def fib_ns(n):
	assert n >= 1
	f = [0 for _ in range(n + 1)]
	f[0] = 0
	f[1] = 1
	for i in range(2, n + 1):
		f[i] = f[i - 1] + f[i - 2]
	return f

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

def xgcd(a, b):
	(x0, x1, y0, y1) = (0, 1, 1, 0)
	while a != 0:
		((q, a), b) = (divmod(b, a), a)
		(y0, y1) = (y1, y0 - q * y1)
		(x0, x1) = (x1, x0 - q * x1)
	return (b, x0, y0)

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

def is_even(x):
	return x % 2 == 0

def is_odd(x):
	return x % 2 == 1

def modinv(a, m):
	(g, x, _) = xgcd(a, m)
	if g != 1:
		raise Exception('gcd(a, m) != 1')
	return x % m

def mod_add(x, y):
	x += y
	while x >= MOD:
		x -= MOD
	while x < 0:
		x += MOD
	return x

def mod_mul(x, y):
	return x * y % MOD

def mod_pow(x, y):
	if y == 0:
		return 1
	if y % 2:
		return mod_mul(x, mod_pow(x, y - 1))
	p = mod_pow(x, y // 2)
	return mod_mul(p, p)

def mod_inv(y):
	return mod_pow(y, MOD - 2)

def mod_div(x, y):
	return mod_mul(x, mod_inv(y))

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

def gen_primes(n):
	P = [True for _ in range(n + 1)]
	P[0] = P[1] = False
	for i in range(int(n ** 0.5) + 1):
		if P[i]:
			for j in range(2 * i, n + 1, i):
				P[j] = False
	return P
main()


n = int(input())
a = input()
a = list(a)
b = n // 11
c = a.count('8')
if c >= b:
	print(b)
elif b > c:
	print(c)
else:
	print('0')


n = int(input())
s = input()
temp = 0
for i in range(len(s)):
	if s[i] == '8':
		temp += 1
print(min(temp, n // 11))


n = int(input())
s = input()
print(min(sum([1 if i == '8' else 0 for i in s]), len(s) // 11))


input()
k = input()
s = k.count('8')
l = len(list(k)) // 11
print(min(s, l))


n = int(input())
nos = input()
numbers = []
for s in nos:
	numbers.append(int(s))
if n < 11:
	print('0')
else:
	poss = int(n / 11)
	no_of_eight = 0
	for i in range(n):
		if numbers[i] == 8:
			no_of_eight += 1
	print(min(no_of_eight, poss))


n = int(input())
m = input()
hasil = ''
banyakAngka = 0
for i in range(len(m)):
	if m[i] == '8':
		banyakAngka += 1
harusnya = n // 11
if banyakAngka >= harusnya:
	print(harusnya)
else:
	print(banyakAngka)


n = int(input())
inp = input()
a = 0
for i in range(n):
	if inp[i] == '8':
		a += 1
b = n // 11
print(a) if b > a else print(b)


def main():
	n = int(input())
	s = input()
	if '8' not in s:
		return 0
	q = s.count('8')
	return min(q, n // 11)
print(main())


n = input()
numbers = input()
eights = 0
max_nums = len(numbers) // 11
for n in numbers:
	if n == '8':
		eights += 1
if eights >= max_nums:
	print(max_nums)
else:
	print(eights)


n = int(input())
s = input().rstrip()
x = list(s)
l = []
i = 0
Y = 0
while i < len(x):
	if x[i] == '8':
		l.append(x[i])
		del x[i]
	else:
		i += 1
if len(l) == 0:
	print(0)
else:
	while 1:
		if len(l) == 0 or len(x) + len(l) < 10:
			break
		else:
			del l[0]
			if len(x) + len(l) < 10:
				break
			elif len(x) >= 10:
				for i in range(0, 10):
					del x[0]
				Y += 1
			elif len(x) < 10 and len(l) + len(x) >= 10:
				G = len(x)
				for i in range(0, len(x)):
					del x[0]
				t = 11 - G - 1
				for i in range(0, t):
					del l[0]
				Y += 1
			else:
				break
	print(Y)


def solution(l1):
	i = 0
	while i < len(l1):
		if l1[i] == 8:
			l1[i] = 1
		else:
			l1[i] = 0
		i += 1
	l1.sort()
	i = 0
	while len(l1) > 10 and 1 in l1:
		l1.remove(1)
		for x in range(0, 10):
			l1.remove(l1[0])
		i += 1
	return i

def answer():
	a = int(input())
	l1 = [int(x) for x in list(input())]
	print(solution(l1))
answer()


t = 0
n = int(input())
m = input()
for i in range(len(m)):
	if m[i] == '8':
		t = t + 1
if t >= n / 11:
	print('%d' % int(n // 11))
else:
	print('%d' % t)


t = int(input())
e = input()
ei = e.count('8')
ans = t // 11
print(min(ans, ei))


n = int(input())
ss = input()
n1 = n // 11
if n1 == 0:
	print(0)
	exit()
s8s = [s for s in ss[:len(ss)] if s == '8']
print(min(n1, len(s8s)))


n = int(input())
a = list(input())
k = 0
if n < 11:
	print(0)
	exit()
else:
	p = 0
	for i in range(len(a)):
		if a[i] == '8':
			p += 1
		f = len(a) // 11
	print(min(f, p))


def pn(l):
	if l.count('8') == 0:
		print(0)
	else:
		a = l.count('8')
		p = len(l) // 11
		if p == a:
			print(a)
		elif a > p:
			print(p)
		else:
			print(a)
	return
n = int(input())
l = list(input())
pn(l)


a = int(input())
s = str(input())
l = list(s)
k = l.count('8')
m = min(int(a / 11), k)
print(m)


length = int(input())
line = str(input())
len11 = int(length / 11)
print(min(len11, line.count('8')))


def test(n, string):
	eight = string.count('8')
	n = n // 11
	if eight >= n:
		return n
	else:
		return eight
print(test(int(input()), input()))


n = int(input())
s = input()
a = s.count('8')
if a == 0:
	print(0)
	exit()
nn = n - a
b = a * 10
if b <= nn:
	print(a)
else:
	h = nn // 10
	h += (nn % 10 + (a - h)) // 11
	print(h)


n = int(input())
s = input()
p = s.count('8')
r = n // 11
print(min(r, p))


n = int(input())
a = input()
b = a.count('8')
d = []
for i in range(b):
	d.append(min((n - (i + 1)) // 10, i + 1))
if len(d) == 0:
	print(0)
	exit()
print(max(d))


n = int(input())
str = input()
result = str.count('8')
ans = 0
while n >= 11 and result > 0:
	if n >= 11 and result > 0:
		ans += 1
		n -= 11
		result -= 1
	else:
		break
print(ans)


n = int(input())
s = input()
t = int(n / 11)
if n < 11:
	print('0')
else:
	p = s.count('8')
	if p < t:
		print(p)
	if p >= t:
		print(t)


import math
from collections import defaultdict

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

def solve():
	n = int(input())
	s = input()
	n = len(s)
	c = s.count('8')
	for x in range(100):
		if x > c or 11 * x > n:
			print(x - 1)
			return
solve()


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

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

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

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

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

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

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

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

def S():
	return input()

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

def pe(s):
	return print(str(s), file=sys.stderr)

def main():
	n = I()
	c = collections.Counter(S())
	return min(n // 11, c['8'])
print(main())


N = int(input())
s = input()
ei = s.count('8')
m = N - ei
k = m // 10
if k <= ei:
	q = N - k * 11
	print(k + max(0, q // 11))
else:
	print(ei)


n = int(input())
l = input()
l = list(l)
a = l.count('8')
if a <= len(l) // 11:
	print(a)
elif a >= len(l) // 11:
	print(len(l) // 11)
else:
	print('0')


N = int(input())
s = input()
eights = s.count('8')
m = len(s) // 11
print(min(eights, m))


q = int(input())
w = list(input())
e = w.count('8')
r = q // 11
t = min(e, r)
print(t)


n = int(input())
s = list(str(input()))
res1 = 0
res2 = 0
l = '8'
if l not in s or n < 11:
	print(0)
else:
	res1 = s.count(l)
	res2 = n // 11
	print(min(res1, res2))


N = int(input())
ipt = input()

def checker(ipt):
	if '8' in ipt:
		if len(ipt) >= 11:
			return min(len(ipt) // 11, ipt.count('8'))
	return 0
print(checker(ipt))


n = int(input())
l = input()
a = len(l) % 11
p = len(l) - a
if n < 11:
	print(0)
else:
	for i in range(p):
		if l.count('8') >= p // 11:
			print(p // 11)
			break
		elif l.count('8') < p // 11:
			print(l.count('8'))
			break
		else:
			print(0)
		break


n = int(input())
s = input()
l = list(s)
cnt = l.count('8')
length = n // 11
if length >= cnt:
	print(cnt)
elif length <= cnt:
	print(length)
elif length == cnt:
	print(lenght)
elif length <= 1:
	print(0)


a = int(input())
S = input()
L = a // 11
P = S.count('8')
print(min(L, P))


(n, s) = (int(input()), input())
e = s.count('8')
m = 0
for i in range(e + 1):
	m = max(m, min(i, (n - i) // 10))
print(m)


try:
	n = int(input())
	s = input()
	l = list(s)
	x = int(n / 11)
	if l.count('8') >= x:
		print(x)
	elif l.count('8') == 0:
		print('0')
	else:
		print(l.count('8'))
except EOFError:
	pass


n = int(input())
array = list(input())
eight = 0
notEight = 0
for x in array:
	if x == '8':
		eight += 1
	else:
		notEight += 1
solution = 0
while eight > 0 and eight + notEight > 10:
	solution += 1
	eight -= 1
	if notEight < 10:
		eight -= 10 - notEight
		notEight = 0
	else:
		notEight -= 10
print(solution)


n = int(input())
s = input()
m = len(s)
v = s.count('8')
out = min(v, m // 11)
print(out)


import sys

def main():
	inp = sys.stdin.readlines()
	amount_of_no = int(inp[0])
	string_of_no = str(inp[1]).strip()
	number_of_8 = string_of_no.count('8')
	no_list = [x for x in string_of_no]
	possibilities_len = int(len(no_list) / 11)
	possibilities_8 = number_of_8
	possibilities = min(possibilities_8, possibilities_len)
	print(possibilities)
main()


n = int(input())
cs = input()
eights = sum((1 for c in cs if c == '8'))
print(min(len(cs) // 11, eights))


nu = int(input())
number = int(input())
cont = 0
for i in str(number):
	if i == '8':
		cont += 1
nu = nu / 11
if cont > nu:
	print(int(nu))
else:
	print(int(cont))


length = int(input())
s = input()
max_num = int(length / 11)
eight_num = 0
for i in range(length):
	if s[i] == '8':
		eight_num += 1
if eight_num >= max_num:
	print(max_num)
else:
	print(eight_num)


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

def count(str):
	k = 0
	for i in str:
		if i == '8':
			k += 1
	return k
if count(s) == 0:
	print(0)
elif n // 11 >= count(s):
	print(count(s))
else:
	print(n // 11)


n = int(input())
a = list(input())
c = a.count('8')
l = len(a) // 11
if c > l:
	print(l)
else:
	print(c)


N = int(input())
eight_amount = input().count('8')
if N // 11 >= eight_amount:
	print(eight_amount)
else:
	print(N // 11)


n = int(input())
num = input()
if '8' not in num:
	print(0)
else:
	print(min(num.count('8'), n // 11))


def main():
	n = int(input())
	d = list(map(int, input()))
	count = d.count(8)
	print(0 if count == 0 or n < 11 else min(count, n // 11))
main()


n = int(input())
s = input()
(eight, other) = (0, 0)
for i in range(len(s)):
	if s[i] == '8':
		eight += 1
	else:
		other += 1
res = 0
for i in range(1, 100):
	if i <= eight and eight - i + other >= i * 10:
		res = i
	else:
		break
print(res)


l = int(input())
s = input()
frq = {8: 0, 0: 0}
for c in s:
	if c != '8':
		frq[0] = frq[0] + 1
	else:
		frq[8] = frq[8] + 1
l = 0
r = 10
while r > l + 1:
	m = (l + r) // 2
	if frq[8] - m >= 0 and (frq[0] + frq[8] - m) // 10 >= m:
		l = m
	else:
		r = m
print(l)


n = int(input())
l = list(input())
n8 = l.count('8')
nn = n // 11
print(min(nn, n8))


n = int(input())
num = str(int(input()))
cnt1 = n // 11
cnt2 = num.count('8')
print(min(cnt1, cnt2))


n = int(input())
x = input()
c = 0
for i in range(n):
	if x[i] == '8':
		c += 1
print(min(c, n // 11))


def main():
	length = int(input())
	cards = input()
	n_eights = cards.count('8')
	max_numbers = length // 11
	print(min(n_eights, max_numbers))
main()


n = int(input())
s = list(input())
count_8 = s.count('8')
total = len(s)
if len(s) < 11:
	print(0)
elif count_8 == 0:
	print(0)
else:
	cnt = 0
	for i in range(count_8):
		s.remove('8')
	s = s[::-1]
	for i in range(count_8):
		s.append('8')
	for i in range(count_8):
		if s[-1] == '8' and total >= 11:
			total -= 11
			cnt += 1
			s.pop()
		else:
			break
	print(cnt)


n = int(input())
if n < 11:
	print(0)
else:
	ss = input()
	count = 0
	for i in range(0, n):
		if int(ss[i]) == 8:
			count += 1
	temp = n // 11
	if temp < count:
		print(temp)
	else:
		print(count)


n = int(input())
s = str(input())
a = n // 11
c = s.count('8')
print(min(a, c))


n = input()
s = input()
a = 0
for i in s:
	a += i == '8'
print(min(a, len(s) // 11))


n = int(input())
c = input().count('8')
print(min(n // 11, c))


_ = input()
N = input()
Num = N.count('8')
div = len(N) // 11
print(min(Num, div))


dat = [0] * 10
n = int(input())
s = input()
num8 = s.count('8')
print(min(num8, n // 11))


n = int(input())
s = input()
occu_8 = s.count('8')
if n < 11 or occu_8 == 0:
	print(0)
elif n // 11 >= occu_8:
	print(occu_8)
else:
	print(n // 11)


nbCards = int(input())
cards = input()
eights = 0
otherDigits = 0
for card in cards:
	if card == '8':
		eights += 1
	else:
		otherDigits += 1
nbNumbers = 0
for loop in range(eights):
	toTake = min(10, otherDigits)
	taken = toTake
	otherDigits -= toTake
	if toTake != 10:
		toTake = min(10 - toTake, eights - 1)
		eights -= toTake
		taken += toTake
	if taken == 10:
		eights -= 1
		nbNumbers += 1
	else:
		break
print(nbNumbers)


x = int(input())
s = input()
print(min(s.count('8'), x // 11))


n = int(input())
s = input()
c8 = s.count('8')
re = n - c8
t = n // 11
print(min(c8, t))


a = int(input())
b = input()
n = a // 11
c = 0
for i in range(a):
	if b[i] == '8':
		c += 1
print(min(c, n))


def find_eights():
	sum = 0
	for i in range(len(y)):
		if y[i] == '8':
			sum += 1
	return sum
k = int(input())
y = input()
find_e = find_eights()
ll = k // 11
if k < 11 or find_e == 0:
	print(0)
	exit()
if find_e >= ll:
	print(ll)
else:
	print(find_e)


n = int(input())
digits = input()
if digits.count('8') == 0:
	print(0)
else:
	ans = 0
	temp = digits.count('8')
	for _ in range(temp):
		if n == 0 or n - 11 < 0:
			break
		n -= 11
		ans += 1
	print(ans)


nnn = int(input())
n = input()
c8 = n.count('8')
print(min(c8, nnn // 11))


n = int(input())
lis = list(input())
n = len(lis) // 11
c = lis.count('8')
if '8' in lis:
	print(min(n, c))
else:
	print(0)


n = int(input())
s = input()
eight = s.count('8')
if eight == n:
	ans = eight // 11
	print(ans)
else:
	all_except_eight = n - eight
	tmp = all_except_eight // 10
	remaining = all_except_eight % 10
	ans = 0
	if eight >= tmp:
		ans = tmp
		eight -= tmp
		if eight == 0:
			print(ans)
		else:
			if remaining + eight >= 11:
				ans += 1
			eight -= 11 - remaining
			if eight >= 0:
				ans += eight // 11
			print(ans)
	else:
		print(eight)


import math
n = int(input())
s = input()
c = 0
d = s.count('8')
print(min(n // 11, d))


def sum(a):
	s = 0
	for i in a:
		s = s + i
	return s
n = int(input())
a = list(input())
b = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
c = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
d = dict(zip(b, c))
for i in range(len(a)):
	d[a[i]] += 1
e = list(d.values())
z = sum(e) // 11
x = e[8]
print(min(x, z))


n = int(input())
p = input()
e = p.count('8')
print(min(n // 11, e))


n = int(input())
x = input()
k = 0
m = 0
z = 0
for i in x:
	if int(i) == 8:
		k += 1
for i in range(k):
	m += 11
	if n < m:
		break
	z += 1
print(z)


n = int(input())
ch = input()
dem = 0
for i in ch:
	if i == '8':
		dem += 1
print(min(int(n / 11), dem))


n = int(input())
s = input()
for i in range(n, -1, -1):
	if s.count('8') < i:
		continue
	if (len(s) - i) // 10 < i:
		continue
	print(i)
	break


a = int(input())
b = list(''.join(input()))
g = b.count('8')
f = a // 11
print(min(g, f))


def solve(n, s):
	x = s.count(8)
	m = len(s) // 11
	return min(m, x)

def main():
	n = int(input())
	s = list(map(int, input()))
	print(solve(n, s))
main()


n = int(input())
a = input()
a0 = 0
a1 = 0
a2 = 0
a3 = 0
a4 = 0
a5 = 0
a6 = 0
a7 = 0
a8 = 0
a9 = 0
for i in a:
	if i == '0':
		a0 += 1
	if i == '1':
		a1 += 1
	if i == '2':
		a2 += 1
	if i == '3':
		a3 += 1
	if i == '4':
		a4 += 1
	if i == '5':
		a5 += 1
	if i == '6':
		a6 += 1
	if i == '7':
		a7 += 1
	if i == '8':
		a8 += 1
	if i == '9':
		a9 += 1
mm = sum([a8, a1, a2, a3, a4, a5, a6, a7, a9, a0])
kk = a8
k = 0
while kk > 0 and mm >= 11:
	k += 1
	mm -= 11
	kk -= 1
print(k)


n = int(input())
s = input()
num_eight = 0
for i in range(n):
	if s[i] == '8':
		num_eight += 1
phone_num = n // 11
if num_eight <= phone_num:
	print(num_eight)
else:
	print(phone_num)


n = int(input())
a = list(input())
k = a.count('8')
s = 0
while k > 0 and n > 10:
	s += 1
	n -= 11
	k -= 1
print(s)


a = int(input())
b = input()
ans = a // 11
ans1 = b.count('8')
print(min(ans, ans1))


n = int(input())
s = input()
cnt8 = 0
for charr in s:
	if charr == '8':
		cnt8 += 1
print(min(cnt8, n // 11))


n = int(input())
num = input()
a = n // 11
b = 0
p = 0
while p < len(num):
	x = num[p]
	if x == '8':
		b += 1
	p += 1
if b == 0:
	print(0)
elif a > b:
	print(b)
else:
	print(a)


n = int(input())
s = input()
output = 0
if s.count('8') > 0:
	num = s.count('8')
	if num * 11 <= n:
		output = num
	else:
		output = n // 11
print(output)


a = int(input()) // 11
b = 0
for i in input():
	if i == '8':
		b += 1
print(min(a, b))


from math import *
n = int(input())
s = [int(i) for i in input()][:n]
ctr = 0
for i in s:
	ctr += 1 if i == 8 else 0
print(min(ctr, len(s) // 11))


n = int(input())
s = list(input())
if '8' not in s:
	print(0)
	exit()
print(min(s.count('8'), n // 11))


t = int(input())
lst = list(input())
print(min(lst.count('8'), t // 11))


x = int(input())
if x < 11:
	y = input()
	print(0)
else:
	x = x // 11
	y = input()
	Y = len(y)
	N = 0
	for k in range(0, Y):
		if y[k] == '8':
			N += 1
	if N >= x:
		print(x)
	else:
		print(N)


input()
string = input()
print(min(str.count(string, '8'), len(string) // 11))


n = int(input())
s = list(map(int, input()))
print(min(s.count(8), len(s) // 11))


n = int(input())
str = input()
res = 0
much = str.count('8')
while n >= 11:
	if much > 0:
		n -= 11
		much -= 1
		res += 1
	else:
		break
print(res)


n = int(input())
s = input()
c = 0
for i in range(s.count('8')):
	n -= 11
	if n < 0:
		break
	c += 1
print(c)


a = int(input())
st = str(input())
if a < 11:
	print(0)
	exit()
map = {}
for i in range(10):
	map[i] = 0
for i in range(a):
	map[int(st[i])] += 1
if map[8] == 0:
	print(0)
	exit()
ans = 0
print(min(int(a / 11), map[8]))


n = eval(input())
c = input()
i = 0
count = 0
temp = 0
for j in range(n):
	if c[j] == '8':
		i += 1
if i == 0:
	print(0)
else:
	while count < i and temp + 11 <= n:
		temp += 11
		count += 1
	print(count)


n = int(input())
num = input()
if n % 11 <= 11 and '8' in num:
	if num.count('8') <= n // 11:
		print(num.count('8'))
	else:
		print(n // 11)
else:
	print(0)


n = int(input())
while n < 1 or n > 100:
	n = int(input())
ch = input()
while not ch.isdigit() or len(ch) > n:
	ch = input()
s = 0
for i in ch:
	if i == '8':
		s += 1
if s == 0:
	print(0)
elif s > n // 11:
	print(n // 11)
else:
	print(s)


n = int(input())
s = input()
cnt = 0
for i in s:
	if i == '8':
		cnt += 1
ans = 0
for i in range(0, cnt + 1):
	if i * 11 <= n:
		ans = i
	else:
		break
print(ans)


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

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

def li():
	return list(mi())
n = ii()
s = input().strip()
eight = s.count('8')
rem = len(s) - eight
(cnt, extra) = divmod(rem, 10)
if eight <= cnt:
	ans = eight
else:
	ans = cnt
	eight -= cnt
	if eight + extra >= 11:
		ans += 1
		eight -= 11 - extra
		ans += eight // 11
print(ans)


from collections import Counter

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

def readline():
	return [int(c) for c in input().split()]

def main():
	no_cards = readint()
	cards = [int(c) for c in input()]
	cnt = Counter(cards)
	print(min(cnt[8], sum(cnt.values()) // 11))
main()


def solve():
	n = int(input())
	digits = input()
	c = digits.count('8')
	if c < 1 or n < 11:
		return 0
	return min(c, n // 11)
print(solve())


count = 0
n = int(input())
number = str(input())
for i in range(n):
	if number[i] == '8':
		count += 1
if n // 11 > count:
	print(count)
else:
	print(n // 11)


n = int(input())
a = list(input())
cnt = a.count('8')
l = len(a) // 11
print(min(cnt, l))


n = int(input())
l = input()
N = 0
for x in l:
	if x == '8':
		N += 1
n //= 11
n = min(N, n)
print(n)


n = int(input())
num = input()
e = 0
for x in num:
	if x == '8':
		e += 1
print(min(e, n // 11))


a = int(input())
b = input()
d = []
if b.count('8') > 1:
	k = 1
else:
	k = 0
if a >= 11 and b.count('8') > 0:
	for i in range(a):
		if b[i] != '8' and b[i] not in d:
			d.append(b[i])
			k += 1
	print(min(a // 11, a // k, b.count('8')))
else:
	print(0)


def read():
	return int(input())

def read_cards():
	s = input()
	return list((int(e) for e in s))
n = read()
arr = read_cards()
print(min(len(arr) // 11, arr.count(8)))


n = int(input())
lst = list(input())
print(min(lst.count('8'), n // 11))


from collections import Counter

def can_make(e, n, x):
	return e >= x and (n - x) // 10 >= x
n = int(input())
e = sum((c == '8' for c in input()))
ans = 0
while can_make(e, n, ans):
	ans += 1
print(ans - 1)


n = int(input())
s = list(input())
cnt_8 = 0
for item in s:
	if item == '8':
		cnt_8 += 1
cnt_num = n // 11
if cnt_8 > cnt_num:
	print(cnt_num)
else:
	print(cnt_8)


n = int(input())
a = str(input())
a1 = n // 11
s = a.count('8')
print(min(a1, s))


n = int(input())
t = input()
c = t.count('8')
for x in range(c, -1, -1):
	if x + 10 * x <= n:
		print(x)
		break


n = int(input())
a = [*map(int, input())]
e = a.count(8)
print(min(n // 11, e))


n = int(input())
cards = input()
r = min(n // 11, cards.count('8'))
print(r)


n = int(input())
s = input()
k1 = 0
k2 = 0
if '8' in s and n > 10:
	k1 = s.count('8')
	k2 = n // 11
	print(min(k1, k2))
else:
	print(0)


n = int(input())
m = input()
s = 0
for i in range(n):
	if m[i] == '8':
		s += 1
print(min(n // 11, s))


n = int(input(''))
dizi = list(input(''))
sekiz = 0
for j in range(n):
	if dizi[j] == '8':
		sekiz = sekiz + 1
sayi = int(len(dizi) / 11)
if sekiz == 0:
	print(0)
elif sekiz > sayi:
	print(int(sayi))
else:
	print(int(sekiz))


n = int(input())
from collections import Counter
s = Counter(input())
digs = 0
eights = None
for i in range(10):
	if str(i) == '8':
		if str(i) in s:
			eights = s[str(i)]
		else:
			eights = 0
	elif str(i) in s:
		digs += s[str(i)]
ans = 0
for i in range(15):
	if i > eights:
		break
	eightz = i
	oth = digs + (eights - i)
	ans = max(ans, min(oth // 10, eightz))
print(ans)


N = int(input())
S = str(input())
cnt = 0
for i in range(N):
	if S[i] == '8':
		cnt += 1
print(min(cnt, N // 11))


n = int(input())
l = list(input())
maxi = n // 11
e = l.count('8')
print(min(maxi, e))


n = int(input())
m = len(input().replace('8', ''))
print(min(n // 11, n - m))


length = int(input())
num = input()
p = 0
for i in range(length):
	if num[i] == '8':
		p += 1
if length >= 11:
	if p >= length // 11:
		print(length // 11)
	else:
		print(p)
else:
	print(0)


N = int(input())
eight_amount = input().count('8')
if eight_amount == 0:
	print(0)
elif N // 11 >= eight_amount:
	print(eight_amount)
else:
	print(N // 11)


n = int(input())
k = list(input())
r = n // 11
print(min(r, k.count('8')))


n = int(input())
eights = 0
others = 0
for elem in input():
	if int(elem) == 8:
		eights += 1
	else:
		others += 1
answer = 0
while True:
	if eights == 0:
		break
	else:
		eights -= 1
		if others >= 10:
			others -= 10
			answer += 1
		elif eights - (10 - others) >= 0:
			eights -= 10 - others
			others = 0
			answer += 1
		else:
			break
print(answer)


n = 0
a = input()
b = list(input())
for element in b:
	if element == '8':
		n += 1
if len(b) < 11:
	print(0)
elif n < 1:
	print(0)
elif len(b) // 11 == n:
	print(n)
elif len(b) // 11 > n:
	print(n)
elif len(b) // 11 < n:
	print(len(b) // 11)


n = int(input())
s = input()
if n < 11:
	print(0)
else:
	temp = n / 11
	if s.count('8') == temp or s.count('8') < temp:
		print(s.count('8'))
	else:
		print(int(temp))


n = int(input())
ch = input()
l = list(ch)
if l.count('8') >= len(ch) // 11:
	print(len(ch) // 11)
elif '8' not in l:
	print(0)
elif l.count('8') < len(ch) // 11:
	print(l.count('8'))


n = int(input())
digits = input()
num_eights = sum((1 for x in digits if x == '8'))
num_not_eights = len(digits) - num_eights
num_phones = None
while True:
	num_phones = min(num_eights, num_not_eights // 10)
	if num_eights > num_phones:
		num_eights -= 1
		num_not_eights += 1
	else:
		break
print(num_phones)


n = int(input())
s = input()
count1 = 0
for i in range(n):
	if s[i] == '8':
		count1 += 1
if count1 == 0:
	print(0)
else:
	tam = n // 11
	if tam <= count1:
		print(tam)
	else:
		print(count1)


from math import factorial
t = int(input())
num = input()[:t]
length = t // 11
eigth = num.count('8')
zero = num.count('0')
if eigth == 0:
	print(0)
elif eigth > length:
	print(length)
else:
	print(eigth)


n = int(input())
s = input()
con = n // 11
if s.count('8') >= con and n >= 11:
	print(con)
elif s.count('8') != 0 and n >= 11:
	print(s.count('8'))
else:
	print(0)


n = int(input())
str = input()
a = str.count('8')
b = n // 11
print(min([a, b]))


from sys import stdin, stdout
from bisect import bisect_left, bisect_right
from collections import defaultdict
import math
from fractions import Fraction as frac
from random import random
cin = stdin.readline

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

def var(type=int):
	return type(stdin.readline())

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

def readlist(type=int):
	return list(map(type, stdin.readline().split()))

def sorted_indexes(arr):
	return sorted(range(len(arr)), key=arr.__getitem__)

def printr(arr):
	[stdout.write(str(x) + ' ') for x in arr]
	cout('')

def find_lt(a, x):
	i = bisect_left(a, x)
	if i:
		return a[i - 1]
	raise ValueError

def find_gt(a, x):
	i = bisect_right(a, x)
	if i != len(a):
		return a[i]
	raise ValueError

def dist(x, y):
	return math.sqrt(x * x + y * y)

def binary_search(arr, x):
	i = bisect_left(arr, x)
	if i == len(arr) or arr[i] != x:
		return -1
	return i
MOD2 = 998244353
n = var()
s = input()
e = 0
for c in s:
	if c == '8':
		e += 1
ans = 0
while n > 0 and e > 0:
	if n >= 11:
		n -= 11
		ans += 1
		e -= 1
	else:
		break
print(ans)