#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
from typing import List
from math import gcd


def get_divisors(n: int) -> List[int]:
    i = 1
    ret = []
    while i * i <= n:
        if n % i == 0:
            ret.append(i)
            x = n // i
            if x != i:
                ret.append(x)
        i += 1
    return ret



def main() -> None:
    a, b = map(int, input().split())
    if a > b:
        a, b = b, a

    divisors = list(filter(lambda x: b % x == 0, get_divisors(a)))
    divisors.sort()
    # print(divisors)
    ret = []

    for div in divisors:
        ok = True
        for i in ret:
            if gcd(i, div) != 1:
                ok = False
                break
        if ok:
            ret.append(div)

    print(len(ret))


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self, **kwargs):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main() import os os import sys sys from io import BytesIO, IOBase from typing import List from math import gcd def get_divisors(n: int) -> List[int]:
    i = 1
    ret = []
    while i * i <= n:
        if n % i == 0:
            ret.append(i)
            x = n // i
            if x != i:
                ret.append(x)
        i += 1
    return ret get_divisors i = 1 i 1 ret = [] ret [] while i * i <= n:
        if n % i == 0:
            ret.append(i)
            x = n // i
            if x != i:
                ret.append(x)
        i += 1
     i * i <= n i * i i i n if n % i == 0:
            ret.append(i)
            x = n // i
            if x != i:
                ret.append(x)
         n % i == 0 n % i n i 0 ret.append(i) ret.append ret append i x = n // i x n // i n i if x != i:
                ret.append(x)
         x != i x i ret.append(x) ret.append ret append x i += 1 i 1 return ret ret n: int n def main() -> None:
    a, b = map(int, input().split())
    if a > b:
        a, b = b, a

    divisors = list(filter(lambda x: b % x == 0, get_divisors(a)))
    divisors.sort()
    # print(divisors)
    ret = []

    for div in divisors:
        ok = True
        for i in ret:
            if gcd(i, div) != 1:
                ok = False
                break
        if ok:
            ret.append(div)

    print(len(ret))


# region fastio main a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b if a > b:
        a, b = b, a

     a > b a b a, b = b, a a b b a divisors = list(filter(lambda x: b % x == 0, get_divisors(a))) divisors list(filter(lambda x: b % x == 0, get_divisors(a))) list filter(lambda x: b % x == 0, get_divisors(a)) filter lambda x: b % x == 0 b % x == 0 b % x b x 0 x get_divisors(a) get_divisors a divisors.sort() divisors.sort divisors sort ret = [] ret [] for div in divisors:
        ok = True
        for i in ret:
            if gcd(i, div) != 1:
                ok = False
                break
        if ok:
            ret.append(div)

     div divisors ok = True ok True for i in ret:
            if gcd(i, div) != 1:
                ok = False
                break
         i ret if gcd(i, div) != 1:
                ok = False
                break
         gcd(i, div) != 1 gcd(i, div) gcd i div 1 ok = False ok False break if ok:
            ret.append(div)

     ok ret.append(div) ret.append ret append div print(len(ret)) print len(ret) len ret BUFSIZE = 8192 BUFSIZE 8192 class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self, **kwargs):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0) FastIO newlines = 0 newlines 0 def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

     __init__ self._fd = file.fileno() self._fd self _fd file.fileno() file.fileno file fileno self.buffer = BytesIO() self.buffer self buffer BytesIO() BytesIO self.writable = "x" in file.mode or "r" not in file.mode self.writable self writable "x" in file.mode or "r" not in file.mode "x" in file.mode "x" file.mode file mode "r" not in file.mode "r" file.mode file mode self.write = self.buffer.write if self.writable else None self.write self write self.buffer.write if self.writable else None self.writable self writable self.buffer.write self.buffer self buffer write None self self file file def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

     read while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
         True b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) b os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) os.read os read self._fd self _fd max(os.fstat(self._fd).st_size, BUFSIZE) max os.fstat(self._fd).st_size os.fstat(self._fd) os.fstat os fstat self._fd self _fd st_size BUFSIZE if not b:
                break
             not b b break ptr = self.buffer.tell() ptr self.buffer.tell() self.buffer.tell self.buffer self buffer tell self.buffer.seek(0, 2) self.buffer.seek self.buffer self buffer seek 0 2 self.buffer.write(b) self.buffer.write self.buffer self buffer write b self.buffer.seek(ptr) self.buffer.seek self.buffer self buffer seek ptr self.newlines = 0 self.newlines self newlines 0 return self.buffer.read() self.buffer.read() self.buffer.read self.buffer self buffer read self self def readline(self, **kwargs):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

     readline while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
         self.newlines == 0 self.newlines self newlines 0 b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) b os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) os.read os read self._fd self _fd max(os.fstat(self._fd).st_size, BUFSIZE) max os.fstat(self._fd).st_size os.fstat(self._fd) os.fstat os fstat self._fd self _fd st_size BUFSIZE self.newlines = b.count(b"\n") + (not b) self.newlines self newlines b.count(b"\n") + (not b) b.count(b"\n") b.count b count b"\n" not b b ptr = self.buffer.tell() ptr self.buffer.tell() self.buffer.tell self.buffer self buffer tell self.buffer.seek(0, 2) self.buffer.seek self.buffer self buffer seek 0 2 self.buffer.write(b) self.buffer.write self.buffer self buffer write b self.buffer.seek(ptr) self.buffer.seek self.buffer self buffer seek ptr self.newlines -= 1 self.newlines self newlines 1 return self.buffer.readline() self.buffer.readline() self.buffer.readline self.buffer self buffer readline self self **kwargs def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0) flush if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0) self.writable self writable os.write(self._fd, self.buffer.getvalue()) os.write os write self._fd self _fd self.buffer.getvalue() self.buffer.getvalue self.buffer self buffer getvalue self.buffer.truncate(0) self.buffer.truncate self.buffer self buffer truncate 0 self.buffer.seek(0) self.buffer.seek self.buffer self buffer seek 0 self self IOBase class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii") IOWrapper def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii") __init__ self.buffer = FastIO(file) self.buffer self buffer FastIO(file) FastIO file self.flush = self.buffer.flush self.flush self flush self.buffer.flush self.buffer self buffer flush self.writable = self.buffer.writable self.writable self writable self.buffer.writable self.buffer self buffer writable self.write = lambda s: self.buffer.write(s.encode("ascii")) self.write self write lambda s: self.buffer.write(s.encode("ascii")) self.buffer.write(s.encode("ascii")) self.buffer.write self.buffer self buffer write s.encode("ascii") s.encode s encode "ascii" s self.read = lambda: self.buffer.read().decode("ascii") self.read self read lambda: self.buffer.read().decode("ascii") self.buffer.read().decode("ascii") self.buffer.read().decode self.buffer.read() self.buffer.read self.buffer self buffer read decode "ascii" self.readline = lambda: self.buffer.readline().decode("ascii") self.readline self readline lambda: self.buffer.readline().decode("ascii") self.buffer.readline().decode("ascii") self.buffer.readline().decode self.buffer.readline() self.buffer.readline self.buffer self buffer readline decode "ascii" self self file file IOBase sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout) sys.stdin sys stdin IOWrapper(sys.stdin) IOWrapper sys.stdin sys stdin sys.stdout sys stdout IOWrapper(sys.stdout) IOWrapper sys.stdout sys stdout input = lambda: sys.stdin.readline().rstrip("\r\n") input lambda: sys.stdin.readline().rstrip("\r\n") sys.stdin.readline().rstrip("\r\n") sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip "\r\n" if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main BUFSIZE = 8192 8192 BUFSIZE class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self, **kwargs):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0) class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self, **kwargs):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0) FastIO def get_divisors(n: int) -> List[int]:
    i = 1
    ret = []
    while i * i <= n:
        if n % i == 0:
            ret.append(i)
            x = n // i
            if x != i:
                ret.append(x)
        i += 1
    return ret def get_divisors(n: int) -> List[int]:
    i = 1
    ret = []
    while i * i <= n:
        if n % i == 0:
            ret.append(i)
            x = n // i
            if x != i:
                ret.append(x)
        i += 1
    return ret get_divisors class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii") class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii") IOWrapper def main() -> None:
    a, b = map(int, input().split())
    if a > b:
        a, b = b, a

    divisors = list(filter(lambda x: b % x == 0, get_divisors(a)))
    divisors.sort()
    # print(divisors)
    ret = []

    for div in divisors:
        ok = True
        for i in ret:
            if gcd(i, div) != 1:
                ok = False
                break
        if ok:
            ret.append(div)

    print(len(ret))


# region fastio def main() -> None:
    a, b = map(int, input().split())
    if a > b:
        a, b = b, a

    divisors = list(filter(lambda x: b % x == 0, get_divisors(a)))
    divisors.sort()
    # print(divisors)
    ret = []

    for div in divisors:
        ok = True
        for i in ret:
            if gcd(i, div) != 1:
                ok = False
                break
        if ok:
            ret.append(div)

    print(len(ret))


# region fastio main input = lambda: sys.stdin.readline().rstrip("\r\n") lambda: sys.stdin.readline().rstrip("\r\n") input
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
from typing import List
from math import gcd


def get_divisors(n: int) -> List[int]:
    i = 1
    ret = []
    while i * i <= n:
        if n % i == 0:
            ret.append(i)
            x = n // i
            if x != i:
                ret.append(x)
        i += 1
    return ret



def main() -> None:
    a, b = map(int, input().split())
    if a > b:
        a, b = b, a

    divisors = list(filter(lambda x: b % x == 0, get_divisors(a)))
    divisors.sort()
    # print(divisors)
    ret = []

    for div in divisors:
        ok = True
        for i in ret:
            if gcd(i, div) != 1:
                ok = False
                break
        if ok:
            ret.append(div)

    print(len(ret))


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self, **kwargs):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()
