def resolve():
    K = int(input())
    a = [0] * (K + 1)
    a[1] = 7 % K
    for i in range(2, K + 1):
        a[i] = (a[i - 1] * 10 + 7) % K
    for i in range(1, K + 1):
        if a[i] == 0:
            print(i)
            return
    print(-1)


resolve() def resolve():
    K = int(input())
    a = [0] * (K + 1)
    a[1] = 7 % K
    for i in range(2, K + 1):
        a[i] = (a[i - 1] * 10 + 7) % K
    for i in range(1, K + 1):
        if a[i] == 0:
            print(i)
            return
    print(-1) resolve K = int(input()) K int(input()) int input() input a = [0] * (K + 1) a [0] * (K + 1) [0] 0 K + 1 K 1 a[1] = 7 % K a[1] a 1 7 % K 7 K for i in range(2, K + 1):
        a[i] = (a[i - 1] * 10 + 7) % K
     i range(2, K + 1) range 2 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 for i in range(1, K + 1):
        if a[i] == 0:
            print(i)
            return
     i range(1, K + 1) range 1 K + 1 K 1 if a[i] == 0:
            print(i)
            return
     a[i] == 0 a[i] a i 0 print(i) print i return print(-1) print -1 resolve() resolve def resolve():
    K = int(input())
    a = [0] * (K + 1)
    a[1] = 7 % K
    for i in range(2, K + 1):
        a[i] = (a[i - 1] * 10 + 7) % K
    for i in range(1, K + 1):
        if a[i] == 0:
            print(i)
            return
    print(-1) def resolve():
    K = int(input())
    a = [0] * (K + 1)
    a[1] = 7 % K
    for i in range(2, K + 1):
        a[i] = (a[i - 1] * 10 + 7) % K
    for i in range(1, K + 1):
        if a[i] == 0:
            print(i)
            return
    print(-1) resolve
def resolve():
    K = int(input())
    a = [0] * (K + 1)
    a[1] = 7 % K
    for i in range(2, K + 1):
        a[i] = (a[i - 1] * 10 + 7) % K
    for i in range(1, K + 1):
        if a[i] == 0:
            print(i)
            return
    print(-1)


resolve()
