console.log((args=>{
  const K = args.trim()|0;
  if (~K&1) return '-1';
  let r = 7;
  for ( let i = 1;; i++ ) {
    if ( r%K===0 ) return i;
    r = (r*10+7)%K;
  }
})(require('fs').readFileSync('/dev/stdin', 'utf8')));