# -*- coding: utf-8 -*-

import numpy as np

import sys

from collections import deque

from collections import defaultdict

import heapq

import collections

import itertools

import bisect

from scipy.special import comb

import copy

sys.setrecursionlimit(10**6)



# lis_of_lis = [[] for _ in range(N)]





def zz():

    return list(map(int, sys.stdin.readline().split()))





def z():

    return int(sys.stdin.readline())





def S():

    return sys.stdin.readline()[:-1]





def C(line):

    return [sys.stdin.readline() for _ in range(line)]





def is_prime(n):

    if n == 1:

        return False

    for i in range(2, int(n**0.5)+1):

        if n % i == 0:

            return False

    return True





K = z()

if K == 7:

    print((1))

    exit()



t = 7 % K

for i in range(1, K * 2):

    if t == 0:

        print(i)

        exit()



    t = (t * 10 + 7) % K



print((-1))

# -*- coding: utf-8 -*-

import numpy as np

import sys

from collections import deque

from collections import defaultdict

import heapq

import collections

import itertools

import bisect

from scipy.special import comb

import copy

sys.setrecursionlimit(10**6)



# lis_of_lis = [[] for _ in range(N)]





def zz():

    return list(map(int, sys.stdin.readline().split()))





def z():

    return int(sys.stdin.readline())





def S():

    return sys.stdin.readline()[:-1]





def C(line):

    return [sys.stdin.readline() for _ in range(line)]





def is_prime(n):

    if n == 1:

        return False

    for i in range(2, int(n**0.5)+1):

        if n % i == 0:

            return False

    return True





K = z()

if K == 7:

    print((1))

    exit()



t = 7 % K

for i in range(1, K+1):

    if t == 0:

        print(i)

        exit()



    t = (t * 10 + 7) % K



print((-1))

# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy

sys.setrecursionlimit(10**6)
# lis_of_lis = [[] for _ in range(N)]
def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0:
            return False
    return True


K = z()
if K == 7:
    print((1))
    exit()
t = 7 % K
for i in range(1, K * 2):
    if t == 0:
        print(i)
        exit()
    t = (t * 10 + 7) % K
print((-1))

# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy

sys.setrecursionlimit(10**6)
# lis_of_lis = [[] for _ in range(N)]
def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0:
            return False
    return True


K = z()
if K == 7:
    print((1))
    exit()
t = 7 % K
for i in range(1, K + 1):
    if t == 0:
        print(i)
        exit()
    t = (t * 10 + 7) % K
print((-1))

-for i in range(1, K * 2): +for i in range(1, K + 1):