# coding: utf-8


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

    ret = 1
    a = 7 % k
    while(a):
        a = (a*10+7) % k
        ret += 1
        if k < 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])

    ret = 1
    a = 7 % k
    while(a):
        a = (a*10+7) % k
        ret += 1
        if k < ret:
            ret = -1
            break

    return str(ret) solve k = int(args[0]) k int(args[0]) int args[0] args 0 ret = 1 ret 1 a = 7 % k a 7 % k 7 k while(a):
        a = (a*10+7) % k
        ret += 1
        if k < ret:
            ret = -1
            break

     a a = (a*10+7) % k a (a*10+7) % k a*10+7 a*10 a 10 7 k ret += 1 ret 1 if k < ret:
            ret = -1
            break

     k < ret k 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])

    ret = 1
    a = 7 % k
    while(a):
        a = (a*10+7) % k
        ret += 1
        if k < ret:
            ret = -1
            break

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

    ret = 1
    a = 7 % k
    while(a):
        a = (a*10+7) % k
        ret += 1
        if k < ret:
            ret = -1
            break

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


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

    ret = 1
    a = 7 % k
    while(a):
        a = (a*10+7) % k
        ret += 1
        if k < ret:
            ret = -1
            break

    return str(ret)


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