K = int(eval(input()))

x = 7 % K #mod(K)

if K == 1 or K == 7:

  print((1))

  exit()

ans = 1

i = 0

while i < K:

  ans += 1

  x = (x * 10 + 7) % K

  

  if x == 7 % K:

    print('-1')

    exit()

  if x == 0:

    print(ans)

    exit()

  i += 1

print('-1')
K = int(eval(input()))

x = 7 % K #mod(K)

if K == 1 or K == 7:

  print((1))

  exit()

ans = 1

i = 0

while i < K:

  ans += 1

  x = (x * 10 + 7) % K

  

  

  if x == 0:

    print(ans)

    exit()

  i += 1

print('-1')
K = int(eval(input()))
x = 7 % K  # mod(K)
if K == 1 or K == 7:
    print((1))
    exit()
ans = 1
i = 0
while i < K:
    ans += 1
    x = (x * 10 + 7) % K
    if x == 7 % K:
        print("-1")
        exit()
    if x == 0:
        print(ans)
        exit()
    i += 1
print("-1")

K = int(eval(input()))
x = 7 % K  # mod(K)
if K == 1 or K == 7:
    print((1))
    exit()
ans = 1
i = 0
while i < K:
    ans += 1
    x = (x * 10 + 7) % K
    if x == 0:
        print(ans)
        exit()
    i += 1
print("-1")

-    if x == 7 % K: -        print("-1") -        exit()