import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    def factorization(n):
        if n==1:
            return []
        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
    
    mod=10**9+7
    a,b=MI()
    from math import gcd
    g=gcd(a,b)
    arr=factorization(g)
    
    ans=len(arr)+1
    
    print(ans)
    
    
    

main() import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def I(): return int(input()) I def MI(): return map(int, input().split()) MI def LI(): return list(map(int, input().split())) LI def main():
    def factorization(n):
        if n==1:
            return []
        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
    
    mod=10**9+7
    a,b=MI()
    from math import gcd
    g=gcd(a,b)
    arr=factorization(g)
    
    ans=len(arr)+1
    
    print(ans)
    
    
     main def factorization(n):
        if n==1:
            return []
        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 if n==1:
            return []
         n==1 n 1 return [] [] 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 mod=10**9+7 mod 10**9+7 10**9 10 9 7 a,b=MI() a MI() MI b from math import gcd g=gcd(a,b) g gcd(a,b) gcd a b arr=factorization(g) arr factorization(g) factorization g ans=len(arr)+1 ans len(arr)+1 len(arr) len arr 1 print(ans) print ans main() main def LI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) LI def MI(): return map(int, input().split()) def MI(): return map(int, input().split()) MI input = sys.stdin.readline sys.stdin.readline input def I(): return int(input()) def I(): return int(input()) I def main():
    def factorization(n):
        if n==1:
            return []
        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
    
    mod=10**9+7
    a,b=MI()
    from math import gcd
    g=gcd(a,b)
    arr=factorization(g)
    
    ans=len(arr)+1
    
    print(ans)
    
    
     def main():
    def factorization(n):
        if n==1:
            return []
        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
    
    mod=10**9+7
    a,b=MI()
    from math import gcd
    g=gcd(a,b)
    arr=factorization(g)
    
    ans=len(arr)+1
    
    print(ans)
    
    
     main
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    def factorization(n):
        if n==1:
            return []
        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
    
    mod=10**9+7
    a,b=MI()
    from math import gcd
    g=gcd(a,b)
    arr=factorization(g)
    
    ans=len(arr)+1
    
    print(ans)
    
    
    

main()
