n,D=map(int,input().split()) d={} for x in range(1,n+1): for y in range(1,n+1): v=x**2+y**2 if v not in d: d[v]=0 d[v]+=1 g=0 for z in range(1,n+1): for w in range(1,n+1): v=w**2+D-z**2 if v in d: g+=d[v] print(g)