k = gets.to_i
s = 10%k
t = 7%k
a = []
a[0] = t
i = 1
while i < k do
  a[i] = (s*a[i-1]+t)%k
  i += 1
end
i = 0
g = 0
while i < k do
  if a[i] == 0
    g = 1
    break
  end
  i += 1
end
if g == 1
  puts i+1
else
  puts "-1"
end