import sys
k = int(input())
a = dict()
cnt = 0
base = 0
while True:
    cnt += 1
    base = (base*10+7)%k
    if base == 0:
        break
    if base in a:
        cnt = -1
        break
    else:
        a[base] = 1
print(cnt) import sys sys k = int(input()) k int(input()) int input() input a = dict() a dict() dict cnt = 0 cnt 0 base = 0 base 0 while True:
    cnt += 1
    base = (base*10+7)%k
    if base == 0:
        break
    if base in a:
        cnt = -1
        break
    else:
        a[base] = 1 True cnt += 1 cnt 1 base = (base*10+7)%k base (base*10+7)%k base*10+7 base*10 base 10 7 k if base == 0:
        break
     base == 0 base 0 break if base in a:
        cnt = -1
        break
    else:
        a[base] = 1 base in a base a cnt = -1 cnt -1 break a[base] = 1 a[base] a base 1 print(cnt) print cnt k = int(input()) int(input()) k a = dict() dict() a base = 0 0 base cnt = 0 0 cnt base = (base*10+7)%k (base*10+7)%k base cnt += 1 1 cnt cnt = -1 -1 cnt
import sys
k = int(input())
a = dict()
cnt = 0
base = 0
while True:
    cnt += 1
    base = (base*10+7)%k
    if base == 0:
        break
    if base in a:
        cnt = -1
        break
    else:
        a[base] = 1
print(cnt)