import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    a,b = i_map()

    def prime_decomposition(n):
        i = 2
        table = []
        while i * i <= n: # sqrt(n)で計算が済む
            while n % i == 0:
                n //= i
                table.append(i)
            i += 1
        if n > 1:
            table.append(n)
        return table

    a = set(prime_decomposition(a))
    b = set(prime_decomposition(b))
    print(len(a&b)+1)



if __name__=="__main__":
    main() import math math from math import gcd,pi,sqrt INF = float("inf") INF float("inf") float "inf" import sys sys sys.setrecursionlimit(10**6) sys.setrecursionlimit sys setrecursionlimit 10**6 10 6 import itertools itertools from collections import Counter,deque def i_input(): return int(input()) i_input def i_map(): return map(int, input().split()) i_map def i_list(): return list(i_map()) i_list i_input() for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) i_input() i_input def i_row(N): return [i_input() for _ in range(N)] i_row N N i_list() for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) i_list() i_list def i_row_list(N): return [i_list() for _ in range(N)] i_row_list N N def s_input(): return input() s_input def s_map(): return input().split() s_map def s_list(): return list(s_map()) s_list s_input for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) s_input def s_row(N): return [s_input for _ in range(N)] s_row N N s_list() for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) s_list() s_list def s_row_str(N): return [s_list() for _ in range(N)] s_row_str N N list(s_input()) for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) list(s_input()) list s_input() s_input def s_row_list(N): return [list(s_input()) for _ in range(N)] s_row_list N N def main():
    a,b = i_map()

    def prime_decomposition(n):
        i = 2
        table = []
        while i * i <= n: # sqrt(n)で計算が済む
            while n % i == 0:
                n //= i
                table.append(i)
            i += 1
        if n > 1:
            table.append(n)
        return table

    a = set(prime_decomposition(a))
    b = set(prime_decomposition(b))
    print(len(a&b)+1) main a,b = i_map() a i_map() i_map b def prime_decomposition(n):
        i = 2
        table = []
        while i * i <= n: # sqrt(n)で計算が済む
            while n % i == 0:
                n //= i
                table.append(i)
            i += 1
        if n > 1:
            table.append(n)
        return table

     prime_decomposition i = 2 i 2 table = [] table [] while i * i <= n: # sqrt(n)で計算が済む
            while n % i == 0:
                n //= i
                table.append(i)
            i += 1
         i * i <= n i * i i i n while n % i == 0:
                n //= i
                table.append(i)
             n % i == 0 n % i n i 0 n //= i n i table.append(i) table.append table append i i += 1 i 1 if n > 1:
            table.append(n)
         n > 1 n 1 table.append(n) table.append table append n return table table n n a = set(prime_decomposition(a)) a set(prime_decomposition(a)) set prime_decomposition(a) prime_decomposition a b = set(prime_decomposition(b)) b set(prime_decomposition(b)) set prime_decomposition(b) prime_decomposition b print(len(a&b)+1) print len(a&b)+1 len(a&b) len a&b a b 1 if __name__=="__main__":
    main() __name__=="__main__" __name__ "__main__" main() main def i_row_list(N): return [i_list() for _ in range(N)] def i_row_list(N): return [i_list() for _ in range(N)] i_row_list def s_list(): return list(s_map()) def s_list(): return list(s_map()) s_list def s_row(N): return [s_input for _ in range(N)] def s_row(N): return [s_input for _ in range(N)] s_row def s_input(): return input() def s_input(): return input() s_input def i_row(N): return [i_input() for _ in range(N)] def i_row(N): return [i_input() for _ in range(N)] i_row def i_map(): return map(int, input().split()) def i_map(): return map(int, input().split()) i_map INF = float("inf") float("inf") INF def main():
    a,b = i_map()

    def prime_decomposition(n):
        i = 2
        table = []
        while i * i <= n: # sqrt(n)で計算が済む
            while n % i == 0:
                n //= i
                table.append(i)
            i += 1
        if n > 1:
            table.append(n)
        return table

    a = set(prime_decomposition(a))
    b = set(prime_decomposition(b))
    print(len(a&b)+1) def main():
    a,b = i_map()

    def prime_decomposition(n):
        i = 2
        table = []
        while i * i <= n: # sqrt(n)で計算が済む
            while n % i == 0:
                n //= i
                table.append(i)
            i += 1
        if n > 1:
            table.append(n)
        return table

    a = set(prime_decomposition(a))
    b = set(prime_decomposition(b))
    print(len(a&b)+1) main def s_map(): return input().split() def s_map(): return input().split() s_map def s_row_list(N): return [list(s_input()) for _ in range(N)] def s_row_list(N): return [list(s_input()) for _ in range(N)] s_row_list def i_list(): return list(i_map()) def i_list(): return list(i_map()) i_list def s_row_str(N): return [s_list() for _ in range(N)] def s_row_str(N): return [s_list() for _ in range(N)] s_row_str def i_input(): return int(input()) def i_input(): return int(input()) i_input
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    a,b = i_map()

    def prime_decomposition(n):
        i = 2
        table = []
        while i * i <= n: # sqrt(n)で計算が済む
            while n % i == 0:
                n //= i
                table.append(i)
            i += 1
        if n > 1:
            table.append(n)
        return table

    a = set(prime_decomposition(a))
    b = set(prime_decomposition(b))
    print(len(a&b)+1)



if __name__=="__main__":
    main()
