program c174

implicit none
integer(16) :: k, i, a, b, m, f

i = 1

read *, k

if (mod(k, 2) == 0) then
 print *, -1
 stop
else if (k == 7) then
 print *, 1
 stop
end if

f = mod(7, k)
a = mod(7, k)

do while(f > 0)
 i = i + 1
 b = a * 10
 a = mod(b, k)
 m =  f + a
 f = mod(m, k)
 !print '(4(I3))', i, a, b, f
 
 if(i > 1919810) then
 print *, -1
 stop
 end if
 
end do

print *, i

end program c174