from sys import stdin

input = stdin.readline
import math

def solve():
    k = int(input())
    if k % 2 == 0 or k % 5 == 0:
        print(-1)
        return
    cnt = 1
    cur = 7
    while True:
        r = cur % k
        if r == 0:
            print(cnt)
            break
        cur = r * 10 + 7
        cnt += 1

if __name__ == '__main__':
    solve() from sys import stdin input = stdin.readline input stdin.readline stdin readline import math math def solve():
    k = int(input())
    if k % 2 == 0 or k % 5 == 0:
        print(-1)
        return
    cnt = 1
    cur = 7
    while True:
        r = cur % k
        if r == 0:
            print(cnt)
            break
        cur = r * 10 + 7
        cnt += 1 solve k = int(input()) k int(input()) int input() input if k % 2 == 0 or k % 5 == 0:
        print(-1)
        return
     k % 2 == 0 or k % 5 == 0 k % 2 == 0 k % 2 k 2 0 k % 5 == 0 k % 5 k 5 0 print(-1) print -1 return cnt = 1 cnt 1 cur = 7 cur 7 while True:
        r = cur % k
        if r == 0:
            print(cnt)
            break
        cur = r * 10 + 7
        cnt += 1 True r = cur % k r cur % k cur k if r == 0:
            print(cnt)
            break
         r == 0 r 0 print(cnt) print cnt break cur = r * 10 + 7 cur r * 10 + 7 r * 10 r 10 7 cnt += 1 cnt 1 if __name__ == '__main__':
    solve() __name__ == '__main__' __name__ '__main__' solve() solve def solve():
    k = int(input())
    if k % 2 == 0 or k % 5 == 0:
        print(-1)
        return
    cnt = 1
    cur = 7
    while True:
        r = cur % k
        if r == 0:
            print(cnt)
            break
        cur = r * 10 + 7
        cnt += 1 def solve():
    k = int(input())
    if k % 2 == 0 or k % 5 == 0:
        print(-1)
        return
    cnt = 1
    cur = 7
    while True:
        r = cur % k
        if r == 0:
            print(cnt)
            break
        cur = r * 10 + 7
        cnt += 1 solve input = stdin.readline stdin.readline input
from sys import stdin

input = stdin.readline
import math

def solve():
    k = int(input())
    if k % 2 == 0 or k % 5 == 0:
        print(-1)
        return
    cnt = 1
    cur = 7
    while True:
        r = cur % k
        if r == 0:
            print(cnt)
            break
        cur = r * 10 + 7
        cnt += 1

if __name__ == '__main__':
    solve()
