n = gets.to_i a = Math.sqrt(n).to_i + 1 result = false while a < 3162277660168 val = 10**25 b = 1 while a > b val = a**2 - b**2 result = true and break if val == n break if val < n b += 1 end break if result break if a + b >= n a += 1 end puts result ? 1 : -1