//解説参照済み

function main(input = "") {
    const K = 0 | input;
    let L = 9 * K;
    if (L % 2 === 0) { return -1; }
    if (L % 5 === 0) { return -1; }
    if (L % 7 === 0) { L = 0 | L / 7; }

    let res = 0;
    let mod = 10 % L;
    for(i = 1; i <= L; i++){
        if(mod === 1){
            res = i;
            break;
        }
        mod = mod * 10 % L;
    }
    return res;
}

//******************************
exports.main = main;

function Main(input) {
    console.log(main(input.trim()));
}

if (process.argv[2] !== "test") {
    Main(require("fs").readFileSync("/dev/stdin", "utf8"));
}