PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#QHD0000074. Chọn tập có nhiều chữ số 0 cuối (Round Subset)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Chọn tập có nhiều chữ số 0 cuối (Round Subset)

Round Subset

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Given nn positive integers a1,…,ana_1,\ldots,a_n, choose exactly kk distinct indices and multiply the numbers at those indices. The roundness of a positive integer is the number of trailing zero digits in its decimal representation: 10001000 has roundness 33, 8080 has roundness 11, and 7777 has roundness 00.

Find the maximum attainable roundness over all choices of exactly kk indices. Equal values at different indices may both be selected, but no index may be used twice.

Each input number can reach 101810^{18}, so the chosen product may not fit in a 64-bit integer. You should reason about the counts of prime factors 22 and 55 rather than multiply the selected numbers.

Input

The first line contains n,kn,k. The second line contains nn positive integers aia_i.

Output

Print one integer: the maximum number of trailing zeroes in the product of exactly kk selected elements.

Subtasks

  • Subtask 1 (20 points): 1≤k≤n≤121\le k\le n\le12; 1≤ai≤1091\le a_i\le10^9; choose exactly kk indices.

  • Subtask 2 (30 points): 1≤k≤n≤701\le k\le n\le70; 1≤ai≤10121\le a_i\le10^{12}; choose exactly kk indices.

  • Subtask 3 (50 points): 1≤k≤n≤2001\le k\le n\le200; 1≤ai≤10181\le a_i\le10^{18}; choose exactly kk indices.

Examples

Example 1

Input

3 2
50 4 20

Output

3

Explanation

The pairs yield 200200 (two zeros), 8080 (one zero), and 10001000 (three zeros), respectively; therefore the maximum is 33.

Example 2

Input

5 3
15 16 3 25 9

Output

3

Explanation

Selecting 15,16,2515,16,25 gives the product 60006000, ending with three zeros; no selection does better.

Example 3

Input

3 3
9 77 13

Output

0

Explanation

None of the numbers contributes a factor 22 or 55, so the product has no trailing zeroes.