K = gets.to_i
Lim = 5 * (10 ** 6)

mod10s = []
for i in 1..Lim do
  if i == 1 then
    mod10s[i-1] = (1 % K)
  else
    mod10s[i-1] = (mod10s[i-2] * 10) % K
  end
end

ans = -1
current_mod = 0
for i in 1..Lim do
  current_mod = (current_mod + mod10s[i-1] * 7) % K
  if current_mod == 0 then
    ans = i
    break
  end
end
  
puts ans