K = int(input())

if K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    x = 7 % K
    for i in range(1, K + 1):
        if x == 0:
            print(i)
            break
        x = (x * 10 + 7) % K K = int(input()) K int(input()) int input() input if K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    x = 7 % K
    for i in range(1, K + 1):
        if x == 0:
            print(i)
            break
        x = (x * 10 + 7) % K 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 x = 7 % K x 7 % K 7 K for i in range(1, K + 1):
        if x == 0:
            print(i)
            break
        x = (x * 10 + 7) % K i range(1, K + 1) range 1 K + 1 K 1 if x == 0:
            print(i)
            break
         x == 0 x 0 print(i) print i break x = (x * 10 + 7) % K x (x * 10 + 7) % K x * 10 + 7 x * 10 x 10 7 K x = (x * 10 + 7) % K (x * 10 + 7) % K x x = 7 % K 7 % K x K = int(input()) int(input()) K
K = int(input())

if K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    x = 7 % K
    for i in range(1, K + 1):
        if x == 0:
            print(i)
            break
        x = (x * 10 + 7) % K