/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+:---test
12 18
---+/
/+---test
420 660
---+/
/+---test
1 2019
---+/

bool isPrime(N)(N n) {
  if (n   <  2) return false;
  if (n   == 2) return true;
  if (n%2 == 0) return false;

  for (int i = 3; i*i <= n; i+=2) {
    if (n%i == 0) return false;
  }
  return true;
}

void main(string[] args) {
  long A, B;
  readf(" %d %d ", &A, &B);

  auto C = gcd(A, B);

  int ans = 1;
  foreach (i; 2..C+1) {
    if (C%i == 0 && i.isPrime) {
      ++ans;
    }
  }
  ans.writeln;
}
