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;
  ulong greatest = gcd(N, M);

  ulong[] answerDivisers;
  foreach(i; 1..greatest+1) {
    if (i != 2 && i % 2 == 0) continue;
    if (i != 3 && i % 3 == 0) continue;
    if (i != 5 && i % 5 == 0) continue;
    if (greatest % i != 0) continue;
    if (answerDivisers.any!(d => gcd(i, d) != 1)) continue;

    answerDivisers ~= i;
    debug answerDivisers.writeln;
  }

  writeln(answerDivisers.length);
}
