def factorize(n):
    fct = []
    b,e = 2,0
    while b*b <= n:
        while n % b == 0:
            n //= b
            e += 1
        if e > 0:
            fct.append((b,e))
        b,e = b+1,0
    if n > 1:
        fct.append((n,1))
    return fct
a,b = map(int,input().split())
ap = set()
for prime,count in factorize(a):
    ap.add(prime)
bp = set()
for prime,count in factorize(b):
    bp.add(prime)
print(len(ap&bp)+1) def factorize(n):
    fct = []
    b,e = 2,0
    while b*b <= n:
        while n % b == 0:
            n //= b
            e += 1
        if e > 0:
            fct.append((b,e))
        b,e = b+1,0
    if n > 1:
        fct.append((n,1))
    return fct factorize fct = [] fct [] b,e = 2,0 b 2 e 0 while b*b <= n:
        while n % b == 0:
            n //= b
            e += 1
        if e > 0:
            fct.append((b,e))
        b,e = b+1,0
     b*b <= n b*b b b n while n % b == 0:
            n //= b
            e += 1
         n % b == 0 n % b n b 0 n //= b n b e += 1 e 1 if e > 0:
            fct.append((b,e))
         e > 0 e 0 fct.append((b,e)) fct.append fct append (b,e) b e b,e = b+1,0 b b+1 b 1 e 0 if n > 1:
        fct.append((n,1))
     n > 1 n 1 fct.append((n,1)) fct.append fct append (n,1) n 1 return fct fct n n a,b = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b ap = set() ap set() set for prime,count in factorize(a):
    ap.add(prime) prime count factorize(a) factorize a ap.add(prime) ap.add ap add prime bp = set() bp set() set for prime,count in factorize(b):
    bp.add(prime) prime count factorize(b) factorize b bp.add(prime) bp.add bp add prime print(len(ap&bp)+1) print len(ap&bp)+1 len(ap&bp) len ap&bp ap bp 1 a,b = map(int,input().split()) map(int,input().split()) a ap = set() set() ap def factorize(n):
    fct = []
    b,e = 2,0
    while b*b <= n:
        while n % b == 0:
            n //= b
            e += 1
        if e > 0:
            fct.append((b,e))
        b,e = b+1,0
    if n > 1:
        fct.append((n,1))
    return fct def factorize(n):
    fct = []
    b,e = 2,0
    while b*b <= n:
        while n % b == 0:
            n //= b
            e += 1
        if e > 0:
            fct.append((b,e))
        b,e = b+1,0
    if n > 1:
        fct.append((n,1))
    return fct factorize b = map(int,input().split()) map(int,input().split()) b bp = set() set() bp
def factorize(n):
    fct = []
    b,e = 2,0
    while b*b <= n:
        while n % b == 0:
            n //= b
            e += 1
        if e > 0:
            fct.append((b,e))
        b,e = b+1,0
    if n > 1:
        fct.append((n,1))
    return fct
a,b = map(int,input().split())
ap = set()
for prime,count in factorize(a):
    ap.add(prime)
bp = set()
for prime,count in factorize(b):
    bp.add(prime)
print(len(ap&bp)+1)