def main():
    import sys
    input = sys.stdin.readline
    
    a,b = map(int,input().split())

    #gcd(a,b)の素因数分解
    import math
    gcd = math.gcd(a,b)

    p = []
    for i in range(2,int(math.sqrt(gcd))+1):
        while gcd % i == 0:
            gcd /= i
            p.append(i)
            
    p.append(int(gcd))
    p.append(1)
    print(len(list(set(p))))

if __name__=='__main__':
    main() def main():
    import sys
    input = sys.stdin.readline
    
    a,b = map(int,input().split())

    #gcd(a,b)の素因数分解
    import math
    gcd = math.gcd(a,b)

    p = []
    for i in range(2,int(math.sqrt(gcd))+1):
        while gcd % i == 0:
            gcd /= i
            p.append(i)
            
    p.append(int(gcd))
    p.append(1)
    print(len(list(set(p)))) main import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline a,b = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b import math math gcd = math.gcd(a,b) gcd math.gcd(a,b) math.gcd math gcd a b p = [] p [] for i in range(2,int(math.sqrt(gcd))+1):
        while gcd % i == 0:
            gcd /= i
            p.append(i)
            
     i range(2,int(math.sqrt(gcd))+1) range 2 int(math.sqrt(gcd))+1 int(math.sqrt(gcd)) int math.sqrt(gcd) math.sqrt math sqrt gcd 1 while gcd % i == 0:
            gcd /= i
            p.append(i)
            
     gcd % i == 0 gcd % i gcd i 0 gcd /= i gcd i p.append(i) p.append p append i p.append(int(gcd)) p.append p append int(gcd) int gcd p.append(1) p.append p append 1 print(len(list(set(p)))) print len(list(set(p))) len list(set(p)) list set(p) set p if __name__=='__main__':
    main() __name__=='__main__' __name__ '__main__' main() main def main():
    import sys
    input = sys.stdin.readline
    
    a,b = map(int,input().split())

    #gcd(a,b)の素因数分解
    import math
    gcd = math.gcd(a,b)

    p = []
    for i in range(2,int(math.sqrt(gcd))+1):
        while gcd % i == 0:
            gcd /= i
            p.append(i)
            
    p.append(int(gcd))
    p.append(1)
    print(len(list(set(p)))) def main():
    import sys
    input = sys.stdin.readline
    
    a,b = map(int,input().split())

    #gcd(a,b)の素因数分解
    import math
    gcd = math.gcd(a,b)

    p = []
    for i in range(2,int(math.sqrt(gcd))+1):
        while gcd % i == 0:
            gcd /= i
            p.append(i)
            
    p.append(int(gcd))
    p.append(1)
    print(len(list(set(p)))) main
def main():
    import sys
    input = sys.stdin.readline
    
    a,b = map(int,input().split())

    #gcd(a,b)の素因数分解
    import math
    gcd = math.gcd(a,b)

    p = []
    for i in range(2,int(math.sqrt(gcd))+1):
        while gcd % i == 0:
            gcd /= i
            p.append(i)
            
    p.append(int(gcd))
    p.append(1)
    print(len(list(set(p))))

if __name__=='__main__':
    main()