K = int(input())
a = 7 % K
cnt = 1
while a:
    a = (10*a+7) % K
    cnt += 1
    if K < cnt:
        cnt = -1
        break
print(cnt) K = int(input()) K int(input()) int input() input a = 7 % K a 7 % K 7 K cnt = 1 cnt 1 while a:
    a = (10*a+7) % K
    cnt += 1
    if K < cnt:
        cnt = -1
        break a a = (10*a+7) % K a (10*a+7) % K 10*a+7 10*a 10 a 7 K cnt += 1 cnt 1 if K < cnt:
        cnt = -1
        break K < cnt K cnt cnt = -1 cnt -1 break print(cnt) print cnt a = 7 % K 7 % K a cnt += 1 1 cnt cnt = 1 1 cnt K = int(input()) int(input()) K cnt = -1 -1 cnt a = (10*a+7) % K (10*a+7) % K a
K = int(input())
a = 7 % K
cnt = 1
while a:
    a = (10*a+7) % K
    cnt += 1
    if K < cnt:
        cnt = -1
        break
print(cnt)