N,D = map(int,input().split()) BASE = N**2+1 C = [0]*(2*BASE+1) for z in range(1,N+1): for w in range(1,N+1): C[z**2-w**2+BASE] += 1 ans = 0 for x in range(1,N+1): for y in range(1,N+1): a = D-x**2-y**2 if -BASE<=a<=BASE: ans += C[a+BASE] print(ans)