process.stdin.resume();
process.stdin.setEncoding('utf-8');
 
let inputString = '';
let currentLine = 0;
 
process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
 
process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    
    main();    
});
 
function readLine() {
    return inputString[currentLine++];
}

function main() {
  let k = Number(readLine())
  if (k % 2 === 0 || k % 5 === 0) {
    return console.log(-1)
  }
  if (k % 7 === 0) {
    k /= 7
  }
  k *= 9
  let mod = 1
  let i = 1
  while (true) {
    mod = (mod * 10) % k
    if (mod === 1) {
      return console.log(i)
    }
    i++
  }
}
