from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(100000000)
mod = 1000000007
"""
#N,K,Mが入力
    n,k,m=LI() 
    #N
    #x1 y1
    #.  .
    #xn ynが入力
    N=I()
    p=LIR(N)
    print(n,k,m,p)
"""
############################## ユニオン木(union tree) ###################################
#uf=UnionFind(n)と使う
# print(uf.roots())
# print(uf.all_group_members())
class UnionFind:
    def __init__(self, n):
        self.n=n
        self.par = [-1 for i in range(self.n+1)]
        self.rank = [0 for i in range(self.n+1)]#素集合でないとrankは意味がなさそう,素集合であればrank kには少なくとも2^k要素がある。
    
    # 検索
    def find(self, x):
        # if self.par[x] == x:
        if self.par[x] <0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
        
    # 同じ集合に属するか判定
    def same(self, x, y):
        return self.find(x) == self.find(y)

    #要素xが属するグループに属する要素をリストで返す
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n+1) if self.find(i) == root]

    #すべての根の要素をリストで返す
    def roots(self):
        return [i for i, x in enumerate(self.par) if x<0]

    #グループの数を返す
    def group_count(self):
        return len(self.roots())

    #{ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す
    def all_group_members(self):
        return {int(r):self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
    

#辞書やタプルで使えるようにクラスを継承 l = ['A', 'B', 'C', 'D', 'E']とかを想定
class UnionFindLabel(UnionFind):
    def __init__(self, labels):
        assert len(labels) == len(set(labels))
        self.n = len(labels)
        labels=[0]+labels#n+1と合わせるため
        self.par = [-1 for i in range(self.n+1)]
        self.d = {x: i for i, x in enumerate(labels)}
        self.d_inv = {i: x for i, x in enumerate(labels)}
        self.rank = [0 for i in range(self.n+1)]#素集合でないとrankは意味がなさそう,素集合であればrank kには少なくとも2^k要素がある。

    def find_label(self, x):
        return self.d_inv[super().find(self.d[x])]

    def union_label(self, x, y):
        super().union(self.d[x], self.d[y])

    #def size(self, x):
    #    return super().size(self.d[x])

    def same_label(self, x, y):
        return super().same(self.d[x], self.d[y])

    def members_label(self, x):
        root = self.find(self.d[x])
        return [self.d_inv[i] for i in range(self.n+1) if self.find(i) == root]

    def roots_label(self):
        return [self.d_inv[i] for i, x in enumerate(self.par) if x<0]
    
    def all_group_members_label(self):
        return {int(r):self.members_label(r) for r in self.roots_label()}


########### nの約数を全て求める ##################
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
########## 素因数分解のリスト
def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(int(i))
        i += 1
    if n > 1:
        table.append(int(n))
    return table

############## a,bの最大公約数 ##################


#こっちのほうがいい？
import fractions

def comdiv(a,b):
    ta=set(divisor(a))
    tb=set(divisor(b))
    t=ta & tb
    return list(t)

def resolve():
    a,b=LI()
    buf=fractions.gcd(a,b)
    t=prime_decomposition(buf)
    #t=comdiv(a,b)
    #uf=UnionFindLabel(t)
    #print(uf.all_group_members_label())
    s=set(t)
    print(len(s)+1)
    #print(uf.all_group_members_label())
    """
    ans=set()
    for i in t:
        buf=set(divisor(i))
        if len(buf)>2:
            l={1,i}
            buf=buf-l
        ans=ans | buf
    """


    return

import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """12 18"""
        output = """3"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """420 660"""
        output = """4"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """1 2019"""
        output = """1"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Measured memory_bytes: 75524