func readInt() -> Int {
    Int(readLine()!)!
}
 
func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}
 
prefix operator *
prefix func * <T> (a: [T]) -> (T, T) {return (a[0], a[1])}
prefix func * <T> (a: [T]) -> (T, T, T) {return (a[0], a[1], a[2])}

func main() {
    let k = readInt()

    var s: Set<Int> = []

    var v = 7 % k
    for i in 1... {
        guard !s.contains(v) else { break }

        s.insert(v)

        if v == 0 {
            print(i)
            return
        }

        v = (v * 10 + 7) % k
    }

    print(-1)
}

main()