A = gets.to_i num = (8..100).find { |n| next if A % n >= 10 (n + 7) == A } puts num || -1