mod = 1000000007 eps = 10**-9 def main(): import sys from collections import defaultdict input = sys.stdin.readline N, D = map(int, input().split()) cnt = defaultdict(int) for w in range(1, N+1): for z in range(1, N+1): cnt[w*w - z*z] += 1 ans = 0 for x in range(1, N+1): for y in range(1, N+1): ans += cnt[x*x + y*y - D] print(ans) if __name__ == '__main__': main()