# -*- coding: utf-8 -*-
"""
Created on Sun Sep 13 14:18:02 2020

@author: liang
"""

import math
from math import gcd
A, B = map(int,input().split())
g = gcd(A,B)
n = int(math.sqrt(g))
d_list = list()# 1

#約数チェック O(√n)
for i in range(1,n+1):
    if g % i == 0:
        j = g//i
        d_list.append(i)
        if j != 1:
            d_list.append(j)
d_list.sort()
#print(d_list)
ans_list = [1]
d_list.pop(0)
while d_list:
    t = d_list.pop(0)
    ans_list.append(t)
    d_list = [i for i in d_list if i%t != 0]
#print(d_list)
#print(ans_list)
print(len(ans_list)) """
Created on Sun Sep 13 14:18:02 2020

@author: liang
""" import math math from math import gcd A, B = map(int,input().split()) A map(int,input().split()) map int input().split() ().split () input split B g = gcd(A,B) g gcd(A,B) gcd A B n = int(math.sqrt(g)) n int(math.sqrt(g)) int math.sqrt(g) math.sqrt math sqrt g d_list = list() d_list list() list for i in range(1,n+1):
    if g % i == 0:
        j = g//i
        d_list.append(i)
        if j != 1:
            d_list.append(j) i range(1,n+1) range 1 n+1 n 1 if g % i == 0:
        j = g//i
        d_list.append(i)
        if j != 1:
            d_list.append(j) g % i == 0 g % i g i 0 j = g//i j g//i g i d_list.append(i) d_list.append d_list append i if j != 1:
            d_list.append(j) j != 1 j 1 d_list.append(j) d_list.append d_list append j d_list.sort() d_list.sort d_list sort ans_list = [1] ans_list [1] 1 d_list.pop(0) d_list.pop d_list pop 0 while d_list:
    t = d_list.pop(0)
    ans_list.append(t)
    d_list = [i for i in d_list if i%t != 0]
#print(d_list)
#print(ans_list) d_list t = d_list.pop(0) t d_list.pop(0) d_list.pop d_list pop 0 ans_list.append(t) ans_list.append ans_list append t i for i in d_list if i%t != 0 for i in d_list if i%t != 0 i d_list i%t != 0 i%t i t 0 if i%t != 0 i d_list = [i for i in d_list if i%t != 0] d_list [i for i in d_list if i%t != 0] print(len(ans_list)) print len(ans_list) len ans_list d_list = list() list() d_list j = g//i g//i j A, B = map(int,input().split()) map(int,input().split()) A t = d_list.pop(0) d_list.pop(0) t d_list = [i for i in d_list if i%t != 0] [i for i in d_list if i%t != 0] d_list B = map(int,input().split()) map(int,input().split()) B g = gcd(A,B) gcd(A,B) g ans_list = [1] [1] ans_list n = int(math.sqrt(g)) int(math.sqrt(g)) n
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 13 14:18:02 2020

@author: liang
"""

import math
from math import gcd
A, B = map(int,input().split())
g = gcd(A,B)
n = int(math.sqrt(g))
d_list = list()# 1

#約数チェック O(√n)
for i in range(1,n+1):
    if g % i == 0:
        j = g//i
        d_list.append(i)
        if j != 1:
            d_list.append(j)
d_list.sort()
#print(d_list)
ans_list = [1]
d_list.pop(0)
while d_list:
    t = d_list.pop(0)
    ans_list.append(t)
    d_list = [i for i in d_list if i%t != 0]
#print(d_list)
#print(ans_list)
print(len(ans_list))