var k:Int = Int(readLine()!)!
var c:Int = 0
if k % 2 == 0 || k % 5 == 0 {
  c = -1
} else {
  k = (k % 7 == 0 ? k/7:k)
  var m1:Int = 1, m2:Int = 1
  c += 1
  while m1 % k != 0 {
    m2 = (m2*10)%k
    m1 = (m1+m2)%k
    c += 1
  }
}
print(c)