import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

immutable long MOD = 10^^9 + 7;

void main() {
    auto N = readln.chomp.to!int;
    auto S = readln.chomp;

    auto cnt = new int[](2);
    foreach (s; S) cnt[s=='8'] += 1;

    int ans = 0;
    while (cnt[1]) {
        cnt[1] -= 1;
        int x = min(10, cnt[0]);
        cnt[0] -= x;
        int y = min(10-x, cnt[1]);
        cnt[1] -= y;
        if (x + y < 10) break;
        ans += 1;
    }

    ans.writeln;
}
