# coding: utf-8


def solve(*args: str) -> str:
    k = int(args[0])

    l = 9*(k//7 if k % 7 == 0 else k)
    if l % 2 == 0 or l % 5 == 0:
        return '-1'

    r = phi = l
    for i in range(2, int(-pow(l, 1/2))):
        if r % i == 0:
            phi = phi//i*(i-1)
            while r % i:
                r //= i

    a = 10 % l
    ret = 1
    while(a != 1):
        a = a*10 % l
        ret += 1
        if phi < ret:
            ret = -1
            break

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines()))) def solve(*args: str) -> str:
    k = int(args[0])

    l = 9*(k//7 if k % 7 == 0 else k)
    if l % 2 == 0 or l % 5 == 0:
        return '-1'

    r = phi = l
    for i in range(2, int(-pow(l, 1/2))):
        if r % i == 0:
            phi = phi//i*(i-1)
            while r % i:
                r //= i

    a = 10 % l
    ret = 1
    while(a != 1):
        a = a*10 % l
        ret += 1
        if phi < ret:
            ret = -1
            break

    return str(ret) solve k = int(args[0]) k int(args[0]) int args[0] args 0 l = 9*(k//7 if k % 7 == 0 else k) l 9*(k//7 if k % 7 == 0 else k) 9 k//7 if k % 7 == 0 else k k % 7 == 0 k % 7 k 7 0 k//7 k 7 k if l % 2 == 0 or l % 5 == 0:
        return '-1'

     l % 2 == 0 or l % 5 == 0 l % 2 == 0 l % 2 l 2 0 l % 5 == 0 l % 5 l 5 0 return '-1' '-1' r = phi = l r l = phi = l phi l for i in range(2, int(-pow(l, 1/2))):
        if r % i == 0:
            phi = phi//i*(i-1)
            while r % i:
                r //= i

     i range(2, int(-pow(l, 1/2))) range 2 int(-pow(l, 1/2)) int -pow(l, 1/2) pow(l, 1/2) pow l 1/2 1 2 if r % i == 0:
            phi = phi//i*(i-1)
            while r % i:
                r //= i

     r % i == 0 r % i r i 0 phi = phi//i*(i-1) phi phi//i*(i-1) phi//i phi i i-1 i 1 while r % i:
                r //= i

     r % i r i r //= i r i a = 10 % l a 10 % l 10 l ret = 1 ret 1 while(a != 1):
        a = a*10 % l
        ret += 1
        if phi < ret:
            ret = -1
            break

     a != 1 a 1 a = a*10 % l a a*10 % l a*10 a 10 l ret += 1 ret 1 if phi < ret:
            ret = -1
            break

     phi < ret phi ret ret = -1 ret -1 break return str(ret) str(ret) str ret *args: str if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines()))) __name__ == "__main__" __name__ "__main__" print(solve(*(open(0).read().splitlines()))) print solve(*(open(0).read().splitlines())) solve *(open(0).read().splitlines()) open(0).read().splitlines() (0).read().splitlines (0).read() (0).read (0) open 0 read splitlines def solve(*args: str) -> str:
    k = int(args[0])

    l = 9*(k//7 if k % 7 == 0 else k)
    if l % 2 == 0 or l % 5 == 0:
        return '-1'

    r = phi = l
    for i in range(2, int(-pow(l, 1/2))):
        if r % i == 0:
            phi = phi//i*(i-1)
            while r % i:
                r //= i

    a = 10 % l
    ret = 1
    while(a != 1):
        a = a*10 % l
        ret += 1
        if phi < ret:
            ret = -1
            break

    return str(ret) def solve(*args: str) -> str:
    k = int(args[0])

    l = 9*(k//7 if k % 7 == 0 else k)
    if l % 2 == 0 or l % 5 == 0:
        return '-1'

    r = phi = l
    for i in range(2, int(-pow(l, 1/2))):
        if r % i == 0:
            phi = phi//i*(i-1)
            while r % i:
                r //= i

    a = 10 % l
    ret = 1
    while(a != 1):
        a = a*10 % l
        ret += 1
        if phi < ret:
            ret = -1
            break

    return str(ret) solve
# coding: utf-8


def solve(*args: str) -> str:
    k = int(args[0])

    l = 9*(k//7 if k % 7 == 0 else k)
    if l % 2 == 0 or l % 5 == 0:
        return '-1'

    r = phi = l
    for i in range(2, int(-pow(l, 1/2))):
        if r % i == 0:
            phi = phi//i*(i-1)
            while r % i:
                r //= i

    a = 10 % l
    ret = 1
    while(a != 1):
        a = a*10 % l
        ret += 1
        if phi < ret:
            ret = -1
            break

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))
