K = int(input())
a = 7 % K
mods = []

i = 0
found = False
while (i <= K):
    i += 1
    if a == 0:
        print(i)
        found = True
        break
    a = (10 * a + 7) % K

if not found:
    print(-1) K = int(input()) K int(input()) int input() input a = 7 % K a 7 % K 7 K mods = [] mods [] i = 0 i 0 found = False found False while (i <= K):
    i += 1
    if a == 0:
        print(i)
        found = True
        break
    a = (10 * a + 7) % K i <= K i K i += 1 i 1 if a == 0:
        print(i)
        found = True
        break
     a == 0 a 0 print(i) print i found = True found True break a = (10 * a + 7) % K a (10 * a + 7) % K 10 * a + 7 10 * a 10 a 7 K if not found:
    print(-1) not found found print(-1) print -1 mods = [] [] mods i = 0 0 i K = int(input()) int(input()) K a = 7 % K 7 % K a found = False False found i += 1 1 i found = True True found a = (10 * a + 7) % K (10 * a + 7) % K a
K = int(input())
a = 7 % K
mods = []

i = 0
found = False
while (i <= K):
    i += 1
    if a == 0:
        print(i)
        found = True
        break
    a = (10 * a + 7) % K

if not found:
    print(-1)