function Main(arg) {
    const k = arg;

    let x = 7 % k;
    let cnt = 1;
    const s = new Set();

    while(!s.has(x)){
        if(x === 0) {
            console.log(cnt);
            return;
        }
        s.add(x);
        x = (x * 10 +7) % k;
        cnt++;
    }

    console.log('-1');
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
