Buggy python submission (verdict: Time Limit Exceeded):
# from math import gcd
from fractions import gcd  # gcd: 2つの正の数を渡すと最大公約数を返す  # Atcoder ではこっち
from collections import defaultdict

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

# 正の公約数
cf=[] # 1が公約数なのは当然
min_num = min(a, b)+1
for i in range(2, min_num):
    if a % i == 0 and b % i == 0:
        cf.append(i)

# print(cf)

# 素数チェック
def is_prime(n):
    """
    Assumes that n is a positive natural number
    https://www.rookieslab.com/posts/fastest-way-to-check-if-a-number-is-prime-or-not
    """
    # We know 1 is not a prime number
    if n == 1:
        return False

    i = 2
    # This will loop from 2 to int(sqrt(x))
    while i*i <= n:
        # Check if i divides x without leaving a remainder
        if n % i == 0:
            # This means that n has a factor in between 2 and sqrt(n)
            # So it is not a prime number
            return False
        i += 1
    # If we did not find any factor in the above loop,
    # then n is a prime number
    return True

# disjoint_dict = defaultdict(lambda: True)

disjoint_dict = {i: True for i in cf}

# for i in range(0, len(cf)-1):

for i, cf_i in enumerate(cf):

    if is_prime(cf_i):  # 素数である
        continue
    if disjoint_dict[cf_i] == False:  # 既に互いに素ではないパターンが発見されている
        continue

    # for j in range(i, len(cf)):
    cf_for_j = cf[i:]
    for cf_j in cf_for_j:
        if disjoint_dict[cf_j] == False:
            continue

        if gcd(cf_i, cf_j) != 1:
            disjoint_dict[cf_j] = False

# print(disjoint_dict)
print(sum(disjoint_dict.values())+1)  # 1は必ず全ての数字に対して互いに素なので +1 する


Fixed submission:
"""
GCD(A, B) の公約数を素因数分解して出てきた素数の数+1 が答え.
"""

import math
from fractions import gcd  # gcd: 2つの正の数を渡すと最大公約数(Greatest Common Divisor)を返す  # Atcoder ではこっち
from collections import OrderedDict


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

# A, B の公約数 = gcd(a, b)の公約数
# GCD
gcd_num = gcd(a, b)

# 素因数分解
"""
N = p * q    (p <= q, pとqは素因数) の時
p <= sqrt(N)    となる

つまり, sqrt(N) まで試して, 割り切れなかった(残った)ものは素因数と言える.
言い方を変えると, sqrt(N)以上の素因数は高々1個まで.

これから, 順番に割っていくのをsqrt(N)までやり, 残ったのが1じゃなければそれも素数.
これなら計算量 O(sqrt(N)) でいける.
"""
def factorize(n):
    """素因数分解を行う

    Parameters
    ----------
    n : int
        正の自然数
    """
    res = dict()
    for i in range(2, math.ceil(math.sqrt(n))):
        if n%i:  # 割り切れなかったらcontinue
            continue
        res[i] = 0
        while (n%i == 0):
            n /= i
            res[i] += 1

    if (n != 1):
        res[n] = 1
    return res


res = factorize(gcd_num)
ans = len(res.keys()) + 1  # 1は必ず入る
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# from math import gcd
from fractions import gcd  # gcd: 2つの正の数を渡すと最大公約数を返す  # Atcoder ではこっち
from collections import defaultdict

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

# 正の公約数
cf=[] # 1が公約数なのは当然
for i in range(2,min(a, b)+1):
    if a % i == 0 and b % i == 0:
        cf.append(i)

# print(cf)

# 素数チェック
def is_prime(n):
    """
    Assumes that n is a positive natural number
    https://www.rookieslab.com/posts/fastest-way-to-check-if-a-number-is-prime-or-not
    """
    # We know 1 is not a prime number
    if n == 1:
        return False

    i = 2
    # This will loop from 2 to int(sqrt(x))
    while i*i <= n:
        # Check if i divides x without leaving a remainder
        if n % i == 0:
            # This means that n has a factor in between 2 and sqrt(n)
            # So it is not a prime number
            return False
        i += 1
    # If we did not find any factor in the above loop,
    # then n is a prime number
    return True

# disjoint_dict = defaultdict(lambda: True)

disjoint_dict = {i: True for i in cf}

# for i in range(0, len(cf)-1):

for i, cf_i in enumerate(cf):

    if is_prime(cf_i):  # 素数である
        continue
    if disjoint_dict[cf_i] == False:  # 既に互いに素ではないパターンが発見されている
        continue

    # for j in range(i, len(cf)):
    for cf_j in cf[i:]:
        if disjoint_dict[cf_j] == False:
            continue

        if gcd(cf_i, cf_j) != 1:
            disjoint_dict[cf_j] = False

# print(disjoint_dict)
print(sum(disjoint_dict.values())+1)  # 1は必ず全ての数字に対して互いに素なので +1 する


Fixed submission:
"""
GCD(A, B) の公約数を素因数分解して出てきた素数の数+1 が答え.
"""

import math
from fractions import gcd  # gcd: 2つの正の数を渡すと最大公約数(Greatest Common Divisor)を返す  # Atcoder ではこっち
from collections import OrderedDict


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

# A, B の公約数 = gcd(a, b)の公約数
# GCD
gcd_num = gcd(a, b)

# 素因数分解
"""
N = p * q    (p <= q, pとqは素因数) の時
p <= sqrt(N)    となる

つまり, sqrt(N) まで試して, 割り切れなかった(残った)ものは素因数と言える.
言い方を変えると, sqrt(N)以上の素因数は高々1個まで.

これから, 順番に割っていくのをsqrt(N)までやり, 残ったのが1じゃなければそれも素数.
これなら計算量 O(sqrt(N)) でいける.
"""
def factorize(n):
    """素因数分解を行う

    Parameters
    ----------
    n : int
        正の自然数
    """
    res = dict()
    for i in range(2, math.ceil(math.sqrt(n))):
        if n%i:  # 割り切れなかったらcontinue
            continue
        res[i] = 0
        while (n%i == 0):
            n /= i
            res[i] += 1

    if (n != 1):
        res[n] = 1
    return res


res = factorize(gcd_num)
ans = len(res.keys()) + 1  # 1は必ず入る
print(ans)