#!/usr/bin/env ruby

k = gets.to_i
if k % 2 == 0
  puts -1
  return
end

s = 7
i = 1
loop {
  if s % k == 0
    puts i
    return
  elsif i > 1000000
    puts -1
    return
  end
  i += 1
  s *= 10
  s += 7;
}
