#include<iostream>
#include<math.h>
using namespace std;
int main()
{
	long n=1,k,num = 7;
	cin>>k;
	while(num%k!=0)
	{
		long a = num/k;
		num=num-a*k;		
		num = num*10+7;
		n++;				
		if(n>10000000)
		{
			n=-1;
			break;
		}
	}		
	cout<<n;
}