from collections import defaultdict n,d = map(int,input().split()) half = defaultdict(int) for i in range(1,n+1): for j in range(i+1,n+1): half[i**2+j**2] +=2 for i in range(1,n+1): half[2*i**2+i**2] +=1 ans = 0 for i in range(1,n+1): for j in range(1,n+1): ans += half[d+i**2-j**2] print(ans)