import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    k = int(input())
    keta = 1
    mod = 7%k
    if k % 7 == 0:
        max_k = 9*k//7
    else:
        max_k = 9*k
    while keta < max_k:
        if mod == 0:
            print(keta)
            break
        mod = (mod*10 + 7)%k
        keta += 1
    else:
        print(-1)


if __name__=='__main__':
    main() import sys sys def input(): return sys.stdin.readline().rstrip() input def main():
    k = int(input())
    keta = 1
    mod = 7%k
    if k % 7 == 0:
        max_k = 9*k//7
    else:
        max_k = 9*k
    while keta < max_k:
        if mod == 0:
            print(keta)
            break
        mod = (mod*10 + 7)%k
        keta += 1
    else:
        print(-1) main k = int(input()) k int(input()) int input() input keta = 1 keta 1 mod = 7%k mod 7%k 7 k if k % 7 == 0:
        max_k = 9*k//7
    else:
        max_k = 9*k
     k % 7 == 0 k % 7 k 7 0 max_k = 9*k//7 max_k 9*k//7 9*k 9 k 7 max_k = 9*k max_k 9*k 9 k while keta < max_k:
        if mod == 0:
            print(keta)
            break
        mod = (mod*10 + 7)%k
        keta += 1
    else:
        print(-1) keta < max_k keta max_k if mod == 0:
            print(keta)
            break
         mod == 0 mod 0 print(keta) print keta break mod = (mod*10 + 7)%k mod (mod*10 + 7)%k mod*10 + 7 mod*10 mod 10 7 k keta += 1 keta 1 print(-1) print -1 if __name__=='__main__':
    main() __name__=='__main__' __name__ '__main__' main() main def input(): return sys.stdin.readline().rstrip() def input(): return sys.stdin.readline().rstrip() input def main():
    k = int(input())
    keta = 1
    mod = 7%k
    if k % 7 == 0:
        max_k = 9*k//7
    else:
        max_k = 9*k
    while keta < max_k:
        if mod == 0:
            print(keta)
            break
        mod = (mod*10 + 7)%k
        keta += 1
    else:
        print(-1) def main():
    k = int(input())
    keta = 1
    mod = 7%k
    if k % 7 == 0:
        max_k = 9*k//7
    else:
        max_k = 9*k
    while keta < max_k:
        if mod == 0:
            print(keta)
            break
        mod = (mod*10 + 7)%k
        keta += 1
    else:
        print(-1) main
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    k = int(input())
    keta = 1
    mod = 7%k
    if k % 7 == 0:
        max_k = 9*k//7
    else:
        max_k = 9*k
    while keta < max_k:
        if mod == 0:
            print(keta)
            break
        mod = (mod*10 + 7)%k
        keta += 1
    else:
        print(-1)


if __name__=='__main__':
    main()