K = int(input())
if K%2==0:
    print(-1)
elif K==1:
    print(1)
elif K==7:
    print(1)
else:
    if K%7==0:
        K = K//7
    a = 1
    cnt = 1
    ind = -1
    for i in range(K):
        a = (a*10)%K
        cnt += a
        if cnt%K==0:
            ind = i
            break
    if ind<0:
        print(-1)
    else:
        print(ind+2) K = int(input()) K int(input()) int input() input if K%2==0:
    print(-1)
elif K==1:
    print(1)
elif K==7:
    print(1)
else:
    if K%7==0:
        K = K//7
    a = 1
    cnt = 1
    ind = -1
    for i in range(K):
        a = (a*10)%K
        cnt += a
        if cnt%K==0:
            ind = i
            break
    if ind<0:
        print(-1)
    else:
        print(ind+2) K%2==0 K%2 K 2 0 print(-1) print -1 elif K==1:
    print(1) K==1 K 1 print(1) print 1 elif K==7:
    print(1) K==7 K 7 print(1) print 1 if K%7==0:
        K = K//7
     K%7==0 K%7 K 7 0 K = K//7 K K//7 K 7 a = 1 a 1 cnt = 1 cnt 1 ind = -1 ind -1 for i in range(K):
        a = (a*10)%K
        cnt += a
        if cnt%K==0:
            ind = i
            break
     i range(K) range K a = (a*10)%K a (a*10)%K a*10 a 10 K cnt += a cnt a if cnt%K==0:
            ind = i
            break
     cnt%K==0 cnt%K cnt K 0 ind = i ind i break if ind<0:
        print(-1)
    else:
        print(ind+2) ind<0 ind 0 print(-1) print -1 print(ind+2) print ind+2 ind 2 cnt += a a cnt a = 1 1 a cnt = 1 1 cnt a = (a*10)%K (a*10)%K a ind = -1 -1 ind K = int(input()) int(input()) K K = K//7 K//7 K ind = i i ind
K = int(input())
if K%2==0:
    print(-1)
elif K==1:
    print(1)
elif K==7:
    print(1)
else:
    if K%7==0:
        K = K//7
    a = 1
    cnt = 1
    ind = -1
    for i in range(K):
        a = (a*10)%K
        cnt += a
        if cnt%K==0:
            ind = i
            break
    if ind<0:
        print(-1)
    else:
        print(ind+2)