N, D = map(int, input().split()) maxv = N * N + D + 5 S = [0] * maxv for i in range(1, N + 1): for j in range(1, N + 1): v = D + i * i - j * j if v < 0: break S[v] += 1 ans = 0 for i in range(1, N + 1): for j in range(1, N + 1): v = i * i + j * j if v >= maxv - 1: break ans += S[v] print(ans)