import math


def main():
    a, b = map(int, input().split())
    gcd = math.gcd(a, b)
    ans = [1]
    while gcd % 2 == 0:
        ans.append(2)
        gcd = gcd // 2
    f = 3
    while f * f <= gcd:
        if gcd % f == 0:
            ans.append(f)
            gcd = gcd // f
        else:
            f += 2
    if gcd != 1:
        ans.append(gcd)
    print(len(set(ans)))


if __name__ == '__main__':
    main() import math math def main():
    a, b = map(int, input().split())
    gcd = math.gcd(a, b)
    ans = [1]
    while gcd % 2 == 0:
        ans.append(2)
        gcd = gcd // 2
    f = 3
    while f * f <= gcd:
        if gcd % f == 0:
            ans.append(f)
            gcd = gcd // f
        else:
            f += 2
    if gcd != 1:
        ans.append(gcd)
    print(len(set(ans))) main a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b gcd = math.gcd(a, b) gcd math.gcd(a, b) math.gcd math gcd a b ans = [1] ans [1] 1 while gcd % 2 == 0:
        ans.append(2)
        gcd = gcd // 2
     gcd % 2 == 0 gcd % 2 gcd 2 0 ans.append(2) ans.append ans append 2 gcd = gcd // 2 gcd gcd // 2 gcd 2 f = 3 f 3 while f * f <= gcd:
        if gcd % f == 0:
            ans.append(f)
            gcd = gcd // f
        else:
            f += 2
     f * f <= gcd f * f f f gcd if gcd % f == 0:
            ans.append(f)
            gcd = gcd // f
        else:
            f += 2
     gcd % f == 0 gcd % f gcd f 0 ans.append(f) ans.append ans append f gcd = gcd // f gcd gcd // f gcd f f += 2 f 2 if gcd != 1:
        ans.append(gcd)
     gcd != 1 gcd 1 ans.append(gcd) ans.append ans append gcd print(len(set(ans))) print len(set(ans)) len set(ans) set ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    a, b = map(int, input().split())
    gcd = math.gcd(a, b)
    ans = [1]
    while gcd % 2 == 0:
        ans.append(2)
        gcd = gcd // 2
    f = 3
    while f * f <= gcd:
        if gcd % f == 0:
            ans.append(f)
            gcd = gcd // f
        else:
            f += 2
    if gcd != 1:
        ans.append(gcd)
    print(len(set(ans))) def main():
    a, b = map(int, input().split())
    gcd = math.gcd(a, b)
    ans = [1]
    while gcd % 2 == 0:
        ans.append(2)
        gcd = gcd // 2
    f = 3
    while f * f <= gcd:
        if gcd % f == 0:
            ans.append(f)
            gcd = gcd // f
        else:
            f += 2
    if gcd != 1:
        ans.append(gcd)
    print(len(set(ans))) main
import math


def main():
    a, b = map(int, input().split())
    gcd = math.gcd(a, b)
    ans = [1]
    while gcd % 2 == 0:
        ans.append(2)
        gcd = gcd // 2
    f = 3
    while f * f <= gcd:
        if gcd % f == 0:
            ans.append(f)
            gcd = gcd // f
        else:
            f += 2
    if gcd != 1:
        ans.append(gcd)
    print(len(set(ans)))


if __name__ == '__main__':
    main()
