import java.util.Scanner;
import kotlin.system.exitProcess

fun main(args: Array<String>) {
	val scanner = Scanner(System.`in`)
	val a = scanner.nextLong()
	val b = scanner.nextLong()
	var gcd = euc(a, b)

	if (gcd==1L) fin(1)

	var cnt = 1
	val ps = mutableListOf(2L, 3L, 5L)
	for (p in ps) {
		if (gcd%p==0L) {
			cnt++
			while (gcd%p==0L) gcd /= p
		}
		if (gcd==1L) fin(cnt)
	}
	for (v in 7L..1000000L) {
		if (v*v>gcd) {	//gcdは素数
			fin (cnt+1)
		}
		val vMod = v%6
		if (vMod==1L || vMod==5L) {
			for (p in ps) {
				if (v%p==0L) break
				if (p*p>v) {	//vは素数
					ps.add(v)
					if (gcd%v==0L) {
						cnt++
						while(gcd%v==0L) gcd /= v
					}
					if (gcd==1L) fin(cnt)
					break
				}
			}
		}
	}
	println(cnt)
}

fun fin(cnt: Int) {
	println(cnt)
	exitProcess(0)
}

fun euc(a: Long, b: Long): Long {
	var a = a
	var b = b
	if (a < b) {    //a>=bほしょー
		val c = a
		a = b
		b = c
	}
	while (a%b != 0L) {
		val c = a % b
		a = b
		b = c
	}
	return b
}