QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 32 MB Total points: 100

#12697. Weights

统计

While moving to a new compound the Byteotian Institute of Experimental Physics has encountered a logistical problem - the transfer of its vast collection of precision weights turned out to be non-trivial.

The Institute has a certain number of containers of limited strength at its disposal. As many weights as possible are to be put into the containers, the remaining ones will be discarded. There is no limit on the number of weights to be put in a container apart from the requirement of not exceeding its strength. A container may also be empty.

Any two weights in the Institute have a peculiar property: the mass of one of them is an integer multiple of the mass of the other. Particularly, they may have the same mass.

Write a programme which:

  • reads the durabilities of the containers and masses of the weights from the standard input,
  • determines the maximal number of weights that can be put in the containers,
  • writes the outcome to the standard output.

Input

The first line of the standard input contains two integers $n$ and $m$ ($1 ≤ n,m ≤ 100\,000$), separated by a single space, denoting respectively: the number of containers and the number of weights. The second line of the standard input consists of n integers $w_i$ ($1 ≤ w_i ≤ 100,000,000$ for $1 ≤ i ≤ n$), separated by single spaces, denoting the strengths of containers in milligrammes. In the third line there are $m$ integers $m_j$ ($1 ≤ m_j ≤ 1\,000\,000\,000$ for $1 ≤ j ≤ m$), separated by single spaces, denoting masses of the weights in milligrammes.

Output

The first and only line of the standard output should contain a single integer - the maximal number of weights that can be placed in the containers without exceeding their durability.

Example

Input

2 4
13 9
4 12 2 4

Output

3
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.