# -*- coding: utf-8 -*-
from collections import defaultdict, deque
from heapq import heappush, heapreplace
from itertools import count
from math import ceil, sqrt
from fractions import gcd


class Primes_C(object):

    def b_search(L,t):
        #増大列LについてL[:+1]の要素すべてがt以下であるような最大のi<len(L)を返す。
        search_range = [-1, len(L)]
        update_range = lambda mid: search_range.__setitem__(t<L[mid], mid)
        for _ in range(search_range[1].bit_length()):
            update_range(sum(search_range)//2)
        return search_range[0]
    
    def __init__(self):
        self.P = [2]
        self.Pappend = self.P.append
        self.Q = deque([])
        self.Qappend = self.Q.append
        self.Qpopleft = self.Q.popleft
        self.hq = [] 
        self.integer = count(3,2)
        self.current_i = 2
        self.valid_range = 1
        self.iter_index = 0

    def __iter__(self):
        return self

    def __next__(self):
        if self.iter_index >= len(self.P):
            self.step_calc(1)
        self.iter_index += 1
        return self.P[self.iter_index-1]

    def iter_reset(self, index=0):
        self.iter_index = index

    def list(self, max_int=None):
        if max_int is None:
            return self.P[:]

        elif  max_int <= self.current_i:
            return self.P[:Primes_C.b_search(self.P,max_int)+1]

        else:
            self.calc(max_int)
            return self.P[:]

    def extend(self, i):
        if i >= self.valid_range:
            if self.Q:
                q = self.Qpopleft()
                heappush(self.hq, (q**2,q))
            self.valid_range = self.Q[0]**2 if self.Q else i**2

    def check_update(self,i):
        m,r = self.hq[0] if self.hq else (0,0)
        flag =  (i != m)
        if flag:
            self.Pappend(i)
            self.Qappend(i)
        while m == i:
            heapreplace(self.hq, (m+2*r, r))
            m,r = self.hq[0]
        return flag

    def calc(self, max_int):
        for i in self.integer:
            self.extend(i)
            self.check_update(i) 
            self.current_i = i+1
            if max_int <= self.current_i:
                break

    def step_calc(self, step):
        for i in self.integer:
            self.extend(i)
            step -= self.check_update(i) 
            self.current_i = i+1
            if not step:
                break

    def factorization(self, m, F=defaultdict(int), break_flag=False):
        if m <= 0:
            raise  ValueError('m >= 1')
        iter_index = self.iter_index
        self.iter_reset()
        flag = True
        for p in self:
            if flag:
                try:
                    max_int = ceil(sqrt(m))
                except OverflowError:
                    max_int = m//p

                flag = False
            if m >= p > max_int:
                F[m] += 1
                break
            while not m%p:
                m //= p
                F[p] += 1
                flag = True
            if (flag and break_flag) or m == 1:
                break
        F_ = dict(F)
        F.clear()
        self.iter_reset(iter_index)
        return F_

    def is_prime(self,m):
        F = self.factorization(m)
        return m in F



def solve():
    A, B = map(int, input().split())
    C = gcd(A,B)    
    P = Primes_C()
    F = P.factorization(C)
    res = len(F)+1
    return str(res)

if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 8376