k = int(input())

n = 7 % k
ans = -1
cnt = 1
checked = {n}
while n > 0:
    n = (n * 10 + 7) % k
    cnt += 1
    if n in checked:
        break
    checked.add(n)

if n == 0:
    print(cnt)
else:
    print(-1) k = int(input()) k int(input()) int input() input n = 7 % k n 7 % k 7 k ans = -1 ans -1 cnt = 1 cnt 1 checked = {n} checked {n} while n > 0:
    n = (n * 10 + 7) % k
    cnt += 1
    if n in checked:
        break
    checked.add(n) n > 0 n 0 n = (n * 10 + 7) % k n (n * 10 + 7) % k n * 10 + 7 n * 10 n 10 7 k cnt += 1 cnt 1 if n in checked:
        break
     n in checked n checked break checked.add(n) checked.add checked add n if n == 0:
    print(cnt)
else:
    print(-1) n == 0 n 0 print(cnt) print cnt print(-1) print -1 n = (n * 10 + 7) % k (n * 10 + 7) % k n cnt = 1 1 cnt checked = {n} {n} checked ans = -1 -1 ans cnt += 1 1 cnt k = int(input()) int(input()) k n = 7 % k 7 % k n
k = int(input())

n = 7 % k
ans = -1
cnt = 1
checked = {n}
while n > 0:
    n = (n * 10 + 7) % k
    cnt += 1
    if n in checked:
        break
    checked.add(n)

if n == 0:
    print(cnt)
else:
    print(-1)
