def factorization(n):
    arr = set()
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.add(i)

    if temp!=1:
        arr.add(temp)

    if arr==[]:
        arr.add(n)

    return arr

a,b = map(int, input().split())
a_soi = factorization(a)
b_soi = factorization(b)
both = list(a_soi & b_soi)
print(len(both)+1) def factorization(n):
    arr = set()
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.add(i)

    if temp!=1:
        arr.add(temp)

    if arr==[]:
        arr.add(n)

    return arr factorization arr = set() arr set() set temp = n temp n for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.add(i)

     i range(2, int(-(-n**0.5//1))+1) range 2 int(-(-n**0.5//1))+1 int(-(-n**0.5//1)) int -(-n**0.5//1) -n**0.5//1 -n**0.5 n**0.5 n 0.5 1 1 if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.add(i)

     temp%i==0 temp%i temp i 0 cnt=0 cnt 0 while temp%i==0:
                cnt+=1
                temp //= i
             temp%i==0 temp%i temp i 0 cnt+=1 cnt 1 temp //= i temp i arr.add(i) arr.add arr add i if temp!=1:
        arr.add(temp)

     temp!=1 temp 1 arr.add(temp) arr.add arr add temp if arr==[]:
        arr.add(n)

     arr==[] arr [] arr.add(n) arr.add arr add n return arr arr n n a,b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b a_soi = factorization(a) a_soi factorization(a) factorization a b_soi = factorization(b) b_soi factorization(b) factorization b both = list(a_soi & b_soi) both list(a_soi & b_soi) list a_soi & b_soi a_soi b_soi print(len(both)+1) print len(both)+1 len(both) len both 1 b_soi = factorization(b) factorization(b) b_soi b = map(int, input().split()) map(int, input().split()) b a_soi = factorization(a) factorization(a) a_soi a,b = map(int, input().split()) map(int, input().split()) a both = list(a_soi & b_soi) list(a_soi & b_soi) both def factorization(n):
    arr = set()
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.add(i)

    if temp!=1:
        arr.add(temp)

    if arr==[]:
        arr.add(n)

    return arr def factorization(n):
    arr = set()
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.add(i)

    if temp!=1:
        arr.add(temp)

    if arr==[]:
        arr.add(n)

    return arr factorization
def factorization(n):
    arr = set()
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.add(i)

    if temp!=1:
        arr.add(temp)

    if arr==[]:
        arr.add(n)

    return arr

a,b = map(int, input().split())
a_soi = factorization(a)
b_soi = factorization(b)
both = list(a_soi & b_soi)
print(len(both)+1)