def main(): from math import sqrt,sin,cos,tan,ceil,radians,floor,gcd,exp,log,log10,log2,factorial,fsum from heapq import heapify, heappop, heappush from bisect import bisect_left, bisect_right from copy import deepcopy import copy import random from collections import deque,Counter,defaultdict from itertools import permutations,combinations from decimal import Decimal,ROUND_HALF_UP #tmp = Decimal(mid).quantize(Decimal('0'), rounding=ROUND_HALF_UP) from functools import lru_cache, reduce #@lru_cache(maxsize=None) from operator import add,sub,mul,xor,and_,or_,itemgetter INF = 10**18 mod1 = 10**9+7 mod2 = 998244353 #DecimalならPython ''' 2乗までは回る x^2+y^2 = (w+z)(w-z)+D 2*4 w = 3,z = 1 3*5 w = 4,z = 1 5*10 ない 5*11 w = 8, z = 3 7*4 ない 差が偶数ならよい? ''' N,D = map(int, input().split()) left = [0]*(10**7) right = [0]*(10**7) for i in range(1,N+1): for j in range(1,N+1): left[i**2+j**2] += 1 for i in range(1,N+1): for j in range(1,N+1): right[i**2-j**2+D] += 1 ans = 0 for i in range(10**7): ans += left[i]*right[i] print(ans) if __name__ == '__main__': main()