a,b = map(int,input().split()) cnt = 0 for i in range(a): for j in range(a): for k in range(a): for l in range(a): if i**2+j**2+k**2-l**2 == b: cnt+=1 print(cnt)