import sys

def I(): return int(sys.stdin.readline().rstrip())



K = I()

if K % 2 == 0 or K % 5 == 0:

    print((-1))

    exit()

if K % 7 == 0:

    K //= 7



A = [1]  # A[i] = 10**i mod K

for i in range(K):

    A.append((A[-1]*10) % K)



s = 1

for i in range(1,K+1):

    if s % K == 0:

        print(i)

        exit()

    else:

        s += A[i]

        s %= K

import sys

def I(): return int(sys.stdin.readline().rstrip())



K = I()

if K % 2 == 0 or K % 5 == 0:

    print((-1))

    exit()

if K % 7 == 0:

    K //= 7



s = 1

for i in range(1,K+1):

    if s % K == 0:

        print(i)

        exit()

    else:

        s *= 10

        s += 1

        s %= K

import sys


def I():
    return int(sys.stdin.readline().rstrip())


K = I()
if K % 2 == 0 or K % 5 == 0:
    print((-1))
    exit()
if K % 7 == 0:
    K //= 7
A = [1]  # A[i] = 10**i mod K
for i in range(K):
    A.append((A[-1] * 10) % K)
s = 1
for i in range(1, K + 1):
    if s % K == 0:
        print(i)
        exit()
    else:
        s += A[i]
        s %= K

import sys


def I():
    return int(sys.stdin.readline().rstrip())


K = I()
if K % 2 == 0 or K % 5 == 0:
    print((-1))
    exit()
if K % 7 == 0:
    K //= 7
s = 1
for i in range(1, K + 1):
    if s % K == 0:
        print(i)
        exit()
    else:
        s *= 10
        s += 1
        s %= K

-A = [1]  # A[i] = 10**i mod K -for i in range(K): -    A.append((A[-1] * 10) % K) -        s += A[i] +        s *= 10 +        s += 1