#include<bits/stdc++.h>
#include <math.h>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include<map>
using namespace std;
#define ll long long int
typedef unsigned long long int ull;
typedef long double ldb;
#define B 1000000007
#define vi vector<int>
#define vll vector<long long>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define all(v) v.begin(),v.end()
#define INF 1e18
#define LB lower_bound
#define UB upper_bound
#define deci(n) fixed << setprecision(n)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define PI 3.141592653589793238462643
#define BLOCK 555
//ans.resize(unique(ALL(ans)) - ans.begin());
ll leftmostSetBit(ll x) 
{ 
    ll count = 0; 
    while (x) { 
        count++; 
        x = x >> 1; 
    } 
    return count; 
} 

ll smallestDivisor(ll n) 
{ 
    // if divisible by 2 
    if (n % 2 == 0) 
        return 2; 
  
    // iterate from 3 to sqrt(n) 
    for (ll i = 3; i * i <= n; i += 2) { 
        if (n % i == 0) 
            return i; 
    } 
  
    return n; 
} 
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll gcd(ll a,ll b){while(b){ll t=a;a=b;b=t%b;}return a;}     
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

int cnt[200005]={0};
vector<int> adj[200005];
map<int,int,greater<int> > factorize(int n)
{
    int count=0;
    map<int,int,greater<int> > fact;
    while(!(n%2))
    {
        n/=2;
        count++;
    }
    if (count)
    fact[2]+=count;
    for(int i=3;i<=sqrt(n);i+=2)
    {
        count=0;
        while((n%i)==0)
        {
            count++;
            n/=i;
        }
        if (count)
        fact[i]+=count;
    }
    if(n>2)
        fact[n]++;
    for(auto it:fact)
    {
        cnt[it.first]++;
        adj[it.first].pb(it.second);
    }
    return fact;
}

long long int power(long long int x, int p)
{
    if (p == 0)
        return 1;
    long long int ans = power(x, p / 2);
    ans = ans * ans;
    if (p % 2 == 1)
        ans = ans * x;
    return ans;
}
/*
long long int factorial(long long int n){
    if(n <= 1)
        return 1;
    long long int ans = 1;
    for(ll i=1;i<=n;i++){
        ans = ans * i;
        // ans = ans % B;
    }
    return ans;
}

*/
 
/*
ll nCr(ll n,ll k){ 
    ll C[n + 1][k + 1]; 
    ll i, j; 
    for (i=0;i<=n;i++){ 
        for(j=0;j<=min(i,k);j++){
            if(j==0||j==i) 
                C[i][j]=1;  
            else
                C[i][j]=(C[i-1][j-1]%B+C[i-1][j]%B)%B; 
        } 
    }
    return C[n][k]%B; 
}
*/

bool isPrime(ll n) 
{ 
    // Corner cases 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    // This is checked so that we can skip  
    // middle five numbers in below loop 
    if (n%2 == 0 || n%3 == 0) return false; 
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false;   
    return true; 
} 
vector<ll> countDivisors(ll n) 
{ 
    ll cnt = 0; 
    std::vector<ll> v;
    for (ll i = 1; i <= sqrt(n); i++) 
    { 
        if (n % i == 0) 
        {  
         v.pb(i);
            // If divisors are equal, 
            // count only one 
            if (n / i == i) 
                cnt++; 
  
            else // Otherwise count both 
                {cnt = cnt + 2; 
                    v.pb(n/i);}
        } 
    } 
    return v; 
} 


bool isPowerOfTwo(ll x)
    {   // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
        return (x && !(x & (x - 1)));
    }

map<ll,ll> factors(ll n)
 {
        vector<ll> f;
        map<ll,ll> m;
        for (ll x = 2; x*x <= n; x++) 
        {
           while (n%x == 0) {
            f.push_back(x);
            m[x]++;
            n /= x; }
        }
    if (n > 1) 
     {f.push_back(n);
        m[n]++;
     }
  return m;
}

bool cmp(pair<ll,ll>v1,pair<ll,ll>v2)
{
    if(v1.first>v2.first)
    {
        return true;
    }
    else if(v1.first<v2.first)
    {
        return false;
    }
    else
    {
        return v1.second<v2.second;
    }
}

ll binarySearch(ll arr[], ll l, ll r, ll x) 
{ 
    if (r >= l) { 
        ll mid = l + (r - l) / 2; 
        if (arr[mid] == x) 
            return mid;  
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x);  
        return binarySearch(arr, mid + 1, r, x); 
    } 
    return -1; 
} 
int rub[2000001];
bool ispali(int n){
    int no=n;
    int rev=0;
    while(no>0){
            int ld=no%10;
    no/=10;
        rev=rev*10+ld;
    }
    if(n==rev)
        return true;
    else
        return false;
}
void np(){
for(int i=1;i<=2000000;i++){
    if(ispali(i))
        rub[i]=rub[i-1]+1;
    else
        rub[i]=rub[i-1];
}
}

int pi[20000001];
bool isprime[20000001];
void seive(){
for(int i=4;i<=20000000;i+=2)
    isprime[i]=1;
for(int i=3;i*i<=20000000;i+=2){
    if(!isprime[i]){
        for(int j=i*i;j<=20000000;j+=i)
            isprime[j]=1;
    }
}
for(int i=2;i<=20000000;i++){
    if(!isprime[i])
    pi[i]=pi[i-1]+1;
    else
    pi[i]=pi[i-1];
}
}
int g1;
void bfs( vector<vector<int> > &g , int pos , vector<int> visited )
{
    queue <int> q;
    q.push( pos );
    while( q.size()>0 )
    {
       // cout<<q.front()<<" ";
        if(q.front()==g1){ cout<<"yes";return ;}
        int i = q.front();
        q.pop();
         visited[i]=1;
        
        for(int j = 0 ; j < g[i].size() ; j++)
        {
            if( visited[ g[i][j] ] == 0 )
            {
                q.push( g[i][j] );
                visited[g[i][j]] = 1;
            }
        }
    }
  return;   
}
void pairsort(ll a[], ll b[], ll n) 
{ 
    pair<ll, ll> pairt[n]; 
    for (ll i = 0; i < n; i++)  
    { 
        pairt[i].first = a[i]; 
        pairt[i].second = b[i]; 
    } 
    sort(pairt, pairt + n); 
    for (ll i = 0; i < n; i++)  
    { 
        a[i] = pairt[i].first; 
        b[i] = pairt[i].second; 
    } 
}
 
ll modpower(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } 
    return res; 
} 
ll modsum(ll a, ll b, ll m){
 
    return ((a%m)+(b%m))%m;
}
 
ll modmul(ll a, ll b, ll m){
 
    return ((a%m)*(b%m))%m;
}
 
ll modInverse(ll a, ll m) 
{ 
    return modpower(a, m-2, m); 
} 

/*
#define SIZE 200002
vector<long long int> factorial() 
{ 
    int i; 
    vector<long long int> fact(SIZE + 1, 0); 
    fact[0] = 1; 
    for (i = 1; i <= SIZE; i++)
        fact[i] = (fact[i - 1] * i) % B; 
    return fact;
} 
ll highestPowerof2(ll n) 
{ 
   ll p = (ll)log2(n); 
    return (ll)pow(2, p);  
} 
*/
/*
struct node{
    int x;
    int y;
};

int r,c;
string arr[1111];
int dx={1,-1,0,0};
int dy={0,0,-1,1};

void bfs()
{
    deque<int> q;
    q.push_front((node){0,0});
    int dp[r][c];
    rep(i,0,r)
    rep(j,0,c)
    dp[i][j]=111111;

    dp[0][0]=0;
    while(!q.empty())
    {
        node cur=q.front();
        q.pop_front();
    }
}*/
 
ldb power(ldb x, ll y) 
{ 
    ldb temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2); 
    if (y%2 == 0) 
        return temp*temp; 
    else
        return x*temp*temp; 
}

ll modDivide(ll a, ll b, ll m) 
{ 
    a = a % m; 
    ll inv = modInverse(b, m); 
    return (inv*a)%m;
}

int main()
{
    IOS; //seive(); np();
    int t1=1;
    // cin>>t1;
    while(t1--)
    {

        int k;
        cin>>k;
        int n=k%10;
        if(k%2==0)
        {
            cout<<"-1";
            return 0;
        }

        ll val=7;
        ll c=1;
        unordered_map<ll,ll> m;
        m[val]=1;
        while(1)
        {
            if(val%k==0)
            {
                cout<<c;return 0;
            }
            val=(val*10 + 7) % k;
             if(m.count(val)){
            cout<<-1<<endl;
            return 0;
        }
        else {
            m[val] = 1;
        }
        c++;
        }


































    }
  return 0;
}

Measured memory_bytes: 47224