let k = Int(readLine()!)!

var modulos = Set<Int>()

var current = 0
var count = 0
while true {
  current = (current * 10 + 7) % k
  count += 1
  if modulos.contains(current) {
    count = -1
    break
  }
  if current == 0 {
    break
  }
  modulos.insert(current)
}
print(count)