import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] first = br.readLine().split(" ", 2); int n = Integer.parseInt(first[0]); int d = Integer.parseInt(first[1]); int max = n * n * 2; int[] arr1 = new int[max + 1]; int[] arr2 = new int[max + 1]; for (int i = 1; i <= n; i++) { arr1[i * i * 2]++; for (int j = i + 1; j <= n; j++) { arr1[i * i + j * j] += 2; } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { int value = i * i - j * j + d; if (value > max) { continue; } else if (value <= 0) { break; } arr2[value]++; } } long total = 0; for (int i = 1; i <= max; i++) { total += arr1[i] * arr2[i]; } System.out.println(total); } }