import java.io.*; import java.util.Scanner; public class Main_yukicoder800 { private static Scanner sc; private static Printer pr; private static void solve() { int n = sc.nextInt(); int d = sc.nextInt(); int[] xy = new int[n * n * 2 + 1]; int[] wz = new int[n * n * 2 + 1]; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { xy[i * i + j * j]++; wz[i * i - j * j + (n * n - 1)]++; } } long ans = 0; for (int i = 1; i <= n * n * 2; i++) { if (xy[i] > 0) { int tmp = i - d + (n * n - 1); if (tmp >= 0 && tmp < n * n * 2 + 1) { ans += xy[i] * wz[tmp]; } } } pr.println(ans); } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(System.in); pr = new Printer(System.out); solve(); pr.close(); sc.close(); } static class Printer extends PrintWriter { Printer(OutputStream out) { super(out); } } }