#Lutece2836. Rather Easy Problem

Rather Easy Problem

Migrated from Lutece 2836 Rather Easy Problem

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

Since few members in the training zoo would like to contribute problems to the UESTCPC 2077 Preliminary (almost all of them participate in it...), Kanade had to forcefully assign them the task of contributing problems.

Kanade found mm tool people and asked them to contribute problems. But she didn't tell them how many problems were needed. She intended them to guess the number. She told to the ii-th person that if the problems were divided into groups of bib_i, then aia_i problem(s) would be left.

The mm tool people gathered together. They knew that there wouldn't be more than nn problem(s) according to the restriction of DOMjudge. Let the number of problems needed be xx. They would like to know how many xx meets the conditions Kanade told to them.

Please note that at least one problem is needed for organizing the contest. And Kanade was kind enough that she didn't tell any wrong conditions to the tool people. But it seems that she doesn't realize that DOMjudge has a restriction on the number of problems.

Input

The first line contains two integers n,m (1n109,1m10)n,m\ (1\le n\le 10^9,1\le m\le 10), indicating the maximum problems that can be set on DOMjudge and the number of tool people.

The second line contains mm integers b1,b2,bm (1bi10)b_1,b_2,\ldots b_m\ (1\le b_i\le 10).

The third line contains mm integers a1,a2,,am (0ai<bi)a_1,a_2,\ldots ,a_m\ (0\le a_i<b_i).

Output

Output an integer in one line, indicating the number of xx which meets the conditions Kanade told to the tool people.

Samples

114 3
8 9 3
5 4 1
2

Note

Only 1313 and 8585 meet the conditions.

Resources

The 18th UESTC Programming Contest Preliminary