N = gets.to_i cnt = 0 1.upto(Integer.sqrt(N)-1) {|i| n = N - i**2 next if n == 0 cnt += 1 if Integer.sqrt(n)**2 == n } puts cnt * 2