k = int(eval(input()))

x = 0

ans = -1

if k % 2 == 1:

    for i in range(10**6):

        x = (x + 7 * pow(10, i, k)) % k

        if x == 0:

            ans = i + 1

            break

print(ans)
def abc174_c():

    k = int(eval(input()))

    ans = -1

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

        return ans

    f = 0

    for i in range(k+1):

        f = (f * 10 + 7) % k

        if f == 0:

            ans = i + 1

            break

    return ans



if __name__ == '__main__':

    print((abc174_c()))
k = int(eval(input()))
x = 0
ans = -1
if k % 2 == 1:
    for i in range(10**6):
        x = (x + 7 * pow(10, i, k)) % k
        if x == 0:
            ans = i + 1
            break
print(ans)

def abc174_c():
    k = int(eval(input()))
    ans = -1
    if k % 2 == 0 or k % 5 == 0:
        return ans
    f = 0
    for i in range(k + 1):
        f = (f * 10 + 7) % k
        if f == 0:
            ans = i + 1
            break
    return ans


if __name__ == "__main__":
    print((abc174_c()))

-k = int(eval(input())) -x = 0 -ans = -1 -if k % 2 == 1: -    for i in range(10**6): -        x = (x + 7 * pow(10, i, k)) % k -        if x == 0: +def abc174_c(): +    k = int(eval(input())) +    ans = -1 +    if k % 2 == 0 or k % 5 == 0: +        return ans +    f = 0 +    for i in range(k + 1): +        f = (f * 10 + 7) % k +        if f == 0: -print(ans) +    return ans + + +if __name__ == "__main__": +    print((abc174_c()))