Kin = int(input())

i = 0
now = 0

if (0 == (Kin % 2)) or (0 == (Kin % 5)):
    print(-1)
else:
    while 1:
        now = (now * 10 + 7) % Kin
        i+=1

        if now == 0:
            break
    print(i) Kin = int(input()) Kin int(input()) int input() input i = 0 i 0 now = 0 now 0 if (0 == (Kin % 2)) or (0 == (Kin % 5)):
    print(-1)
else:
    while 1:
        now = (now * 10 + 7) % Kin
        i+=1

        if now == 0:
            break
    print(i) (0 == (Kin % 2)) or (0 == (Kin % 5)) 0 == (Kin % 2) 0 Kin % 2 Kin 2 0 == (Kin % 5) 0 Kin % 5 Kin 5 print(-1) print -1 while 1:
        now = (now * 10 + 7) % Kin
        i+=1

        if now == 0:
            break
     1 now = (now * 10 + 7) % Kin now (now * 10 + 7) % Kin now * 10 + 7 now * 10 now 10 7 Kin i+=1 i 1 if now == 0:
            break
     now == 0 now 0 break print(i) print i i = 0 0 i now = (now * 10 + 7) % Kin (now * 10 + 7) % Kin now Kin = int(input()) int(input()) Kin now = 0 0 now i+=1 1 i
Kin = int(input())

i = 0
now = 0

if (0 == (Kin % 2)) or (0 == (Kin % 5)):
    print(-1)
else:
    while 1:
        now = (now * 10 + 7) % Kin
        i+=1

        if now == 0:
            break
    print(i)