#import <Foundation/Foundation.h>
typedef NSInteger Int;
@interface NSNumber (Extension)
-(NSMutableArray*)primeFactors;
@end

@implementation NSNumber (Extension)
-(NSMutableArray*)primeFactors
{
	NSMutableArray *array = [NSMutableArray array];
	Int factor = 0;
	Int factorCount = 0;
	Int n = [self integerValue];
	Int q = n;
	
	if (n == 1) {
		return [NSMutableArray arrayWithArray: @[@{@"factor": @1, @"exponent": @1}]];
	}
	for(Int i=2;i*i<=n;){
		if (q % i == 0) {
			if (i != factor) {
				factor = i;
				factorCount = 1;
			} else {
				factorCount++;
			}
			q /= i;
		} else {
			if (factor > 0) {
				[array addObject: @{@"factor": @(factor), @"exponent": @(factorCount)}];
				factor = 0;
			}
			i++;
		}
	}
	if (q > 1) {
		[array addObject: @{@"factor": @(q), @"exponent": @1}];
	}
	return array;
}
@end
int main() {
	@autoreleasepool{
		Int a,b;
		scanf("%ld %ld",&a,&b);
		NSArray *p1 = [@(a) primeFactors];
		NSArray *p2 = [@(b) primeFactors];
		NSMutableSet *s1 = [NSMutableSet set];
		NSMutableSet *s2 = [NSMutableSet set];
		for(NSDictionary *f in p1){
			[s1 addObject:[f objectForKey:@"factor"]];
		}
		for(NSDictionary *f in p2){
			[s2 addObject:[f objectForKey:@"factor"]];
		}
		[s1 intersectSet:s2];
		printf("%lu", [s1 count]+1);
	}
}