import std.stdio, std.conv, std.array, std.string;
import std.algorithm;
import std.container;
import std.range;
import core.stdc.stdlib;
import std.numeric;

void main() {
  ulong N, M; readf("%d %d\n", &N, &M);
  ulong[] commonDiviers;

  foreach(i; 1..(N<M ? N : M)+1) {
    if (N % i == 0 && M % i == 0) {
      commonDiviers ~= i;
    }
  }

  ulong[] answerDivisers;
  foreach(c; commonDiviers) {
    if (answerDivisers.any!(d => gcd(c, d) != 1)) continue;
    answerDivisers ~= c;
  }

  writeln(answerDivisers.length);
}
