A = gets.to_i puts (8..A).find { |x| A / x == 1 && A % x == 7 } || - 1