k = int(input())
a = 7
flag = 0
for i in range(1,k+1):
    if a % k == 0:
        print(i)
        flag = 1
        break
    a = 10*(a%k) + 7
if flag == 0:
    print(-1)
#     print(a) k = int(input()) k int(input()) int input() input a = 7 a 7 flag = 0 flag 0 for i in range(1,k+1):
    if a % k == 0:
        print(i)
        flag = 1
        break
    a = 10*(a%k) + 7 i range(1,k+1) range 1 k+1 k 1 if a % k == 0:
        print(i)
        flag = 1
        break
     a % k == 0 a % k a k 0 print(i) print i flag = 1 flag 1 break a = 10*(a%k) + 7 a 10*(a%k) + 7 10*(a%k) 10 a%k a k 7 if flag == 0:
    print(-1)
#     print(a) flag == 0 flag 0 print(-1) print -1 flag = 1 1 flag flag = 0 0 flag a = 10*(a%k) + 7 10*(a%k) + 7 a k = int(input()) int(input()) k a = 7 7 a
k = int(input())
a = 7
flag = 0
for i in range(1,k+1):
    if a % k == 0:
        print(i)
        flag = 1
        break
    a = 10*(a%k) + 7
if flag == 0:
    print(-1)
#     print(a)