Weights

No attempts yetTime limit3sMemory limit128 MB

Problem

The Byteotian Institute of Experimental Physics is moving to a new building, and transporting its large collection of precision weights has turned out to be tricky.

The Institute has a number of containers, each with a limited strength (the maximum total mass it can hold). We want to put as many weights as possible into the containers; any weights that do not fit are discarded. A container may hold any number of weights, as long as their total mass does not exceed its strength, and a container may also be left empty.

The weights have a special property: for any two of them, the mass of one is an integer multiple of the mass of the other (in particular, two weights may have equal mass).

Given the strengths of the containers and the masses of the weights, determine the maximum number of weights that can be placed into the containers.

Input

The first line contains two integers nn and mm (1n,m1000001 \le n, m \le 100\,000): the number of containers and the number of weights.

The second line contains nn integers w1,w2,,wnw_1, w_2, \ldots, w_n (1wi1000000001 \le w_i \le 100\,000\,000): the strengths of the containers, in milligrams.

The third line contains mm integers a1,a2,,ama_1, a_2, \ldots, a_m (1aj10000000001 \le a_j \le 1\,000\,000\,000): the masses of the weights, in milligrams. For any two weights, one mass is an integer multiple of the other.

Output

Print a single integer: the maximum number of weights that can be placed into the containers without exceeding any container's strength.