def solve
  return -1 if K.even?
  used=Array.new(K)
  r=7%K
  1.upto(K+1) do |i|
    return -1 if used[i]
    used[i]=true
    return i if r.zero?
    r*=10
    r+=7
    r%=K
  end
  exit 1
end
K=gets.to_i
p solve