Main(require("fs").readFileSync("/dev/stdin", "utf8"));

function Main(input) {
  const k = parseInt(input.trim(), 10);
  let x = 7%k;
  const set = new Set();
  let i = 1;
  while(!set.has(x)) {
    if (x === 0) {
      console.log(i);
      return;
    }
    set.add(x);
    x = (x*10+7)%k;
    i++;
  }
  console.log(-1);
  return 0;
}