import strutils, sequtils proc main() = let nd = stdin.readLine.strip.split.map(parseInt) (n, d) = (nd[0], nd[1]) var sq = newSeq[bool](n * n + 1) for i in 1..n: sq[i * i] = true var ans: int64 = 0 for x in 1..n: for y in 1..n: for z in 1..n: let w2 = x * x + y * y + z * z - d if w2 >= 0 and w2 <= n * n and sq[w2]: ans += 1 echo ans main()