import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    long a, b;
    readf("%s %s", &a, &b);
    readln;
    
    auto g = gcd(a, b);
    
    long[] ans;
    ans ~= 1;
    
    long k = 2;
    while (k <= g / k) {
        if (g % k == 0) {
            ans ~= k;
            while (g % k == 0) { g /= k; }
        }
        
        ++k;
    }
    
    if (g > 1) { ans ~= g; }
    
    debug { ans.writeln; }
    
    ans.length.writeln;
}