import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    K = int(readline())
    a = 0
    ans = 0
    for _ in range(K+1):
        a = 10*a+7
        a %= K
        ans += 1
        if a%K == 0:
            break

    if ans == K+1: 
        print(-1)
    else:
        print(ans)
if __name__ == '__main__':
    main() import sys sys read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline readlines = sys.stdin.buffer.readlines readlines sys.stdin.buffer.readlines sys.stdin.buffer sys.stdin sys stdin buffer readlines def main():
    K = int(readline())
    a = 0
    ans = 0
    for _ in range(K+1):
        a = 10*a+7
        a %= K
        ans += 1
        if a%K == 0:
            break

    if ans == K+1: 
        print(-1)
    else:
        print(ans) main K = int(readline()) K int(readline()) int readline() readline a = 0 a 0 ans = 0 ans 0 for _ in range(K+1):
        a = 10*a+7
        a %= K
        ans += 1
        if a%K == 0:
            break

     _ range(K+1) range K+1 K 1 a = 10*a+7 a 10*a+7 10*a 10 a 7 a %= K a K ans += 1 ans 1 if a%K == 0:
            break

     a%K == 0 a%K a K 0 break if ans == K+1: 
        print(-1)
    else:
        print(ans) ans == K+1 ans K+1 K 1 print(-1) print -1 print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline read = sys.stdin.buffer.read sys.stdin.buffer.read read readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines def main():
    K = int(readline())
    a = 0
    ans = 0
    for _ in range(K+1):
        a = 10*a+7
        a %= K
        ans += 1
        if a%K == 0:
            break

    if ans == K+1: 
        print(-1)
    else:
        print(ans) def main():
    K = int(readline())
    a = 0
    ans = 0
    for _ in range(K+1):
        a = 10*a+7
        a %= K
        ans += 1
        if a%K == 0:
            break

    if ans == K+1: 
        print(-1)
    else:
        print(ans) main
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    K = int(readline())
    a = 0
    ans = 0
    for _ in range(K+1):
        a = 10*a+7
        a %= K
        ans += 1
        if a%K == 0:
            break

    if ans == K+1: 
        print(-1)
    else:
        print(ans)
if __name__ == '__main__':
    main()
