#!/usr/bin/env python3
import sys
from itertools import chain

# form bisect import bisect_left, bisect_right, insort_left, insort_right
# import numpy as np

# 7.n = 7 * 1.n = 101
7777


def solve(K: int):
    n = 7
    for answer in range(1, K + 1):
        if n % K == 0:
            return answer
        n = 10 * (n % K) + 7
    return -1


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    # K = map(int, line.split())
    K = int(next(tokens))  # type: int
    answer = solve(K)
    print(answer)


if __name__ == "__main__":
    main() import sys sys from itertools import chain 7777 def solve(K: int):
    n = 7
    for answer in range(1, K + 1):
        if n % K == 0:
            return answer
        n = 10 * (n % K) + 7
    return -1 solve n = 7 n 7 for answer in range(1, K + 1):
        if n % K == 0:
            return answer
        n = 10 * (n % K) + 7
     answer range(1, K + 1) range 1 K + 1 K 1 if n % K == 0:
            return answer
         n % K == 0 n % K n K 0 return answer answer n = 10 * (n % K) + 7 n 10 * (n % K) + 7 10 * (n % K) 10 n % K n K 7 return -1 -1 K: int K def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    # K = map(int, line.split())
    K = int(next(tokens))  # type: int
    answer = solve(K)
    print(answer) main line.split() for line in sys.stdin for line in sys.stdin line sys.stdin sys stdin for line in sys.stdin line.split() line.split line split tokens = chain(*(line.split() for line in sys.stdin)) tokens chain(*(line.split() for line in sys.stdin)) chain *(line.split() for line in sys.stdin) (line.split() for line in sys.stdin) K = int(next(tokens)) K int(next(tokens)) int next(tokens) next tokens answer = solve(K) answer solve(K) solve K print(answer) print answer if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    # K = map(int, line.split())
    K = int(next(tokens))  # type: int
    answer = solve(K)
    print(answer) def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    # K = map(int, line.split())
    K = int(next(tokens))  # type: int
    answer = solve(K)
    print(answer) main def solve(K: int):
    n = 7
    for answer in range(1, K + 1):
        if n % K == 0:
            return answer
        n = 10 * (n % K) + 7
    return -1 def solve(K: int):
    n = 7
    for answer in range(1, K + 1):
        if n % K == 0:
            return answer
        n = 10 * (n % K) + 7
    return -1 solve
#!/usr/bin/env python3
import sys
from itertools import chain

# form bisect import bisect_left, bisect_right, insort_left, insort_right
# import numpy as np

# 7.n = 7 * 1.n = 101
7777


def solve(K: int):
    n = 7
    for answer in range(1, K + 1):
        if n % K == 0:
            return answer
        n = 10 * (n % K) + 7
    return -1


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    # K = map(int, line.split())
    K = int(next(tokens))  # type: int
    answer = solve(K)
    print(answer)


if __name__ == "__main__":
    main()
