k = int(input())
x = 7%k
cnt = 0

if k%2 ==0:
    print('-1')
else:
    while True:
        cnt += 1
        if x == 0:
            print(cnt)
            break
        elif cnt == k:
            print('-1')
            break
        else:
            x = (x*10+7)%k k = int(input()) k int(input()) int input() input x = 7%k x 7%k 7 k cnt = 0 cnt 0 if k%2 ==0:
    print('-1')
else:
    while True:
        cnt += 1
        if x == 0:
            print(cnt)
            break
        elif cnt == k:
            print('-1')
            break
        else:
            x = (x*10+7)%k k%2 ==0 k%2 k 2 0 print('-1') print '-1' while True:
        cnt += 1
        if x == 0:
            print(cnt)
            break
        elif cnt == k:
            print('-1')
            break
        else:
            x = (x*10+7)%k True cnt += 1 cnt 1 if x == 0:
            print(cnt)
            break
        elif cnt == k:
            print('-1')
            break
        else:
            x = (x*10+7)%k x == 0 x 0 print(cnt) print cnt break elif cnt == k:
            print('-1')
            break
         cnt == k cnt k print('-1') print '-1' break x = (x*10+7)%k x (x*10+7)%k x*10+7 x*10 x 10 7 k cnt += 1 1 cnt x = (x*10+7)%k (x*10+7)%k x k = int(input()) int(input()) k x = 7%k 7%k x cnt = 0 0 cnt
k = int(input())
x = 7%k
cnt = 0

if k%2 ==0:
    print('-1')
else:
    while True:
        cnt += 1
        if x == 0:
            print(cnt)
            break
        elif cnt == k:
            print('-1')
            break
        else:
            x = (x*10+7)%k