k=gets.to_i
if k%2==0 || k%5==0
  puts -1
elsif k%7==0
  for i in 1..10**6
    if (10**i)%(9*k/7)==1
      maru=1
      break
    end
  end
  if maru==1
    puts i
  else
    puts -1
  end

else
  for j in 1..10**6
    if 7*(10**j-1)%(9*k)==0
      maru=1
      break
    end
  end
  if maru==1
    puts i
  else
    puts -1
  end
end
