N = gets.to_i M = N ** 2 ans = 0 1.upto(N) do |x| if 2 * (x ** 2) == M ans += 1 else ok = N ng = 0 while (ok - ng).abs >= 2 y = (ok + ng) / 2 s = x ** 2 + y ** 2 if s >= M ok = y else ng = y end end if x ** 2 + ok ** 2 == M ans += 1 end end end puts ans