#C6115. Maximum Distinct Numbers Avoiding Divisibility

    ID: 49840 Type: Default 1000ms 256MiB

Maximum Distinct Numbers Avoiding Divisibility

Maximum Distinct Numbers Avoiding Divisibility

We are given two non-negative integers ( X ) and ( Y ). The task is to determine the maximum number of distinct integers that can be selected such that the product of any two chosen numbers is not divisible by either ( X ) or ( Y ).

The interesting observation is that the answer depends on the greatest common divisor (( \gcd(X, Y) )). Specifically, if ( \gcd(X, Y) = 1 ), then it is possible to choose 4 such numbers; otherwise, the maximum is 3. This conclusion is derived from the properties of number theory and divisibility.

inputFormat

The input consists of a single line containing two non-negative integers, ( X ) and ( Y ), separated by a space.

outputFormat

Output a single integer representing the maximum number of distinct numbers that satisfy the condition.## sample

2 3
4