➽ Problem:-

https://www.hackerrank.com/challenges/between-two-sets/problem

➽ Solution:-

import math

import os

import random

import re

import sys

 

a, b = map(int,input().split())

x = list(map(int,input().split()))

y = list(map(int,input().split()))

ans = 0

for i in range(1, 101):

    temp = True

    for j in x:

        if i % j != 0:

            temp = False

            break

    if temp:

        for j in y:

            if j % i != 0:

                temp = False

                break

    if temp:

        ans += 1

print(ans)