using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace debug
{
    class main
    {
        static void Main(string[] args)
        {
            //問題クラスを展開
            ProgramC a = new ProgramC();
            a.main();//実行する

        }

    }
    //ABC170
    class ProgramA
    {
        public void main()
        {
            //入力
            int x = int.Parse(Console.ReadLine());


            if (x >= 30)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");

        }
    }

    class ProgramB
    {
        public void main()
        {
            //入力
            
            string[] s = Console.ReadLine().Split(' ');
            long n = long.Parse(s[0]);
            long d = long.Parse(s[1]);

            long count = 0;
            for(int i = 0; i < n;i++)
            {
                string[] t = Console.ReadLine().Split(' ');
                long x = long.Parse(t[0]);
                long y = long.Parse(t[1]);
                if (x * x + y * y <= d * d)
                    count++;
            }

            Console.WriteLine(count);

        }
    }

    class ProgramC
    {
        public void main()
        {

            //入力
            int k = int.Parse(Console.ReadLine());

            if(k % 2 == 0)
            {
                Console.WriteLine("-1");
                return;
            }

            if (7 % k == 0)
            {
                Console.WriteLine("1");
                return;
            }


            int flag = 0;
            long num = 7;
            long count = 1;

            while(flag == 0)
            {
                count++;
                num *= 10;
                num += 7;
                num %= k;
                if (num == 0)
                    flag = 1;
                if (count >= 10000000)
                {
                    Console.WriteLine("-1");
                    return;
                }
                
            }

            Console.WriteLine(count);




        }
    }

    class ProgramD
    {
        public void main()
        {

            //入力
            long n = long.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            int count = 0;
            long num = 0;
            long num2 = 0;
            for (int i = 0; i < n; i++)
            {
                if (s[i] == '1')
                    count++;
            }

            if (count == 0)
            {
                for (int i = 0; i < n; i++)
                    Console.WriteLine("1");
                return;
            }

            if (count == 1)
            {
                if (s[(int)n - 1] == '1')
                {
                    for (int i = 0; i < n; i++)
                    {
                        if (i == n - 1)
                            Console.WriteLine("0");
                        else
                            Console.WriteLine("2");
                    }
                }
                else
                {
                    for (int i = 0; i < n; i++)
                    {
                        if (s[i] == '1')
                            Console.WriteLine("0");
                        else if(i == n -1)
                            Console.WriteLine("2");
                        else
                            Console.WriteLine("1");
                    }
                }
                return;
            }

            for (int i = 0; i < n; i++)
            {
                if (s[i] == '1')
                {
                    num += modpow(2, n - 1 - i, count -1);
                    num2 += modpow(2, n - 1 - i, count + 1);
                }
            }

            for (int i = 0; i < n; i++)
            {
                long temp = 0;

                if (s[i] == '1')
                {
                    temp = num;
                    temp -= modpow(2, n - 1 - i, count - 1);
                    temp %= count - 1;
                }
                else
                {
                    temp = num2;
                    temp += modpow(2, n - 1 - i, count + 1);
                    temp %= count + 1;
                }

                long ans = 1;

                while(temp != 0)
                {
                    long t = 0;
                    long t2 = temp;
                    while (temp != 0)
                    {
                        t += temp % 2;
                        temp /= 2;
                    }

                    temp = t2 % t;
                    ans++;

                }

                Console.WriteLine(ans);
            }

        }

        static long modpow(long a, long n, long MOD)
        {
            if (n == 0)
                return 1;
            if (n % 2 == 0)
            {
                long temp = modpow(a, n / 2, MOD);
                return temp * temp % MOD;
            }

            return a * modpow(a, n - 1, MOD) % MOD;
        }
    }

    class ProgramE
    {

        public void main()
        {
            //入力
            int t = int.Parse(Console.ReadLine());


            for(int x = 0;x < t;x++)
            {
                int n = int.Parse(Console.ReadLine());
                for(int i = 0;i < n;i++)
                {

                }

            }


        }


    }

}






Measured memory_bytes: 27460