import sys input = sys.stdin.readline def MI(): return map(int, input().split()) n,d=MI() from collections import defaultdict xydic=defaultdict(int) wzdic=defaultdict(int) for i in range(1,n+1): for j in range(1,n+1): wzdic[i**2-j**2+d]+=1 xydic[i**2+j**2]+=1 ans=0 for i in xydic.keys(): ans+=wzdic[i]*xydic[i] print(ans)