n = read_line.to_i64 n2 = n * n puts (1i64...n).count { |x| y = n2 - x * x sq = Math.sqrt(y).to_i64 (sq - 2..sq + 2).any? { |aa| aa*aa == y } }