n = gets.to_i heiho = Hash.new(0) x = 1 while x*x <= n*n heiho[x*x] = 1 x += 1 end cnt = 0 x = 1 while x <= n y2 = n*n - x*x cnt += 1 if heiho[y2] == 1 x += 1 end p cnt