import scala.annotation.tailrec import scala.io.StdIn.* import scala.math.* @main def main = val Array(n, d) = readLine().split(' ').map(_.toInt) val factorCount = Array.fill(max(n * n * 2, d) + 1){0} for w <- 1 to n z <- 1 to w do factorCount(w * w - z * z) += 1 var result = 0L for x <- 1 to n y <- 1 to n do result += factorCount(abs(d - x * x - y * y)) println(result)