function Main(input) {
	input = input.split(' ');
	var a = parseInt(input[0], 10);
	var b = parseInt(input[1], 10);

	var results = [1];
	var maxd = Sub(a, b);
	for (var i = 2; i <= maxd; i++) {
		if (a % i === 0 && b % i === 0) {
			if (results.every(n => Sub(n, i) === 1)) {
				results.push(i);
			}
		}
	}
	console.log(results.length);
}
function Sub(a, b) {
	if (b === 0) return a;
	return Sub(b, a % b);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));