k = int(input())

if(k%2 == 0 or k%5 == 0):
    print('-1')
else:
    if(k%7 == 0):
        k = k // 7
    num = 1
    ans = 1
    while(True):
        if(num%k == 0):
            print(ans)
            break
        else:
            num %= k
            num *= 10
            num += 1
            ans += 1

 k = int(input()) k int(input()) int input() input if(k%2 == 0 or k%5 == 0):
    print('-1')
else:
    if(k%7 == 0):
        k = k // 7
    num = 1
    ans = 1
    while(True):
        if(num%k == 0):
            print(ans)
            break
        else:
            num %= k
            num *= 10
            num += 1
            ans += 1 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' if(k%7 == 0):
        k = k // 7
     k%7 == 0 k%7 k 7 0 k = k // 7 k k // 7 k 7 num = 1 num 1 ans = 1 ans 1 while(True):
        if(num%k == 0):
            print(ans)
            break
        else:
            num %= k
            num *= 10
            num += 1
            ans += 1 True if(num%k == 0):
            print(ans)
            break
        else:
            num %= k
            num *= 10
            num += 1
            ans += 1 num%k == 0 num%k num k 0 print(ans) print ans break num %= k num k num *= 10 num 10 num += 1 num 1 ans += 1 ans 1 k = int(input()) int(input()) k num *= 10 10 num num += 1 1 num ans = 1 1 ans num %= k k num k = k // 7 k // 7 k ans += 1 1 ans num = 1 1 num
k = int(input())

if(k%2 == 0 or k%5 == 0):
    print('-1')
else:
    if(k%7 == 0):
        k = k // 7
    num = 1
    ans = 1
    while(True):
        if(num%k == 0):
            print(ans)
            break
        else:
            num %= k
            num *= 10
            num += 1
            ans += 1


