ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

k = ni()

a = [0]*(10**6+1)
a[1] = 7%k
for i in range(2,k+1):
  a[i] = (a[i-1]*10+7)%k
for i in range(1,k+1):
  if a[i]==0:
    print(i)
    exit()
print(-1) ni = lambda: int(input()) ni lambda: int(input()) int(input()) int input() input nm = lambda: map(int, input().split()) nm lambda: map(int, input().split()) map(int, input().split()) map int input().split() ().split () input split nl = lambda: list(map(int, input().split())) nl lambda: list(map(int, input().split())) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split k = ni() k ni() ni a = [0]*(10**6+1) a [0]*(10**6+1) [0] 0 10**6+1 10**6 10 6 1 a[1] = 7%k a[1] a 1 7%k 7 k for i in range(2,k+1):
  a[i] = (a[i-1]*10+7)%k i range(2,k+1) range 2 k+1 k 1 a[i] = (a[i-1]*10+7)%k a[i] a i (a[i-1]*10+7)%k a[i-1]*10+7 a[i-1]*10 a[i-1] a i-1 i 1 10 7 k for i in range(1,k+1):
  if a[i]==0:
    print(i)
    exit() i range(1,k+1) range 1 k+1 k 1 if a[i]==0:
    print(i)
    exit() a[i]==0 a[i] a i 0 print(i) print i exit() exit print(-1) print -1 nm = lambda: map(int, input().split()) lambda: map(int, input().split()) nm nl = lambda: list(map(int, input().split())) lambda: list(map(int, input().split())) nl ni = lambda: int(input()) lambda: int(input()) ni k = ni() ni() k a = [0]*(10**6+1) [0]*(10**6+1) a
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

k = ni()

a = [0]*(10**6+1)
a[1] = 7%k
for i in range(2,k+1):
  a[i] = (a[i-1]*10+7)%k
for i in range(1,k+1):
  if a[i]==0:
    print(i)
    exit()
print(-1)