from math import gcd
A, B = map(int,input().split())
max_cmn_div = gcd(A, B)

# 約数列挙関数
def make_divisor(n):
    divisor = []
    for i in range(1, int(n**(1/2))+1):
        if n % i == 0:
            divisor.append(i)
            if i != n//i:
                divisor.append(n//i)
    return divisor

def check_prime(n):
    for i in range(2, int(n**(1/2))+1):
        if n % i == 0:
            return 0
    return 1

cmn_div = make_divisor(max_cmn_div)
ans = 0
for i in cmn_div:
    if check_prime(i):
        ans += 1
print(ans) from math import gcd A, B = map(int,input().split()) A map(int,input().split()) map int input().split() ().split () input split B max_cmn_div = gcd(A, B) max_cmn_div gcd(A, B) gcd A B def make_divisor(n):
    divisor = []
    for i in range(1, int(n**(1/2))+1):
        if n % i == 0:
            divisor.append(i)
            if i != n//i:
                divisor.append(n//i)
    return divisor make_divisor divisor = [] divisor [] for i in range(1, int(n**(1/2))+1):
        if n % i == 0:
            divisor.append(i)
            if i != n//i:
                divisor.append(n//i)
     i range(1, int(n**(1/2))+1) range 1 int(n**(1/2))+1 int(n**(1/2)) int n**(1/2) n 1/2 1 2 1 if n % i == 0:
            divisor.append(i)
            if i != n//i:
                divisor.append(n//i)
     n % i == 0 n % i n i 0 divisor.append(i) divisor.append divisor append i if i != n//i:
                divisor.append(n//i)
     i != n//i i n//i n i divisor.append(n//i) divisor.append divisor append n//i n i return divisor divisor n n def check_prime(n):
    for i in range(2, int(n**(1/2))+1):
        if n % i == 0:
            return 0
    return 1 check_prime for i in range(2, int(n**(1/2))+1):
        if n % i == 0:
            return 0
     i range(2, int(n**(1/2))+1) range 2 int(n**(1/2))+1 int(n**(1/2)) int n**(1/2) n 1/2 1 2 1 if n % i == 0:
            return 0
     n % i == 0 n % i n i 0 return 0 0 return 1 1 n n cmn_div = make_divisor(max_cmn_div) cmn_div make_divisor(max_cmn_div) make_divisor max_cmn_div ans = 0 ans 0 for i in cmn_div:
    if check_prime(i):
        ans += 1 i cmn_div if check_prime(i):
        ans += 1 check_prime(i) check_prime i ans += 1 ans 1 print(ans) print ans B = map(int,input().split()) map(int,input().split()) B max_cmn_div = gcd(A, B) gcd(A, B) max_cmn_div ans = 0 0 ans def make_divisor(n):
    divisor = []
    for i in range(1, int(n**(1/2))+1):
        if n % i == 0:
            divisor.append(i)
            if i != n//i:
                divisor.append(n//i)
    return divisor def make_divisor(n):
    divisor = []
    for i in range(1, int(n**(1/2))+1):
        if n % i == 0:
            divisor.append(i)
            if i != n//i:
                divisor.append(n//i)
    return divisor make_divisor def check_prime(n):
    for i in range(2, int(n**(1/2))+1):
        if n % i == 0:
            return 0
    return 1 def check_prime(n):
    for i in range(2, int(n**(1/2))+1):
        if n % i == 0:
            return 0
    return 1 check_prime cmn_div = make_divisor(max_cmn_div) make_divisor(max_cmn_div) cmn_div ans += 1 1 ans A, B = map(int,input().split()) map(int,input().split()) A
from math import gcd
A, B = map(int,input().split())
max_cmn_div = gcd(A, B)

# 約数列挙関数
def make_divisor(n):
    divisor = []
    for i in range(1, int(n**(1/2))+1):
        if n % i == 0:
            divisor.append(i)
            if i != n//i:
                divisor.append(n//i)
    return divisor

def check_prime(n):
    for i in range(2, int(n**(1/2))+1):
        if n % i == 0:
            return 0
    return 1

cmn_div = make_divisor(max_cmn_div)
ans = 0
for i in cmn_div:
    if check_prime(i):
        ans += 1
print(ans)