#ABC 174 C
k = int(input())

sevens = [0] * k

sevens[0] = 7 % k

if k == 7 or k == 1:
    print(1)
    
else:
    for i in range(1, k):
        new = (sevens[i - 1] * 10 + 7) % k
        sevens[i] = new

        if new == 0:
            print(i + 1)
            break
    else:
        print(-1) k = int(input()) k int(input()) int input() input sevens = [0] * k sevens [0] * k [0] 0 k sevens[0] = 7 % k sevens[0] sevens 0 7 % k 7 k if k == 7 or k == 1:
    print(1)
    
else:
    for i in range(1, k):
        new = (sevens[i - 1] * 10 + 7) % k
        sevens[i] = new

        if new == 0:
            print(i + 1)
            break
    else:
        print(-1) k == 7 or k == 1 k == 7 k 7 k == 1 k 1 print(1) print 1 for i in range(1, k):
        new = (sevens[i - 1] * 10 + 7) % k
        sevens[i] = new

        if new == 0:
            print(i + 1)
            break
    else:
        print(-1) i range(1, k) range 1 k new = (sevens[i - 1] * 10 + 7) % k new (sevens[i - 1] * 10 + 7) % k sevens[i - 1] * 10 + 7 sevens[i - 1] * 10 sevens[i - 1] sevens i - 1 i 1 10 7 k sevens[i] = new sevens[i] sevens i new if new == 0:
            print(i + 1)
            break
     new == 0 new 0 print(i + 1) print i + 1 i 1 break print(-1) print -1 sevens = [0] * k [0] * k sevens k = int(input()) int(input()) k new = (sevens[i - 1] * 10 + 7) % k (sevens[i - 1] * 10 + 7) % k new
#ABC 174 C
k = int(input())

sevens = [0] * k

sevens[0] = 7 % k

if k == 7 or k == 1:
    print(1)
    
else:
    for i in range(1, k):
        new = (sevens[i - 1] * 10 + 7) % k
        sevens[i] = new

        if new == 0:
            print(i + 1)
            break
    else:
        print(-1)