Build More 2020's!

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

Byteazar got a string SS (s_1s_ns\_1 \dots s\_n) of length nn consisting of only digits '0', '1', and '2', and he wants to pick some disjoint subsequences which equal to 20202020, as many as possible.

Formally, Byteazar would like to find kk quadruples (a_1,b_1,c_1,d_1),,(a_k,b_k,c_k,d_k)(a\_1, b\_1, c\_1, d\_1), \dots, (a\_k, b\_k, c\_k, d\_k)  such as

  • 1a_i<b_i<c_i<d_in1 \leq a\_i < b\_i < c\_i < d\_i \leq n
  • s_a_is_b_is_c_is_d_i=2020s\_{a\_i} s\_{b\_i} s\_{c\_i} s\_{d\_i} = 2020
  • a_i,b_i,c_i,d_ia_j,b_j,c_j,d_j=\\{a\_i, b\_i, c\_i, d\_i\\} \cap \\{a\_j, b\_j, c\_j, d\_j\\} = \emptyset for iji \neq j.

Find the maximum value of kk.

입력

The input consists of several test cases terminated by end-of-file.

The first line of each test case contains an integer nn (1n1051 \le n \le 10^5). Second line contains the string SS (s_1s_ns\_1 \dots s\_n). (s_i0,1,2s\_i \in \\{0, 1, 2\\}). Sum of nn in all test cases does not exceed 10610^6.

출력

For each test case print an integer which denotes the result.