#include using namespace std; int flg[2001*2001*2]; int ans; signed main () { int n, d; scanf("%d %d", &n, &d); for ( int i = 1; i <= n; i++ ) { for ( int j = 1; j <= n; j++ ) { flg[i*i+j*j]++; } } for ( int i = 1; i <= n; i++ ) { for ( int j = 1; j <= n; j++ ) { if ( j*j+d-i*i < 0 ) continue; ans += flg[j*j+d-i*i]; } } printf("%d\n", ans); return 0; }