let K = Int(readLine()!)!
var result = -1
var value: Int = 7
if value % K == 0 {
    print(0)
} else {
    for i in 1..<K {
        if value == 0 {
            result = i
            break
        }
        value = (value * 10 + 7) % K
    }
    print(result)
}
