import sys
#import time
from collections import deque, Counter, defaultdict
#from fractions import gcd
import bisect
import heapq
#import math
import itertools
import numpy as np
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))

k = ri()
reses=[]
cnt = 1
tmp = 7
for i in range(k+1):
    res = tmp % k
    if res==0:
        print(cnt)
        sys.exit(0)
    tmp = res * 10 + 7
    cnt += 1
print(-1) import sys sys from collections import deque, Counter, defaultdict import bisect bisect import heapq heapq import itertools itertools import numpy as np numpy input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline sys.setrecursionlimit(10**8) sys.setrecursionlimit sys setrecursionlimit 10**8 10 8 inf = 10**18 inf 10**18 10 18 MOD = 1000000007 MOD 1000000007 ri = lambda : int(input()) ri lambda : int(input()) int(input()) int input() input rs = lambda : input().strip() rs lambda : input().strip() input().strip() ().strip () input strip rl = lambda : list(map(int, input().split())) rl lambda : list(map(int, input().split())) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split k = ri() k ri() ri reses=[] reses [] cnt = 1 cnt 1 tmp = 7 tmp 7 for i in range(k+1):
    res = tmp % k
    if res==0:
        print(cnt)
        sys.exit(0)
    tmp = res * 10 + 7
    cnt += 1 i range(k+1) range k+1 k 1 res = tmp % k res tmp % k tmp k if res==0:
        print(cnt)
        sys.exit(0)
     res==0 res 0 print(cnt) print cnt sys.exit(0) sys.exit sys exit 0 tmp = res * 10 + 7 tmp res * 10 + 7 res * 10 res 10 7 cnt += 1 cnt 1 print(-1) print -1 ri = lambda : int(input()) lambda : int(input()) ri cnt += 1 1 cnt rs = lambda : input().strip() lambda : input().strip() rs tmp = res * 10 + 7 res * 10 + 7 tmp input = sys.stdin.readline sys.stdin.readline input rl = lambda : list(map(int, input().split())) lambda : list(map(int, input().split())) rl inf = 10**18 10**18 inf res = tmp % k tmp % k res MOD = 1000000007 1000000007 MOD tmp = 7 7 tmp reses=[] [] reses k = ri() ri() k cnt = 1 1 cnt
import sys
#import time
from collections import deque, Counter, defaultdict
#from fractions import gcd
import bisect
import heapq
#import math
import itertools
import numpy as np
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))

k = ri()
reses=[]
cnt = 1
tmp = 7
for i in range(k+1):
    res = tmp % k
    if res==0:
        print(cnt)
        sys.exit(0)
    tmp = res * 10 + 7
    cnt += 1
print(-1)