### BUGGY CODE ###

# abc174_c.py
# https://atcoder.jp/contests/abc174/tasks/abc174_c

global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    K = int(lines[0])
    # N, M = list(map(int, lines[0].split()))
    # values = list(map(int, lines[0].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    if K % 2 == 0:
        return [-1]
    if K % 5 == 0:
        return [-1]

    amari = 10**6 - (10**6 // K) * K

    for k in range(1, K+1):
        mini_k = -(-k // 6)
        target = 0
        for m in range(mini_k):
            amari_m = 1
            for _ in range(m):
                amari_m *= amari
                q, amari_m = divmod(amari_m, K)
            q, amari_m = divmod(amari_m, K)
            if m == mini_k-1:
                target += int('7' * (k-6*m)) * amari_m
            else:
                target += 777777 * amari_m
        log(f'target=[{target}]')
        q, mod = divmod(target, K)
        if mod == 0:
            return [k]

    return [-2]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['101']
        lines_export = [4]
    if pattern == 2:
        lines_input = ['2']
        lines_export = [-1]
    if pattern == 3:
        lines_input = ['999983']
        lines_export = [999982]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


### FIXED CODE ###

# abc174_c.py
# https://atcoder.jp/contests/abc174/tasks/abc174_c


# [開発時用] ログ関数
def lg(value):
    flag = False
    flag = True
    if flag:
        print(str(value))


# [開発時用] exit処理
def xt(log):
    lg('★exit() - ' + str(log))
    exit()


# 本体
def get_results():

    # 引数処理部
    lines = list()
    # 仕様でn行と決まっている場合(の例)
    lines_count = 1
    # 先頭行のNで行数が決まる場合(の例)
    # line = input()
    # lines.append(line)
    # N = int(line)
    # lines_count = N
    for _ in range(lines_count):
        lines.append(input())

    # 演算部
    # S = lines[0]
    K = int(lines[0])
    # N, M = list(map(int, lines[0].split()))
    # values = list(map(int, lines[0].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    result = 0

    tmp = 7

    if K % 5 == 0 or K % 2 == 0:
        return [-1]

    for k in range(K):

        q, mod = divmod(tmp, K)
        if mod == 0:
            return [k+1]
        tmp = mod * 10 + 7


# 主処理
def main():
    results = get_results()

    for result in results:
        print(result)


# 起動処理
if __name__ == '__main__':
    main()