from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

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

a, b = MAP()
n = gcd(a, b)
s = sorted(divisor(n))
t = [1]*len(s)

ans = 0
for i in range(1, len(s)-1):
    if t[i] == 0:
        continue
    else:
        for j in range(i+1, len(s)):
            if t[j] == 0:
                continue
            else:
                if s[j] % s[i] == 0:
                    t[j] = 0
print(sum(t)) from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf from itertools import accumulate,permutations,combinations,product,combinations_with_replacement from collections import deque,defaultdict,Counter from bisect import bisect_left,bisect_right from operator import itemgetter from heapq import heapify,heappop,heappush from copy import deepcopy from time import time import string string import sys sys sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 def input() : return sys.stdin.readline().strip() input def INT()   : return int(input()) INT def MAP()   : return map(int,input().split()) MAP def LIST()  : return list(MAP()) LIST 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 divisor i = 1 i 1 table = [] table [] while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
     i * i <= n i * i i i n if n%i == 0:
            table.append(i)
            table.append(n//i)
         n%i == 0 n%i n i 0 table.append(i) table.append table append i table.append(n//i) table.append table append n//i n i i += 1 i 1 table = list(set(table)) table list(set(table)) list set(table) set table return table table n n a, b = MAP() a MAP() MAP b n = gcd(a, b) n gcd(a, b) gcd a b s = sorted(divisor(n)) s sorted(divisor(n)) sorted divisor(n) divisor n t = [1]*len(s) t [1]*len(s) [1] 1 len(s) len s ans = 0 ans 0 for i in range(1, len(s)-1):
    if t[i] == 0:
        continue
    else:
        for j in range(i+1, len(s)):
            if t[j] == 0:
                continue
            else:
                if s[j] % s[i] == 0:
                    t[j] = 0 i range(1, len(s)-1) range 1 len(s)-1 len(s) len s 1 if t[i] == 0:
        continue
    else:
        for j in range(i+1, len(s)):
            if t[j] == 0:
                continue
            else:
                if s[j] % s[i] == 0:
                    t[j] = 0 t[i] == 0 t[i] t i 0 continue for j in range(i+1, len(s)):
            if t[j] == 0:
                continue
            else:
                if s[j] % s[i] == 0:
                    t[j] = 0 j range(i+1, len(s)) range i+1 i 1 len(s) len s if t[j] == 0:
                continue
            else:
                if s[j] % s[i] == 0:
                    t[j] = 0 t[j] == 0 t[j] t j 0 continue if s[j] % s[i] == 0:
                    t[j] = 0 s[j] % s[i] == 0 s[j] % s[i] s[j] s j s[i] s i 0 t[j] = 0 t[j] t j 0 print(sum(t)) print sum(t) sum t n = gcd(a, b) gcd(a, b) n s = sorted(divisor(n)) sorted(divisor(n)) s def LIST()  : return list(MAP()) def LIST()  : return list(MAP()) LIST b = MAP() MAP() b def input() : return sys.stdin.readline().strip() def input() : return sys.stdin.readline().strip() input def INT()   : return int(input()) def INT()   : return int(input()) INT 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 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 divisor ans = 0 0 ans def MAP()   : return map(int,input().split()) def MAP()   : return map(int,input().split()) MAP a, b = MAP() MAP() a t = [1]*len(s) [1]*len(s) t
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

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

a, b = MAP()
n = gcd(a, b)
s = sorted(divisor(n))
t = [1]*len(s)

ans = 0
for i in range(1, len(s)-1):
    if t[i] == 0:
        continue
    else:
        for j in range(i+1, len(s)):
            if t[j] == 0:
                continue
            else:
                if s[j] % s[i] == 0:
                    t[j] = 0
print(sum(t))