def factorization(n):
    arr = []
    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.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
def main3():
    n,m=map(int, input().split())
    k = factorization(n)
    k1 = factorization(m)

    y1 = set()
    y2 = set()

    for i in k:
        y1.add(i[0])
    for i in k1:
        y2.add(i[0])
    y1.add(1)
    y2.add(1)

    kouyaku = y1&y2
    print(len(kouyaku))



if __name__ == '__main__':
    main3() def factorization(n):
    arr = []
    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.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr factorization arr = [] arr [] 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.append([i, cnt])

     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.append([i, cnt])

     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.append([i, cnt]) arr.append arr append [i, cnt] i cnt if temp!=1:
        arr.append([temp, 1])

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

     arr==[] arr [] arr.append([n, 1]) arr.append arr append [n, 1] n 1 return arr arr n n def main3():
    n,m=map(int, input().split())
    k = factorization(n)
    k1 = factorization(m)

    y1 = set()
    y2 = set()

    for i in k:
        y1.add(i[0])
    for i in k1:
        y2.add(i[0])
    y1.add(1)
    y2.add(1)

    kouyaku = y1&y2
    print(len(kouyaku)) main3 n,m=map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m k = factorization(n) k factorization(n) factorization n k1 = factorization(m) k1 factorization(m) factorization m y1 = set() y1 set() set y2 = set() y2 set() set for i in k:
        y1.add(i[0])
     i k y1.add(i[0]) y1.add y1 add i[0] i 0 for i in k1:
        y2.add(i[0])
     i k1 y2.add(i[0]) y2.add y2 add i[0] i 0 y1.add(1) y1.add y1 add 1 y2.add(1) y2.add y2 add 1 kouyaku = y1&y2 kouyaku y1&y2 y1 y2 print(len(kouyaku)) print len(kouyaku) len kouyaku if __name__ == '__main__':
    main3() __name__ == '__main__' __name__ '__main__' main3() main3 def main3():
    n,m=map(int, input().split())
    k = factorization(n)
    k1 = factorization(m)

    y1 = set()
    y2 = set()

    for i in k:
        y1.add(i[0])
    for i in k1:
        y2.add(i[0])
    y1.add(1)
    y2.add(1)

    kouyaku = y1&y2
    print(len(kouyaku)) def main3():
    n,m=map(int, input().split())
    k = factorization(n)
    k1 = factorization(m)

    y1 = set()
    y2 = set()

    for i in k:
        y1.add(i[0])
    for i in k1:
        y2.add(i[0])
    y1.add(1)
    y2.add(1)

    kouyaku = y1&y2
    print(len(kouyaku)) main3 def factorization(n):
    arr = []
    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.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr def factorization(n):
    arr = []
    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.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr factorization
def factorization(n):
    arr = []
    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.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
def main3():
    n,m=map(int, input().split())
    k = factorization(n)
    k1 = factorization(m)

    y1 = set()
    y2 = set()

    for i in k:
        y1.add(i[0])
    for i in k1:
        y2.add(i[0])
    y1.add(1)
    y2.add(1)

    kouyaku = y1&y2
    print(len(kouyaku))



if __name__ == '__main__':
    main3()
