def divisors(n):
    i = 1
    table = set()
    while i * i <= n:
        if not n % i:
            table.add(i)
            table.add(n//i)
        i += 1
    return table

def max2(x,y):
    return x if x > y else y

def rec(start_set, t):
    global res
    res = max2(res, t)
    next_set = []
    i = start_set[0]
    for j in start_set[1:]:
        if gcd(data[i], data[j]) == 1:
            next_set.append(j)
    if next_set:
        rec(next_set, t+1)
    return res

from math import gcd

A, B = map(int, input().split())
data = divisors(A) & divisors(B)
data = list(data)
data.sort()
L = len(data)
res = 0
print(rec(list(range(L)),1))


 def divisors(n):
    i = 1
    table = set()
    while i * i <= n:
        if not n % i:
            table.add(i)
            table.add(n//i)
        i += 1
    return table divisors i = 1 i 1 table = set() table set() set while i * i <= n:
        if not n % i:
            table.add(i)
            table.add(n//i)
        i += 1
     i * i <= n i * i i i n if not n % i:
            table.add(i)
            table.add(n//i)
         not n % i n % i n i table.add(i) table.add table add i table.add(n//i) table.add table add n//i n i i += 1 i 1 return table table n n def max2(x,y):
    return x if x > y else y max2 return x if x > y else y x if x > y else y x > y x y x y x x y y def rec(start_set, t):
    global res
    res = max2(res, t)
    next_set = []
    i = start_set[0]
    for j in start_set[1:]:
        if gcd(data[i], data[j]) == 1:
            next_set.append(j)
    if next_set:
        rec(next_set, t+1)
    return res rec global res res = max2(res, t) res max2(res, t) max2 res t next_set = [] next_set [] i = start_set[0] i start_set[0] start_set 0 for j in start_set[1:]:
        if gcd(data[i], data[j]) == 1:
            next_set.append(j)
     j start_set[1:] start_set 1: 1 if gcd(data[i], data[j]) == 1:
            next_set.append(j)
     gcd(data[i], data[j]) == 1 gcd(data[i], data[j]) gcd data[i] data i data[j] data j 1 next_set.append(j) next_set.append next_set append j if next_set:
        rec(next_set, t+1)
     next_set rec(next_set, t+1) rec next_set t+1 t 1 return res res start_set start_set t t from math import gcd A, B = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B data = divisors(A) & divisors(B) data divisors(A) & divisors(B) divisors(A) divisors A divisors(B) divisors B data = list(data) data list(data) list data data.sort() data.sort data sort L = len(data) L len(data) len data res = 0 res 0 print(rec(list(range(L)),1)) print rec(list(range(L)),1) rec list(range(L)) list range(L) range L 1 L = len(data) len(data) L res = 0 0 res data = list(data) list(data) data data = divisors(A) & divisors(B) divisors(A) & divisors(B) data def max2(x,y):
    return x if x > y else y def max2(x,y):
    return x if x > y else y max2 def rec(start_set, t):
    global res
    res = max2(res, t)
    next_set = []
    i = start_set[0]
    for j in start_set[1:]:
        if gcd(data[i], data[j]) == 1:
            next_set.append(j)
    if next_set:
        rec(next_set, t+1)
    return res def rec(start_set, t):
    global res
    res = max2(res, t)
    next_set = []
    i = start_set[0]
    for j in start_set[1:]:
        if gcd(data[i], data[j]) == 1:
            next_set.append(j)
    if next_set:
        rec(next_set, t+1)
    return res rec def divisors(n):
    i = 1
    table = set()
    while i * i <= n:
        if not n % i:
            table.add(i)
            table.add(n//i)
        i += 1
    return table def divisors(n):
    i = 1
    table = set()
    while i * i <= n:
        if not n % i:
            table.add(i)
            table.add(n//i)
        i += 1
    return table divisors B = map(int, input().split()) map(int, input().split()) B A, B = map(int, input().split()) map(int, input().split()) A
def divisors(n):
    i = 1
    table = set()
    while i * i <= n:
        if not n % i:
            table.add(i)
            table.add(n//i)
        i += 1
    return table

def max2(x,y):
    return x if x > y else y

def rec(start_set, t):
    global res
    res = max2(res, t)
    next_set = []
    i = start_set[0]
    for j in start_set[1:]:
        if gcd(data[i], data[j]) == 1:
            next_set.append(j)
    if next_set:
        rec(next_set, t+1)
    return res

from math import gcd

A, B = map(int, input().split())
data = divisors(A) & divisors(B)
data = list(data)
data.sort()
L = len(data)
res = 0
print(rec(list(range(L)),1))



