def main():
    K = int(input())

    crawler = 7
    found = False
    i = 1

    if (K % 2 ==0) or (K % 5 == 0):
        print(-1)
    else:
        a = [0 for i in range (K+1)]
        a[0] = 7
        for i in range (1, K+1):
            a[i] = (a[i-1]*10 + 7) % K
        a[0] = a[0] % K
        for i in a:
            if i == 0:
                print(a.index(i) + 1)
                found = True
                break
        if not found:
            print(-1)
    
main() def main():
    K = int(input())

    crawler = 7
    found = False
    i = 1

    if (K % 2 ==0) or (K % 5 == 0):
        print(-1)
    else:
        a = [0 for i in range (K+1)]
        a[0] = 7
        for i in range (1, K+1):
            a[i] = (a[i-1]*10 + 7) % K
        a[0] = a[0] % K
        for i in a:
            if i == 0:
                print(a.index(i) + 1)
                found = True
                break
        if not found:
            print(-1)
     main K = int(input()) K int(input()) int input() input crawler = 7 crawler 7 found = False found False i = 1 i 1 if (K % 2 ==0) or (K % 5 == 0):
        print(-1)
    else:
        a = [0 for i in range (K+1)]
        a[0] = 7
        for i in range (1, K+1):
            a[i] = (a[i-1]*10 + 7) % K
        a[0] = a[0] % K
        for i in a:
            if i == 0:
                print(a.index(i) + 1)
                found = True
                break
        if not found:
            print(-1)
     (K % 2 ==0) or (K % 5 == 0) K % 2 ==0 K % 2 K 2 0 K % 5 == 0 K % 5 K 5 0 print(-1) print -1 0 for i in range (K+1) for i in range (K+1) i range (K+1) range K+1 K 1 for i in range (K+1) 0 a = [0 for i in range (K+1)] a [0 for i in range (K+1)] a[0] = 7 a[0] a 0 7 for i in range (1, K+1):
            a[i] = (a[i-1]*10 + 7) % K
         i range (1, K+1) range 1 K+1 K 1 a[i] = (a[i-1]*10 + 7) % K a[i] a i (a[i-1]*10 + 7) % K a[i-1]*10 + 7 a[i-1]*10 a[i-1] a i-1 i 1 10 7 K a[0] = a[0] % K a[0] a 0 a[0] % K a[0] a 0 K for i in a:
            if i == 0:
                print(a.index(i) + 1)
                found = True
                break
         i a if i == 0:
                print(a.index(i) + 1)
                found = True
                break
         i == 0 i 0 print(a.index(i) + 1) print a.index(i) + 1 a.index(i) a.index a index i 1 found = True found True break if not found:
            print(-1)
     not found found print(-1) print -1 main() main def main():
    K = int(input())

    crawler = 7
    found = False
    i = 1

    if (K % 2 ==0) or (K % 5 == 0):
        print(-1)
    else:
        a = [0 for i in range (K+1)]
        a[0] = 7
        for i in range (1, K+1):
            a[i] = (a[i-1]*10 + 7) % K
        a[0] = a[0] % K
        for i in a:
            if i == 0:
                print(a.index(i) + 1)
                found = True
                break
        if not found:
            print(-1)
     def main():
    K = int(input())

    crawler = 7
    found = False
    i = 1

    if (K % 2 ==0) or (K % 5 == 0):
        print(-1)
    else:
        a = [0 for i in range (K+1)]
        a[0] = 7
        for i in range (1, K+1):
            a[i] = (a[i-1]*10 + 7) % K
        a[0] = a[0] % K
        for i in a:
            if i == 0:
                print(a.index(i) + 1)
                found = True
                break
        if not found:
            print(-1)
     main
def main():
    K = int(input())

    crawler = 7
    found = False
    i = 1

    if (K % 2 ==0) or (K % 5 == 0):
        print(-1)
    else:
        a = [0 for i in range (K+1)]
        a[0] = 7
        for i in range (1, K+1):
            a[i] = (a[i-1]*10 + 7) % K
        a[0] = a[0] % K
        for i in a:
            if i == 0:
                print(a.index(i) + 1)
                found = True
                break
        if not found:
            print(-1)
    
main()