import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  long a, b;
  readf("%s %s\n", &a, &b);
  immutable n = 10 ^^ 6 + 1;
  auto p = new bool[](n);
	p[] = 1;
	p[0..2] = 0;
	foreach (i; 2..n) {
		if (p[i]) {
			foreach (j; iota(i*2, n, i))
				p[j] = 0;
		}
	}
  
  auto res = 1;
  
  foreach (i; 2..n) {
    if (!p[i]) continue;

    if (a % i == 0 && b % i == 0) {
      res++;
    }
  }


  if (a == b && a >= n) {
    bool f = true;
    foreach (i; 2..n) {
      if (a % i == 0) {
        f = false;
        break;
      }
    }

    if (f) {
      res++;
    }
  }

  res.writeln;
}
