This page is still under construction.

Parts of this page are still being built. What you see may change.

Site Planning

Time limit2sMemory limit512 MB

Summary
Count quadruples of positive integers (a,b,c,d) with a*b - c*d = n, a>c, b>d, and a,b both different from x.
Level

Medium6 of 10

Topics
Math, Number theory, Brute force, Implementation
Solved
No attempts yet

Problem

Scientists are planning a site for a testing ground. The site must be an a×ba \times b rectangle, and the testing ground must be a c×dc \times d rectangle. The scientists have not settled on the exact values of aa, bb, cc, and dd, but they know the following.

  • The side lengths a,b,c,da, b, c, d must be positive integers expressed in kilometers.
  • For the safety of the experiment, the width and height of the site must differ from xx, that is, a≠xa \neq x and b≠xb \neq x must hold.
  • The site will be enclosed by a fence, and the testing ground must fit entirely inside the site, that is, a>ca > c and b>db > d must hold.
  • The area of the site not occupied by the testing ground must be exactly nn square kilometers, that is, a⋅b−c⋅d=na \cdot b - c \cdot d = n must hold.

The scientists want to know how many ways they can choose suitable values of aa, bb, cc, and dd. Write a program that, given nn and xx, determines the number of ways to choose aa, bb, cc, and dd so that all the conditions above hold.

Input

The first line of input contains two numbers: nn, the area of the free part of the site without the testing ground (1≤n≤3000)(1 \le n \le 3000), and xx, the forbidden side length of the site (0≤x≤3000)(0 \le x \le 3000).

A value of x=0x = 0 means there are no restrictions on the side lengths, since the side lengths must be positive integers and therefore greater than 0.

Output

On a single line, output the number of ways to choose aa, bb, cc, and dd so that all the conditions hold.

Hint

In the first test example, only a=2,b=2,c=1,d=1a = 2, b = 2, c = 1, d = 1 fits the conditions.

In the second test example, the following fit the conditions.

  • a=2,b=3,c=1,d=1a = 2, b = 3, c = 1, d = 1;
  • a=2,b=4,c=1,d=3a = 2, b = 4, c = 1, d = 3;
  • a=3,b=2,c=1,d=1a = 3, b = 2, c = 1, d = 1;
  • a=3,b=3,c=2,d=2a = 3, b = 3, c = 2, d = 2;
  • a=4,b=2,c=3,d=1a = 4, b = 2, c = 3, d = 1.

In the third test example, the following fit the conditions.

  • a=2,b=4,c=1,d=3a = 2, b = 4, c = 1, d = 3;
  • a=4,b=2,c=3,d=1a = 4, b = 2, c = 3, d = 1.

In the remaining answers from the previous test, either aa or bb equals 3.

Examples3

  1. Example 1

    Input
    3 0
    
    Expected output
    1
    
  2. Example 2

    Input
    5 0
    
    Expected output
    5
    
  3. Example 3

    Input
    5 3
    
    Expected output
    2