@hash_ff = {}

def ff(i)
  #binding.pry
  v = @hash_ff[i]
  if v
    return v
  end
  if i == 1
    @hash_ff[i] = 7
    return 7
  end
  @hash_ff[i] = 7 * 10**(i-1) + ff(i - 1)
end


K = gets
k_size = K.size
k = K.to_i

result = -1
(1..k).each do |keta|
  #binding.pry
  calc = ff(keta)
  #binding.pry
  #puts "keta=#{keta}, calc=#{calc}"
  if calc % k == 0
    result = keta
    break
  end
end

puts result