local MOD
local function add(a,b)return (a+b)%MOD end
local function sub(a,b)return a>b and a-b or a-b+MOD end
local function mul(a,b)return a*b%MOD end
local function pow(a,b)local ret=1 while(b>0)do if(b%2==1)then ret=mul(ret,a)b=b-1 end a=mul(a,a)b=b*.5 end return ret end
local function inv(x)local a,b,u,v=x,MOD,1,0 repeat local t=math.floor(a/b)a,b=b,a-t*b u,v=v,u-t*v until(b==0)return u%MOD end
local function div(a,b)return mul(a,inv(b))end
K=io.read"*n"

if(K%2==0)then print(-1)return end
MOD=K
a=0
i=0
while(true)do
a=add(a,mul(7,pow(10,i)))
if(a==0)then break end
i=i+1
end
print(i+1)
