Spirograph
A spirograph is a children's toy that consists of a plastic plate with cut-out circles of various diameters and a set of smaller wheels with holes. The edges of these circles and wheels are toothed to prevent slipping. To use it, you place the plate on a sheet of paper, insert one of the toothed wheels into a chosen circular hole, and then insert a writing tool into one of the wheel's holes. As you move the wheel, the writing tool traces a beautiful spiral pattern on the paper.
Let's explore a more general scenario. Suppose the radius of the large circle is (rB), the radius of the small circle is (rM), and the writing tool is fixed at a distance (L) from the center of the small circle, rotating along with it. Initially, the small circle touches the large circle at the point ([rB, 0]) (assuming the center of the large circle is the origin). The writing tool is positioned at ([rB-rM+L, 0]).
As the small circle rotates inside the large one, eventually all elements return to their starting positions. This process creates a figure with a certain number of "petals" (for instance, the illustration shows a figure with five "petals" using parameters: (rB = 5), (rM = 3), (L = 4)).
Your task is to find the number of unique pairs of integer radii (rB) and (rM) ((rM < rB)) that allow for drawing a figure with the specified number of "petals", where (rB) does not exceed a given maximum (rMax).
Input
The input consists of two integers (N) and (rMax), separated by a space — the number of "petals" and the maximum radius of the large circle ((2 N 10^6), (1 rMax 10^9)).
Output
The output should be a single integer — the number of unique pairs of integer radii that produce the specified number of "petals", with the large circle's radius not exceeding (rMax). If no such figure can be drawn with the given parameters, output (0).