import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


a,b = list(map(int, input().split()))
def factor(n, m=None):
    # mを与えると、高々その素因数まで見て、残りは分解せずにそのまま出力する
    arr = {}
    temp = n
    M = int(-(-n**0.5//1))+1
    if m is not None:
        M = min(m+1, M)
    for i in range(2, M):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i] = cnt

    if temp!=1:
        arr[temp] = 1

    if not arr:
        arr[n] = 1

    return arr
fa = factor(a)
fb = factor(b)
if 1 in fa:
    del fa[1]
if 1 in fb:
    del fb[1]
d = set(list(fa.keys())) & set(list(fb.keys()))
ans = len(d) + 1
print(ans) import sys sys input = lambda : sys.stdin.readline().rstrip() input lambda : sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip sys.setrecursionlimit(max(1000, 10**9)) sys.setrecursionlimit sys setrecursionlimit max(1000, 10**9) max 1000 10**9 10 9 write = lambda x: sys.stdout.write(x+"\n") write lambda x: sys.stdout.write(x+"\n") sys.stdout.write(x+"\n") sys.stdout.write sys.stdout sys stdout write x+"\n" x "\n" x a,b = list(map(int, input().split())) a list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split b def factor(n, m=None):
    # mを与えると、高々その素因数まで見て、残りは分解せずにそのまま出力する
    arr = {}
    temp = n
    M = int(-(-n**0.5//1))+1
    if m is not None:
        M = min(m+1, M)
    for i in range(2, M):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i] = cnt

    if temp!=1:
        arr[temp] = 1

    if not arr:
        arr[n] = 1

    return arr factor arr = {} arr {} temp = n temp n M = int(-(-n**0.5//1))+1 M 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 m is not None:
        M = min(m+1, M)
     m is not None m None M = min(m+1, M) M min(m+1, M) min m+1 m 1 M for i in range(2, M):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i] = cnt

     i range(2, M) range 2 M if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[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[i] = cnt arr[i] arr i cnt if temp!=1:
        arr[temp] = 1

     temp!=1 temp 1 arr[temp] = 1 arr[temp] arr temp 1 if not arr:
        arr[n] = 1

     not arr arr arr[n] = 1 arr[n] arr n 1 return arr arr n n m=None m None fa = factor(a) fa factor(a) factor a fb = factor(b) fb factor(b) factor b if 1 in fa:
    del fa[1] 1 in fa 1 fa del fa[1] fa[1] fa 1 if 1 in fb:
    del fb[1] 1 in fb 1 fb del fb[1] fb[1] fb 1 d = set(list(fa.keys())) & set(list(fb.keys())) d set(list(fa.keys())) & set(list(fb.keys())) set(list(fa.keys())) set list(fa.keys()) list fa.keys() fa.keys fa keys set(list(fb.keys())) set list(fb.keys()) list fb.keys() fb.keys fb keys ans = len(d) + 1 ans len(d) + 1 len(d) len d 1 print(ans) print ans b = list(map(int, input().split())) list(map(int, input().split())) b fb = factor(b) factor(b) fb d = set(list(fa.keys())) & set(list(fb.keys())) set(list(fa.keys())) & set(list(fb.keys())) d a,b = list(map(int, input().split())) list(map(int, input().split())) a ans = len(d) + 1 len(d) + 1 ans fa = factor(a) factor(a) fa write = lambda x: sys.stdout.write(x+"\n") lambda x: sys.stdout.write(x+"\n") write input = lambda : sys.stdin.readline().rstrip() lambda : sys.stdin.readline().rstrip() input def factor(n, m=None):
    # mを与えると、高々その素因数まで見て、残りは分解せずにそのまま出力する
    arr = {}
    temp = n
    M = int(-(-n**0.5//1))+1
    if m is not None:
        M = min(m+1, M)
    for i in range(2, M):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i] = cnt

    if temp!=1:
        arr[temp] = 1

    if not arr:
        arr[n] = 1

    return arr def factor(n, m=None):
    # mを与えると、高々その素因数まで見て、残りは分解せずにそのまま出力する
    arr = {}
    temp = n
    M = int(-(-n**0.5//1))+1
    if m is not None:
        M = min(m+1, M)
    for i in range(2, M):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i] = cnt

    if temp!=1:
        arr[temp] = 1

    if not arr:
        arr[n] = 1

    return arr factor
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


a,b = list(map(int, input().split()))
def factor(n, m=None):
    # mを与えると、高々その素因数まで見て、残りは分解せずにそのまま出力する
    arr = {}
    temp = n
    M = int(-(-n**0.5//1))+1
    if m is not None:
        M = min(m+1, M)
    for i in range(2, M):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i] = cnt

    if temp!=1:
        arr[temp] = 1

    if not arr:
        arr[n] = 1

    return arr
fa = factor(a)
fb = factor(b)
if 1 in fa:
    del fa[1]
if 1 in fb:
    del fb[1]
d = set(list(fa.keys())) & set(list(fb.keys()))
ans = len(d) + 1
print(ans)