fn main() { let mut nd = String::new(); std::io::stdin().read_line(&mut nd).ok(); let nd: Vec = nd.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let n = nd[0]; let d = nd[1]; let mut cnts = vec![0usize; 2*2000*2000+1]; let mut cnt2 = vec![0usize; 2*2000*2000+1]; for x in 1..=n { for y in 1..=n { cnts[x*x + y*y] += 1; } } for z in 1..=n { for w in 1..=n { if z*z > w*w + d { continue; } cnt2[w*w +d - z*z] += 1; } } let mut result = 0usize; for i in 0..=2*2000*2000 { result += cnts[i] * cnt2[i]; } println!("{}", result); }