N, D =map(int, input().split()) up = 2*N*N +1 num_xy = [0] * up for x in range(1,N+1): for y in range(1,N+1): idx = x*x + y*y -1 num_xy[idx] = num_xy[idx] +1 num_zw = [0] * up for z in range(1,N+1): for w in range(1,N+1): idx = w*w +D - z*z -1 if idx > 0 and idx < up: num_zw[idx] = num_zw[idx] +1 print(sum([a*b for (a,b) in zip(num_xy,num_zw)]))