Codeforces Round #513 by Barcelona Bootcamp (rated, Div. 1 + Div. 2).A. Phone Numbers

A. Phone Numbers

time limit per test

2 seconds

memory limit per test

512 megabytes

input

standard input

output

standard output

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 nn 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 nn — the number of cards with digits that you have (1≤n≤1001≤n≤100).

The second line contains a string of nn digits (characters "0", "1", ..., "9") s1,s2,…,sns1,s2,…,sn. 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

Copy

11
00000000008

output

Copy

1

input

Copy

22
0011223344556677889988

output

Copy

2

input

Copy

11
31415926535

output

Copy

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.

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(cin>>n){
        char a[110];
        int cnt=0;
        for(int i=0;i<n;i++){
            cin>>a[i];
            if(a[i]=='8') cnt++;
        }
        cout<<min(n/11,cnt)<<endl;
    }
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值