import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


# 実装を行う関数
def resolve(test_def_name=""):
    # 数値取得サンプル

    #   N行N項目 x = [list(map(int, input().split())) for i in range(n)]

    # 文字取得サンプル
    #   1行1項目 x = input()

    a, b = map(int, input().split())

    a = make_divisors(a)
    b = make_divisors(b)

    # 公約数 = 一致する値。
    a_b_divisor = list(set(a) & set(b))

    a_b_divisor.sort()

    if len(a_b_divisor) <= 1:
        print(len(a_b_divisor))
        return

    # エラストテネスの篩
    aa = -1
    for i in a_b_divisor[1:]:
        if len(a_b_divisor) <= 1:
            break

        if i > a_b_divisor[-1] / 2:
            break

        aa += 1
        sieve = i

        new_list = []

        for j in a_b_divisor:
            if j <= i or not j % sieve == 0:
                new_list.append(j)

        a_b_divisor = new_list

    print(len(a_b_divisor))

# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """12 18"""
        output = """3"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """420 660"""
        output = """4"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """1 2019"""
        output = """1"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main() import sys sys from io import StringIO import unittest unittest import os os sys.setrecursionlimit(999999999) sys.setrecursionlimit sys setrecursionlimit 999999999 def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


# 実装を行う関数 make_divisors lower_divisors, upper_divisors = [], [] lower_divisors [] upper_divisors [] i = 1 i 1 while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
     i * i <= n i * i i i n if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
         n % i == 0 n % i n i 0 lower_divisors.append(i) lower_divisors.append lower_divisors append i if i != n // i:
                upper_divisors.append(n // i)
         i != n // i i n // i n i upper_divisors.append(n // i) upper_divisors.append upper_divisors append n // i n i i += 1 i 1 return lower_divisors + upper_divisors[::-1] lower_divisors + upper_divisors[::-1] lower_divisors upper_divisors[::-1] upper_divisors ::-1 -1 n n def resolve(test_def_name=""):
    # 数値取得サンプル

    #   N行N項目 x = [list(map(int, input().split())) for i in range(n)]

    # 文字取得サンプル
    #   1行1項目 x = input()

    a, b = map(int, input().split())

    a = make_divisors(a)
    b = make_divisors(b)

    # 公約数 = 一致する値。
    a_b_divisor = list(set(a) & set(b))

    a_b_divisor.sort()

    if len(a_b_divisor) <= 1:
        print(len(a_b_divisor))
        return

    # エラストテネスの篩
    aa = -1
    for i in a_b_divisor[1:]:
        if len(a_b_divisor) <= 1:
            break

        if i > a_b_divisor[-1] / 2:
            break

        aa += 1
        sieve = i

        new_list = []

        for j in a_b_divisor:
            if j <= i or not j % sieve == 0:
                new_list.append(j)

        a_b_divisor = new_list

    print(len(a_b_divisor))

# テストクラス resolve a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b a = make_divisors(a) a make_divisors(a) make_divisors a b = make_divisors(b) b make_divisors(b) make_divisors b a_b_divisor = list(set(a) & set(b)) a_b_divisor list(set(a) & set(b)) list set(a) & set(b) set(a) set a set(b) set b a_b_divisor.sort() a_b_divisor.sort a_b_divisor sort if len(a_b_divisor) <= 1:
        print(len(a_b_divisor))
        return

    # エラストテネスの篩
     len(a_b_divisor) <= 1 len(a_b_divisor) len a_b_divisor 1 print(len(a_b_divisor)) print len(a_b_divisor) len a_b_divisor return aa = -1 aa -1 for i in a_b_divisor[1:]:
        if len(a_b_divisor) <= 1:
            break

        if i > a_b_divisor[-1] / 2:
            break

        aa += 1
        sieve = i

        new_list = []

        for j in a_b_divisor:
            if j <= i or not j % sieve == 0:
                new_list.append(j)

        a_b_divisor = new_list

     i a_b_divisor[1:] a_b_divisor 1: 1 if len(a_b_divisor) <= 1:
            break

         len(a_b_divisor) <= 1 len(a_b_divisor) len a_b_divisor 1 break if i > a_b_divisor[-1] / 2:
            break

         i > a_b_divisor[-1] / 2 i a_b_divisor[-1] / 2 a_b_divisor[-1] a_b_divisor -1 2 break aa += 1 aa 1 sieve = i sieve i new_list = [] new_list [] for j in a_b_divisor:
            if j <= i or not j % sieve == 0:
                new_list.append(j)

         j a_b_divisor if j <= i or not j % sieve == 0:
                new_list.append(j)

         j <= i or not j % sieve == 0 j <= i j i not j % sieve == 0 j % sieve == 0 j % sieve j sieve 0 new_list.append(j) new_list.append new_list append j a_b_divisor = new_list a_b_divisor new_list print(len(a_b_divisor)) print len(a_b_divisor) len a_b_divisor test_def_name="" test_def_name "" class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """12 18"""
        output = """3"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """420 660"""
        output = """4"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """1 2019"""
        output = """1"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し TestClass def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

     assertIO stdout, sat_in = sys.stdout, sys.stdin stdout sys.stdout sys stdout sat_in sys.stdin sys stdin sys.stdout, sys.stdin = StringIO(), StringIO(assert_input) sys.stdout sys stdout StringIO() StringIO sys.stdin sys stdin StringIO(assert_input) StringIO assert_input resolve(sys._getframe().f_back.f_code.co_name) resolve sys._getframe().f_back.f_code.co_name sys._getframe().f_back.f_code sys._getframe().f_back sys._getframe() sys._getframe sys _getframe f_back f_code co_name sys.stdout.seek(0) sys.stdout.seek sys.stdout sys stdout seek 0 out = sys.stdout.read()[:-1] out sys.stdout.read()[:-1] sys.stdout.read() sys.stdout.read sys.stdout sys stdout read :-1 -1 sys.stdout, sys.stdin = stdout, sat_in sys.stdout sys stdout stdout sys.stdin sys stdin sat_in self.assertEqual(out, output) self.assertEqual self assertEqual out output self self assert_input assert_input output output def test_input_1(self):
        test_input = """12 18"""
        output = """3"""
        self.assertIO(test_input, output)

     test_input_1 test_input = """12 18""" test_input """12 18""" output = """3""" output """3""" self.assertIO(test_input, output) self.assertIO self assertIO test_input output self self def test_input_2(self):
        test_input = """420 660"""
        output = """4"""
        self.assertIO(test_input, output)

     test_input_2 test_input = """420 660""" test_input """420 660""" output = """4""" output """4""" self.assertIO(test_input, output) self.assertIO self assertIO test_input output self self def test_input_3(self):
        test_input = """1 2019"""
        output = """1"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
     test_input_3 test_input = """1 2019""" test_input """1 2019""" output = """1""" output """1""" self.assertIO(test_input, output) self.assertIO self assertIO test_input output self self def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し tes_t_1original_1 test_input = """データ""" test_input """データ""" output = """データ""" output """データ""" self.assertIO(test_input, output) self.assertIO self assertIO test_input output self self unittest.TestCase unittest TestCase if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main() __name__ == "__main__" __name__ "__main__" if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main() os.environ.get("USERNAME") is None os.environ.get("USERNAME") os.environ.get os.environ os environ get "USERNAME" None resolve() resolve unittest.main() unittest.main unittest main class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """12 18"""
        output = """3"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """420 660"""
        output = """4"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """1 2019"""
        output = """1"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """12 18"""
        output = """3"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """420 660"""
        output = """4"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """1 2019"""
        output = """1"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し TestClass def resolve(test_def_name=""):
    # 数値取得サンプル

    #   N行N項目 x = [list(map(int, input().split())) for i in range(n)]

    # 文字取得サンプル
    #   1行1項目 x = input()

    a, b = map(int, input().split())

    a = make_divisors(a)
    b = make_divisors(b)

    # 公約数 = 一致する値。
    a_b_divisor = list(set(a) & set(b))

    a_b_divisor.sort()

    if len(a_b_divisor) <= 1:
        print(len(a_b_divisor))
        return

    # エラストテネスの篩
    aa = -1
    for i in a_b_divisor[1:]:
        if len(a_b_divisor) <= 1:
            break

        if i > a_b_divisor[-1] / 2:
            break

        aa += 1
        sieve = i

        new_list = []

        for j in a_b_divisor:
            if j <= i or not j % sieve == 0:
                new_list.append(j)

        a_b_divisor = new_list

    print(len(a_b_divisor))

# テストクラス def resolve(test_def_name=""):
    # 数値取得サンプル

    #   N行N項目 x = [list(map(int, input().split())) for i in range(n)]

    # 文字取得サンプル
    #   1行1項目 x = input()

    a, b = map(int, input().split())

    a = make_divisors(a)
    b = make_divisors(b)

    # 公約数 = 一致する値。
    a_b_divisor = list(set(a) & set(b))

    a_b_divisor.sort()

    if len(a_b_divisor) <= 1:
        print(len(a_b_divisor))
        return

    # エラストテネスの篩
    aa = -1
    for i in a_b_divisor[1:]:
        if len(a_b_divisor) <= 1:
            break

        if i > a_b_divisor[-1] / 2:
            break

        aa += 1
        sieve = i

        new_list = []

        for j in a_b_divisor:
            if j <= i or not j % sieve == 0:
                new_list.append(j)

        a_b_divisor = new_list

    print(len(a_b_divisor))

# テストクラス resolve def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


# 実装を行う関数 def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


# 実装を行う関数 make_divisors
import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


# 実装を行う関数
def resolve(test_def_name=""):
    # 数値取得サンプル

    #   N行N項目 x = [list(map(int, input().split())) for i in range(n)]

    # 文字取得サンプル
    #   1行1項目 x = input()

    a, b = map(int, input().split())

    a = make_divisors(a)
    b = make_divisors(b)

    # 公約数 = 一致する値。
    a_b_divisor = list(set(a) & set(b))

    a_b_divisor.sort()

    if len(a_b_divisor) <= 1:
        print(len(a_b_divisor))
        return

    # エラストテネスの篩
    aa = -1
    for i in a_b_divisor[1:]:
        if len(a_b_divisor) <= 1:
            break

        if i > a_b_divisor[-1] / 2:
            break

        aa += 1
        sieve = i

        new_list = []

        for j in a_b_divisor:
            if j <= i or not j % sieve == 0:
                new_list.append(j)

        a_b_divisor = new_list

    print(len(a_b_divisor))

# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """12 18"""
        output = """3"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """420 660"""
        output = """4"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """1 2019"""
        output = """1"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()
