use proconio::input;

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

    println!("{}", solve(n));
}

fn solve(n: usize) -> usize {
    (1_usize..).find(|&exp| pow_mod(10, exp, n) == 1).unwrap()
}

/// Calculate the remainder of `exp` power of `base` divided by `m`.
pub fn pow_mod(base: usize, exp: usize, m: usize) -> usize {
    let mut ret = 1 % m;
    let mut mul = base % m;
    let mut t = exp;

    while t != 0 {
        if t & 1 == 1 {
            ret = ret * mul % m;
        }

        mul = mul * mul % m;
        t >>= 1;
    }

    ret
}