#include <stdio.h>
int main(){
	int k,cnt,a;
	scanf("%d",&k);
	if(k%2==0||k%10==5) {
		printf("-1\n");
		return 0;
	}
	a=7,cnt=1;
	while(1){
		if(a%k==0)break;
		a%=k,a=a*10+7,cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}