#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(K: int):
    cur = 0
    for i in range(K):
        cur += pow(10, i, K) * 7
        cur %= K
        if cur == 0:
            print(i + 1)
            return i + 1
    ret = -1
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main() import sys sys sys.setrecursionlimit(300000) sys.setrecursionlimit sys setrecursionlimit 300000 def solve(K: int):
    cur = 0
    for i in range(K):
        cur += pow(10, i, K) * 7
        cur %= K
        if cur == 0:
            print(i + 1)
            return i + 1
    ret = -1
    print(ret)
    return solve cur = 0 cur 0 for i in range(K):
        cur += pow(10, i, K) * 7
        cur %= K
        if cur == 0:
            print(i + 1)
            return i + 1
     i range(K) range K cur += pow(10, i, K) * 7 cur pow(10, i, K) * 7 pow(10, i, K) pow 10 i K 7 cur %= K cur K if cur == 0:
            print(i + 1)
            return i + 1
     cur == 0 cur 0 print(i + 1) print i + 1 i 1 return i + 1 i + 1 i 1 ret = -1 ret -1 print(ret) print ret return K: int K def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K) main def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
     iterate_tokens for line in sys.stdin:
            for word in line.split():
                yield word
     line sys.stdin sys stdin for word in line.split():
                yield word
     word line.split() line.split line split yield word word tokens = iterate_tokens() tokens iterate_tokens() iterate_tokens K = int(next(tokens)) K int(next(tokens)) int next(tokens) next tokens solve(K) solve K if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def solve(K: int):
    cur = 0
    for i in range(K):
        cur += pow(10, i, K) * 7
        cur %= K
        if cur == 0:
            print(i + 1)
            return i + 1
    ret = -1
    print(ret)
    return def solve(K: int):
    cur = 0
    for i in range(K):
        cur += pow(10, i, K) * 7
        cur %= K
        if cur == 0:
            print(i + 1)
            return i + 1
    ret = -1
    print(ret)
    return solve def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K) def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K) main
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(K: int):
    cur = 0
    for i in range(K):
        cur += pow(10, i, K) * 7
        cur %= K
        if cur == 0:
            print(i + 1)
            return i + 1
    ret = -1
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main()
