N,D = map(int,input().split()) C = {i:0 for i in range(-N**2+1,N**2)} for z in range(1,N+1): for w in range(1,N+1): C[z**2-w**2] += 1 ans = 0 for x in range(1,N+1): for y in range(1,N+1): a = D-x**2-y**2 if a in C: ans += C[a] print(ans)