n, d = map(int, input().split()) dis = [0] * (n ** 2 * 4 + 1) for w in range(1, n+1): for x in range(1, n+1): dis[x**2-w**2] += 1 yz = [0] * (n ** 2 * 2 + 1) for y in range(1, n+1): for z in range(1, n+1): yz[y**2+z**2] += 1 ans = 0 for i in range(n**2*2+1): if i - d <= - (n ** 2): continue ans += yz[i] * dis[i-d] print(ans)