K = int(input())

first_mod = 7 % K
"""
cnt = 1
if first_mod == 0:
    print(1)
else:
    flg = True
    for i in range(2,K):
        seven = old * 10 + 7
        mod = seven % K
        cnt += 1
        old = seven
        if mod == 0:
            break
        if mod == first_mod:
            flg = False
            break
    if flg:
        print(cnt)
    else:
        print(-1)
"""
old_mod = now_mod = first_mod

cnt = 1
if first_mod == 0:
    print(1)
else:
    flg = False
    for i in range(2,K+1):
        now_mod = ((old_mod * 10) + 7) % K
        cnt += 1
        old_mod = now_mod
        if now_mod == 0:
            flg = True
            break
        if now_mod == first_mod:
            break
    if flg:
        print(cnt)
    else:
        print(-1) K = int(input()) K int(input()) int input() input first_mod = 7 % K first_mod 7 % K 7 K """
cnt = 1
if first_mod == 0:
    print(1)
else:
    flg = True
    for i in range(2,K):
        seven = old * 10 + 7
        mod = seven % K
        cnt += 1
        old = seven
        if mod == 0:
            break
        if mod == first_mod:
            flg = False
            break
    if flg:
        print(cnt)
    else:
        print(-1)
""" old_mod = now_mod = first_mod old_mod first_mod = now_mod = first_mod now_mod first_mod cnt = 1 cnt 1 if first_mod == 0:
    print(1)
else:
    flg = False
    for i in range(2,K+1):
        now_mod = ((old_mod * 10) + 7) % K
        cnt += 1
        old_mod = now_mod
        if now_mod == 0:
            flg = True
            break
        if now_mod == first_mod:
            break
    if flg:
        print(cnt)
    else:
        print(-1) first_mod == 0 first_mod 0 print(1) print 1 flg = False flg False for i in range(2,K+1):
        now_mod = ((old_mod * 10) + 7) % K
        cnt += 1
        old_mod = now_mod
        if now_mod == 0:
            flg = True
            break
        if now_mod == first_mod:
            break
     i range(2,K+1) range 2 K+1 K 1 now_mod = ((old_mod * 10) + 7) % K now_mod ((old_mod * 10) + 7) % K (old_mod * 10) + 7 old_mod * 10 old_mod 10 7 K cnt += 1 cnt 1 old_mod = now_mod old_mod now_mod if now_mod == 0:
            flg = True
            break
         now_mod == 0 now_mod 0 flg = True flg True break if now_mod == first_mod:
            break
     now_mod == first_mod now_mod first_mod break if flg:
        print(cnt)
    else:
        print(-1) flg print(cnt) print cnt print(-1) print -1 first_mod = 7 % K 7 % K first_mod now_mod = ((old_mod * 10) + 7) % K ((old_mod * 10) + 7) % K now_mod cnt += 1 1 cnt K = int(input()) int(input()) K now_mod = first_mod first_mod now_mod cnt = 1 1 cnt old_mod = now_mod now_mod old_mod flg = False False flg old_mod = now_mod = first_mod first_mod old_mod flg = True True flg
K = int(input())

first_mod = 7 % K
"""
cnt = 1
if first_mod == 0:
    print(1)
else:
    flg = True
    for i in range(2,K):
        seven = old * 10 + 7
        mod = seven % K
        cnt += 1
        old = seven
        if mod == 0:
            break
        if mod == first_mod:
            flg = False
            break
    if flg:
        print(cnt)
    else:
        print(-1)
"""
old_mod = now_mod = first_mod

cnt = 1
if first_mod == 0:
    print(1)
else:
    flg = False
    for i in range(2,K+1):
        now_mod = ((old_mod * 10) + 7) % K
        cnt += 1
        old_mod = now_mod
        if now_mod == 0:
            flg = True
            break
        if now_mod == first_mod:
            break
    if flg:
        print(cnt)
    else:
        print(-1)