#[allow(unused_imports)]
use proconio::{input, marker::*};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}
use self::modint::ModInt;

mod modint {
    use std;
    #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
    pub struct ModInt {
        pub value: usize,
        module: usize,
    }
    impl ModInt {
        pub fn new(value: usize, module: usize) -> Self {
            ModInt {
                value: value % module,
                module: module,
            }
        }
    }
    impl std::ops::Add for ModInt {
        type Output = Self;
        fn add(self, other: Self) -> Self {
            let mut value = self.value + other.value;
            if value > self.module {
                value -= self.module;
            }
            ModInt::new(value, self.module)
        }
    }
    impl std::ops::Add<usize> for ModInt {
        type Output = Self;
        fn add(self, other: usize) -> Self {
            let mut value = self.value + other;
            if value > self.module {
                value -= self.module;
            }
            ModInt::new(value, self.module)
        }
    }
    impl std::ops::Sub for ModInt {
        type Output = Self;
        fn sub(self, other: Self) -> Self {
            let mut value = self.value;
            if value < other.value {
                value += self.module;
            }
            value -= other.value;
            ModInt::new(value, self.module)
        }
    }
    impl std::ops::Sub<usize> for ModInt {
        type Output = Self;
        fn sub(self, other: usize) -> Self {
            let mut value = self.value;
            if value < other {
                value += self.module;
            }
            value -= other;
            ModInt::new(value, self.module)
        }
    }
    impl std::ops::Mul for ModInt {
        type Output = Self;
        fn mul(self, other: Self) -> Self {
            let value = self.value * other.value % self.module;
            ModInt::new(value, self.module)
        }
    }
    impl std::ops::Mul<usize> for ModInt {
        type Output = Self;
        fn mul(self, other: usize) -> Self {
            let value = self.value * other % self.module;
            ModInt::new(value, self.module)
        }
    }
    impl std::ops::Div for ModInt {
        type Output = Self;
        fn div(self, other: Self) -> Self {
            let mut exp = self.module - 2;
            let mut value = self.value;
            let mut ovalue = other.value;
            while exp > 0 {
                if exp % 2 == 1 {
                    value = value * ovalue % self.module;
                }
                ovalue = ovalue * ovalue % self.module;
                exp /= 2;
            }
            ModInt::new(value, self.module)
        }
    }
    impl std::ops::Div<usize> for ModInt {
        type Output = Self;
        fn div(self, other: usize) -> Self {
            let mut exp = self.module - 2;
            let mut value = self.value;
            let mut ovalue = other;
            while exp > 0 {
                if exp % 2 == 1 {
                    value = value * ovalue % self.module;
                }
                ovalue = ovalue * ovalue % self.module;
                exp /= 2;
            }
            ModInt::new(value, self.module)
        }
    }
    impl std::ops::AddAssign for ModInt {
        fn add_assign(&mut self, other: Self) {
            *self = *self + other;
        }
    }
    impl std::ops::AddAssign<usize> for ModInt {
        fn add_assign(&mut self, other: usize) {
            *self = *self + other;
        }
    }
    impl std::ops::SubAssign for ModInt {
        fn sub_assign(&mut self, other: Self) {
            *self = *self - other;
        }
    }
    impl std::ops::SubAssign<usize> for ModInt {
        fn sub_assign(&mut self, other: usize) {
            *self = *self - other;
        }
    }
    impl std::ops::MulAssign for ModInt {
        fn mul_assign(&mut self, other: Self) {
            *self = *self * other;
        }
    }
    impl std::ops::MulAssign<usize> for ModInt {
        fn mul_assign(&mut self, other: usize) {
            *self = *self * other;
        }
    }
    impl std::ops::DivAssign for ModInt {
        fn div_assign(&mut self, other: Self) {
            *self = *self / other;
        }
    }
    impl std::ops::DivAssign<usize> for ModInt {
        fn div_assign(&mut self, other: usize) {
            *self = *self / other;
        }
    }
    impl std::fmt::Debug for ModInt {
        fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
            write!(f, "{}", self.value)
        }
    }
    impl std::fmt::Display for ModInt {
        fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
            write!(f, "{}", self.value)
        }
    }
}

fn main() {
    input! {
        k: usize,
    }

    if k % 2 == 0 || k % 5 == 0 {
        println!("-1");
        return;
    }
    let mut val = ModInt::new(7, k);
    for i in 0.. {
        if val.value == 0 {
            println!("{}", i + 1);
            return;
        }
        val = val * 10 + 7;
    }
}


Measured memory_bytes: 2088