# author:  Taichicchi
# created: 19.09.2020 00:06:44

import sys

K = int(input())

a = 7 % K

for k in range(K + 2):
    if a == 0:
        print(k + 1)
        break
    a = (a * 10 + 7) % K
else:
    print(-1) import sys sys K = int(input()) K int(input()) int input() input a = 7 % K a 7 % K 7 K for k in range(K + 2):
    if a == 0:
        print(k + 1)
        break
    a = (a * 10 + 7) % K
else:
    print(-1) k range(K + 2) range K + 2 K 2 if a == 0:
        print(k + 1)
        break
     a == 0 a 0 print(k + 1) print k + 1 k 1 break a = (a * 10 + 7) % K a (a * 10 + 7) % K a * 10 + 7 a * 10 a 10 7 K print(-1) print -1 K = int(input()) int(input()) K a = 7 % K 7 % K a a = (a * 10 + 7) % K (a * 10 + 7) % K a
# author:  Taichicchi
# created: 19.09.2020 00:06:44

import sys

K = int(input())

a = 7 % K

for k in range(K + 2):
    if a == 0:
        print(k + 1)
        break
    a = (a * 10 + 7) % K
else:
    print(-1)
