import Foundation

func readInt() -> Int {
    return Int(readLine()!)!
}

func mainC() {
    let K = readInt()

    for i in 1...1000 {
        let number = NSDecimalNumber(string: String.init(repeating: "7", count: i))
        let result = number.dividing(by: NSDecimalNumber(integerLiteral: K)).stringValue

        if result.contains(".") {
            continue
        } else {
            print(i)
            return
        }
    }

    print(-1)
}
mainC()