import sys
input = sys.stdin.readline
from collections import defaultdict, deque

def F(n: int):
    i = 2
    while i * i <= n:
        while n % i == 0: yield i; n //= i
        i += 1
    if n != 1: yield n

(a, b), c = map(lambda x: set(F(int(x))), input().split()), 0
for i in a: c += 1 if i in b else 0
print(c + 1) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline from collections import defaultdict, deque def F(n: int):
    i = 2
    while i * i <= n:
        while n % i == 0: yield i; n //= i
        i += 1
    if n != 1: yield n F i = 2 i 2 while i * i <= n:
        while n % i == 0: yield i; n //= i
        i += 1
     i * i <= n i * i i i n while n % i == 0: yield i; n //= i
         n % i == 0 n % i n i 0 i += 1 i 1 if n != 1: yie n != 1 n 1 n: int n (a, b), c = map(lambda x: set(F(int(x))), input().split()), 0 (a, b) a b map(lambda x: set(F(int(x))), input().split()) map lambda x: set(F(int(x))) set(F(int(x))) set F(int(x)) F int(x) int x x input().split() ().split () input split c 0 for i in a: c += 1 if i in b else 0 i a print(c + 1) print c + 1 c 1 c = map(lambda x: set(F(int(x))), input().split()), 0 0 c def F(n: int):
    i = 2
    while i * i <= n:
        while n % i == 0: yield i; n //= i
        i += 1
    if n != 1: yield n def F(n: int):
    i = 2
    while i * i <= n:
        while n % i == 0: yield i; n //= i
        i += 1
    if n != 1: yield n F input = sys.stdin.readline sys.stdin.readline input
import sys
input = sys.stdin.readline
from collections import defaultdict, deque

def F(n: int):
    i = 2
    while i * i <= n:
        while n % i == 0: yield i; n //= i
        i += 1
    if n != 1: yield n

(a, b), c = map(lambda x: set(F(int(x))), input().split()), 0
for i in a: c += 1 if i in b else 0
print(c + 1)