#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 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 -th person that if the problems were divided into groups of , then problem(s) would be left.
The tool people gathered together. They knew that there wouldn't be more than problem(s) according to the restriction of DOMjudge. Let the number of problems needed be . They would like to know how many 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 , indicating the maximum problems that can be set on DOMjudge and the number of tool people.
The second line contains integers .
The third line contains integers .
Output
Output an integer in one line, indicating the number of which meets the conditions Kanade told to the tool people.
Samples
114 3
8 9 3
5 4 1
2
Note
Only and meet the conditions.
Resources
The 18th UESTC Programming Contest Preliminary