K = int(input())

if K%2 == 0 or K%5 == 0:
    print(-1)

elif K%7 == 0:
    x = -1
    b = 9*K/7
    c = 10%b

    for i in range(1,K+1):
        if c ==1:
            x = i
            break
        c = (c*10)%b

    print(x)

else:
    x = -1
    b = 9*K
    c = 10%b
    for i in range(1,K+1):
        if c ==1:
            x = i
            break
        c = (c*10)%b
        #print(c)
    print(x) K = int(input()) K int(input()) int input() input if K%2 == 0 or K%5 == 0:
    print(-1)

elif K%7 == 0:
    x = -1
    b = 9*K/7
    c = 10%b

    for i in range(1,K+1):
        if c ==1:
            x = i
            break
        c = (c*10)%b

    print(x)

else:
    x = -1
    b = 9*K
    c = 10%b
    for i in range(1,K+1):
        if c ==1:
            x = i
            break
        c = (c*10)%b
        #print(c)
    print(x) K%2 == 0 or K%5 == 0 K%2 == 0 K%2 K 2 0 K%5 == 0 K%5 K 5 0 print(-1) print -1 elif K%7 == 0:
    x = -1
    b = 9*K/7
    c = 10%b

    for i in range(1,K+1):
        if c ==1:
            x = i
            break
        c = (c*10)%b

    print(x) K%7 == 0 K%7 K 7 0 x = -1 x -1 b = 9*K/7 b 9*K/7 9*K 9 K 7 c = 10%b c 10%b 10 b for i in range(1,K+1):
        if c ==1:
            x = i
            break
        c = (c*10)%b

     i range(1,K+1) range 1 K+1 K 1 if c ==1:
            x = i
            break
         c ==1 c 1 x = i x i break c = (c*10)%b c (c*10)%b c*10 c 10 b print(x) print x x = -1 x -1 b = 9*K b 9*K 9 K c = 10%b c 10%b 10 b for i in range(1,K+1):
        if c ==1:
            x = i
            break
        c = (c*10)%b
        #print(c)
     i range(1,K+1) range 1 K+1 K 1 if c ==1:
            x = i
            break
         c ==1 c 1 x = i x i break c = (c*10)%b c (c*10)%b c*10 c 10 b print(x) print x x = i i x b = 9*K/7 9*K/7 b x = -1 -1 x K = int(input()) int(input()) K b = 9*K 9*K b c = 10%b 10%b c c = (c*10)%b (c*10)%b c c = 10%b 10%b c x = i i x c = (c*10)%b (c*10)%b c x = -1 -1 x
K = int(input())

if K%2 == 0 or K%5 == 0:
    print(-1)

elif K%7 == 0:
    x = -1
    b = 9*K/7
    c = 10%b

    for i in range(1,K+1):
        if c ==1:
            x = i
            break
        c = (c*10)%b

    print(x)

else:
    x = -1
    b = 9*K
    c = 10%b
    for i in range(1,K+1):
        if c ==1:
            x = i
            break
        c = (c*10)%b
        #print(c)
    print(x)