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