#H2026TEST1. Divisor Friendship

Divisor Friendship

Background

There are nn robots in Workshop Alpha and mm robots in Workshop Beta. Every robot has a unique-looking serial number, and two robots become compatible when the serial number of the Alpha robot is a divisor of the serial number of the Beta robot.

The factory wants to know how many compatible cross-workshop pairs can be formed.

Problem

You are given two sequences:

  • A1,A2,,AnA_1, A_2, \dots, A_n: serial numbers of the robots in Workshop Alpha;
  • B1,B2,,BmB_1, B_2, \dots, B_m: serial numbers of the robots in Workshop Beta.

Count the number of pairs (i,j)(i, j) such that 1in1 \le i \le n, 1jm1 \le j \le m, and

BjmodAi=0.B_j \bmod A_i = 0.

Input Format

The first line contains two integers nn and mm, separated by a space.

The second line contains nn integers A1,A2,,AnA_1, A_2, \dots, A_n.

The third line contains mm integers B1,B2,,BmB_1, B_2, \dots, B_m.

Output Format

Output a single integer: the number of compatible pairs.

Samples

Sample 1

Input:

2 3
2 3
2 6 9

Output:

4

Explanation:

22 divides 22 and 66; 33 divides 66 and 99. There are 44 compatible pairs.

Sample 2

Input:

3 3
2 2 5
4 10 5

Output:

6

Explanation:

Each of the two 22's matches 44 and 1010; the single 55 matches 1010 and 55. The total is 2×2+1×2=62 \times 2 + 1 \times 2 = 6.

Constraints

  • 1n,m2×1051 \le n, m \le 2 \times 10^5
  • 1Ai,Bj1061 \le A_i, B_j \le 10^6

The answer may exceed the range of a 32-bit signed integer.