#include <iostream>

using namespace std;

int main()
{
   long long K, p=0, c=0;
   cin>>K;
   if(K%2==0 ||K%5==0)
        cout<<"-1";
   else
   {
       do{
           p=(p*10+7)%K;
           ++c;
       }while(p);
       cout<<c;
   }
   
   return 0;
}
