import math
import sys
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 euclid(a, b):
  if b == 0:
    return a
  else:
    return euclid(b, a%b)
a,b=map(int,input().split())
c=euclid(a,b)
if c==1:
  print(1)
  sys.exit()
print(len(factorization(c))+1) import math math import sys sys 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 euclid(a, b):
  if b == 0:
    return a
  else:
    return euclid(b, a%b) euclid if b == 0:
    return a
  else:
    return euclid(b, a%b) b == 0 b 0 return a a return euclid(b, a%b) euclid(b, a%b) euclid b a%b a b a a b b a,b=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b c=euclid(a,b) c euclid(a,b) euclid a b if c==1:
  print(1)
  sys.exit() c==1 c 1 print(1) print 1 sys.exit() sys.exit sys exit print(len(factorization(c))+1) print len(factorization(c))+1 len(factorization(c)) len factorization(c) factorization c 1 def euclid(a, b):
  if b == 0:
    return a
  else:
    return euclid(b, a%b) def euclid(a, b):
  if b == 0:
    return a
  else:
    return euclid(b, a%b) euclid b=map(int,input().split()) map(int,input().split()) b c=euclid(a,b) euclid(a,b) c 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 a,b=map(int,input().split()) map(int,input().split()) a
import math
import sys
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 euclid(a, b):
  if b == 0:
    return a
  else:
    return euclid(b, a%b)
a,b=map(int,input().split())
c=euclid(a,b)
if c==1:
  print(1)
  sys.exit()
print(len(factorization(c))+1)