Bessie's Secret Pasture

No attempts yetTime limit1sMemory limit128 MB

Problem

Farmer John has cut an almost unlimited number of square pieces of sod (grass sections) of every integer side length from the pasture. (Sometimes FJ doesn't engage the blade properly and even makes squares of side length 0.) He has stacked them in neatly organized piles, which Bessie spotted one afternoon.

Bessie, always eager to put delicious grass in her secret pasture, decides to carry exactly four of these sod pieces to her pasture and cut them into $1 \times 1$ sections so that they tile the $N$ ($1 \le N \le 10000$) unit-square cells of the pasture with no gaps or overlaps.

Bessie wants to know how many different ways she can choose the four sod pieces. In other words, if the four squares have side lengths $a, b, c, d$ (each a non-negative integer), their total area must equal the pasture's area: $a^2 + b^2 + c^2 + d^2 = N$.

For a pasture of size $4$, Bessie could bring sod squares in these five different ways: $(1,1,1,1)$, $(2,0,0,0)$, $(0,2,0,0)$, $(0,0,2,0)$, $(0,0,0,2)$. Order matters: for example, $(4,3,2,1)$ is a different choice from $(1,2,3,4)$.

Input

  • Line 1: A single integer $N$.

Output

  • Line 1: A single integer, the number of different ways Bessie can choose four sod pieces to tile her pasture.