import sys

n=input()
test=list(set(n))
#print(test)
if len(test)==1 and test[0]=="7":
    print(len(n))
    sys.exit()
n=int(n)
if n==1:
    print(1)
    sys.exit()
if n%2 ==0:
    print(-1)
    sys.exit()

Ai=[7%n]
for i in range(1,n+1):
    res=(Ai[i-1]*10 + 7)%n
    if res ==0:
        print(i+1)
        sys.exit()
    Ai.append(res)
print(-1) import sys sys n=input() n input() input test=list(set(n)) test list(set(n)) list set(n) set n if len(test)==1 and test[0]=="7":
    print(len(n))
    sys.exit() len(test)==1 and test[0]=="7" len(test)==1 len(test) len test 1 test[0]=="7" test[0] test 0 "7" print(len(n)) print len(n) len n sys.exit() sys.exit sys exit n=int(n) n int(n) int n if n==1:
    print(1)
    sys.exit() n==1 n 1 print(1) print 1 sys.exit() sys.exit sys exit if n%2 ==0:
    print(-1)
    sys.exit() n%2 ==0 n%2 n 2 0 print(-1) print -1 sys.exit() sys.exit sys exit Ai=[7%n] Ai [7%n] 7%n 7 n for i in range(1,n+1):
    res=(Ai[i-1]*10 + 7)%n
    if res ==0:
        print(i+1)
        sys.exit()
    Ai.append(res) i range(1,n+1) range 1 n+1 n 1 res=(Ai[i-1]*10 + 7)%n res (Ai[i-1]*10 + 7)%n Ai[i-1]*10 + 7 Ai[i-1]*10 Ai[i-1] Ai i-1 i 1 10 7 n if res ==0:
        print(i+1)
        sys.exit()
     res ==0 res 0 print(i+1) print i+1 i 1 sys.exit() sys.exit sys exit Ai.append(res) Ai.append Ai append res print(-1) print -1 n=int(n) int(n) n Ai=[7%n] [7%n] Ai n=input() input() n res=(Ai[i-1]*10 + 7)%n (Ai[i-1]*10 + 7)%n res test=list(set(n)) list(set(n)) test
import sys

n=input()
test=list(set(n))
#print(test)
if len(test)==1 and test[0]=="7":
    print(len(n))
    sys.exit()
n=int(n)
if n==1:
    print(1)
    sys.exit()
if n%2 ==0:
    print(-1)
    sys.exit()

Ai=[7%n]
for i in range(1,n+1):
    res=(Ai[i-1]*10 + 7)%n
    if res ==0:
        print(i+1)
        sys.exit()
    Ai.append(res)
print(-1)