#!/usr/bin/env python3
import sys


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


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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 def solve(K: int):
    lastMod = 0
    for i in range(K):
        lastMod = (lastMod*10+7)%K
        if lastMod == 0:
            print(i+1)
            return
    print(-1)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template) solve lastMod = 0 lastMod 0 for i in range(K):
        lastMod = (lastMod*10+7)%K
        if lastMod == 0:
            print(i+1)
            return
     i range(K) range K lastMod = (lastMod*10+7)%K lastMod (lastMod*10+7)%K lastMod*10+7 lastMod*10 lastMod 10 7 K if lastMod == 0:
            print(i+1)
            return
     lastMod == 0 lastMod 0 print(i+1) print i+1 i 1 return print(-1) print -1 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 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 def solve(K: int):
    lastMod = 0
    for i in range(K):
        lastMod = (lastMod*10+7)%K
        if lastMod == 0:
            print(i+1)
            return
    print(-1)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template) def solve(K: int):
    lastMod = 0
    for i in range(K):
        lastMod = (lastMod*10+7)%K
        if lastMod == 0:
            print(i+1)
            return
    print(-1)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template) solve
#!/usr/bin/env python3
import sys


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


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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()
