def solve(string):
    n, k = 7, int(string)
    if k % 2 == 0 or k % 5 == 0:
        return "-1"
    for i in range(k):
        if not n % k:
            return str(i + 1)
        n = (10 * n + 7) % k


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip())) def solve(string):
    n, k = 7, int(string)
    if k % 2 == 0 or k % 5 == 0:
        return "-1"
    for i in range(k):
        if not n % k:
            return str(i + 1)
        n = (10 * n + 7) % k solve n, k = 7, int(string) n 7 k int(string) int string if k % 2 == 0 or k % 5 == 0:
        return "-1"
     k % 2 == 0 or k % 5 == 0 k % 2 == 0 k % 2 k 2 0 k % 5 == 0 k % 5 k 5 0 return "-1" "-1" for i in range(k):
        if not n % k:
            return str(i + 1)
        n = (10 * n + 7) % k i range(k) range k if not n % k:
            return str(i + 1)
         not n % k n % k n k return str(i + 1) str(i + 1) str i + 1 i 1 n = (10 * n + 7) % k n (10 * n + 7) % k 10 * n + 7 10 * n 10 n 7 k string string if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip())) __name__ == '__main__' __name__ '__main__' import sys sys print(solve(sys.stdin.read().strip())) print solve(sys.stdin.read().strip()) solve sys.stdin.read().strip() sys.stdin.read().strip sys.stdin.read() sys.stdin.read sys.stdin sys stdin read strip def solve(string):
    n, k = 7, int(string)
    if k % 2 == 0 or k % 5 == 0:
        return "-1"
    for i in range(k):
        if not n % k:
            return str(i + 1)
        n = (10 * n + 7) % k def solve(string):
    n, k = 7, int(string)
    if k % 2 == 0 or k % 5 == 0:
        return "-1"
    for i in range(k):
        if not n % k:
            return str(i + 1)
        n = (10 * n + 7) % k solve
def solve(string):
    n, k = 7, int(string)
    if k % 2 == 0 or k % 5 == 0:
        return "-1"
    for i in range(k):
        if not n % k:
            return str(i + 1)
        n = (10 * n + 7) % k


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
