from collections import defaultdict

from collections import deque

from collections import Counter

import itertools

import math

import bisect



def readInt():

  return int(eval(input()))

def readInts():

  return list(map(int, input().split()))

def readChar():

  return eval(input())

def readChars():

  return input().split()





x = 0

k = readInt()

a = 7%k

ans = 0

for i in range(10**6+1):

  x = (x*10%k+a)%k

  ans += 1

  if x==0:

    print(ans)

    exit()



print((-1))
from collections import defaultdict

from collections import deque

from collections import Counter

import math



def readInt():

	return int(eval(input()))

def readInts():

	return list(map(int, input().split()))

def readChar():

	return eval(input())

def readChars():

	return input().split()



k = readInt()



n = 7

for i in range(10**6):

	if n%k==0:

		print((i+1))

		exit()

	else:

		n = (n*10+7)%k



print((-1))
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math
import bisect


def readInt():
    return int(eval(input()))


def readInts():
    return list(map(int, input().split()))


def readChar():
    return eval(input())


def readChars():
    return input().split()


x = 0
k = readInt()
a = 7 % k
ans = 0
for i in range(10**6 + 1):
    x = (x * 10 % k + a) % k
    ans += 1
    if x == 0:
        print(ans)
        exit()
print((-1))

from collections import defaultdict
from collections import deque
from collections import Counter
import math


def readInt():
    return int(eval(input()))


def readInts():
    return list(map(int, input().split()))


def readChar():
    return eval(input())


def readChars():
    return input().split()


k = readInt()
n = 7
for i in range(10**6):
    if n % k == 0:
        print((i + 1))
        exit()
    else:
        n = (n * 10 + 7) % k
print((-1))

-import itertools -import bisect -x = 0 -a = 7 % k -ans = 0 -for i in range(10**6 + 1): -    x = (x * 10 % k + a) % k -    ans += 1 -    if x == 0: -        print(ans) +n = 7 +for i in range(10**6): +    if n % k == 0: +        print((i + 1)) +    else: +        n = (n * 10 + 7) % k