import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI0(): return map(lambda s: int(s) - 1, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
def LMI0(): return list(map(lambda s: int(s) - 1, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


K = I()
num = 7
for i in range(10 ** 6):
    if num % K == 0:
        print(i + 1)
        exit()
    num = (num * 10 + 7) % K
print(-1) import sys sys sys.setrecursionlimit(300000) sys.setrecursionlimit sys setrecursionlimit 300000 def I(): return int(sys.stdin.readline()) I def MI(): return map(int, sys.stdin.readline().split()) MI def MI0(): return map(lambda s: int(s) - 1, sys.stdin.readline().split()) MI0 def LMI(): return list(map(int, sys.stdin.readline().split())) LMI def LMI0(): return list(map(lambda s: int(s) - 1, sys.stdin.readline().split())) LMI0 MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 INF = float('inf') INF float('inf') float 'inf' K = I() K I() I num = 7 num 7 for i in range(10 ** 6):
    if num % K == 0:
        print(i + 1)
        exit()
    num = (num * 10 + 7) % K i range(10 ** 6) range 10 ** 6 10 6 if num % K == 0:
        print(i + 1)
        exit()
     num % K == 0 num % K num K 0 print(i + 1) print i + 1 i 1 exit() exit num = (num * 10 + 7) % K num (num * 10 + 7) % K num * 10 + 7 num * 10 num 10 7 K print(-1) print -1 def LMI(): return list(map(int, sys.stdin.readline().split())) def LMI(): return list(map(int, sys.stdin.readline().split())) LMI num = (num * 10 + 7) % K (num * 10 + 7) % K num def MI(): return map(int, sys.stdin.readline().split()) def MI(): return map(int, sys.stdin.readline().split()) MI def LMI0(): return list(map(lambda s: int(s) - 1, sys.stdin.readline().split())) def LMI0(): return list(map(lambda s: int(s) - 1, sys.stdin.readline().split())) LMI0 INF = float('inf') float('inf') INF num = 7 7 num K = I() I() K def I(): return int(sys.stdin.readline()) def I(): return int(sys.stdin.readline()) I def MI0(): return map(lambda s: int(s) - 1, sys.stdin.readline().split()) def MI0(): return map(lambda s: int(s) - 1, sys.stdin.readline().split()) MI0 MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI0(): return map(lambda s: int(s) - 1, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
def LMI0(): return list(map(lambda s: int(s) - 1, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


K = I()
num = 7
for i in range(10 ** 6):
    if num % K == 0:
        print(i + 1)
        exit()
    num = (num * 10 + 7) % K
print(-1)