// ---------- begin ModInt ----------
mod modint {

    #[allow(dead_code)]
    pub struct Mod;
    impl ConstantModulo for Mod {
        const MOD: u32 = 1_000_000_007;
    }

    #[allow(dead_code)]
    pub struct StaticMod;
    static mut STATIC_MOD: u32 = 0;
    impl Modulo for StaticMod {
        fn modulo() -> u32 {
            unsafe { STATIC_MOD }
        }
    }

    #[allow(dead_code)]
    impl StaticMod {
        pub fn set_modulo(p: u32) {
            unsafe {
                STATIC_MOD = p;
            }
        }
    }

    use std::marker::*;
    use std::ops::*;

    pub trait Modulo {
        fn modulo() -> u32;
    }

    pub trait ConstantModulo {
        const MOD: u32;
    }

    impl<T> Modulo for T
    where
        T: ConstantModulo,
    {
        fn modulo() -> u32 {
            T::MOD
        }
    }

    pub struct ModInt<T>(pub u32, PhantomData<T>);

    impl<T> Clone for ModInt<T> {
        fn clone(&self) -> Self {
            ModInt::new_unchecked(self.0)
        }
    }

    impl<T> Copy for ModInt<T> {}

    impl<T: Modulo> Add for ModInt<T> {
        type Output = ModInt<T>;
        fn add(self, rhs: Self) -> Self::Output {
            let mut d = self.0 + rhs.0;
            if d >= T::modulo() {
                d -= T::modulo();
            }
            ModInt::new_unchecked(d)
        }
    }

    impl<T: Modulo> AddAssign for ModInt<T> {
        fn add_assign(&mut self, rhs: Self) {
            *self = *self + rhs;
        }
    }

    impl<T: Modulo> Sub for ModInt<T> {
        type Output = ModInt<T>;
        fn sub(self, rhs: Self) -> Self::Output {
            let mut d = T::modulo() + self.0 - rhs.0;
            if d >= T::modulo() {
                d -= T::modulo();
            }
            ModInt::new_unchecked(d)
        }
    }

    impl<T: Modulo> SubAssign for ModInt<T> {
        fn sub_assign(&mut self, rhs: Self) {
            *self = *self - rhs;
        }
    }

    impl<T: Modulo> Mul for ModInt<T> {
        type Output = ModInt<T>;
        fn mul(self, rhs: Self) -> Self::Output {
            let v = self.0 as u64 * rhs.0 as u64 % T::modulo() as u64;
            ModInt::new_unchecked(v as u32)
        }
    }

    impl<T: Modulo> MulAssign for ModInt<T> {
        fn mul_assign(&mut self, rhs: Self) {
            *self = *self * rhs;
        }
    }

    impl<T: Modulo> Neg for ModInt<T> {
        type Output = ModInt<T>;
        fn neg(self) -> Self::Output {
            if self.0 == 0 {
                Self::zero()
            } else {
                Self::new_unchecked(T::modulo() - self.0)
            }
        }
    }

    impl<T> std::fmt::Display for ModInt<T> {
        fn fmt<'a>(&self, f: &mut std::fmt::Formatter<'a>) -> std::fmt::Result {
            write!(f, "{}", self.0)
        }
    }

    impl<T: Modulo> std::str::FromStr for ModInt<T> {
        type Err = std::num::ParseIntError;
        fn from_str(s: &str) -> Result<Self, Self::Err> {
            let val = s.parse::<u32>()?;
            Ok(ModInt::new(val))
        }
    }

    impl<T: Modulo> From<usize> for ModInt<T> {
        fn from(val: usize) -> ModInt<T> {
            ModInt::new_unchecked((val % T::modulo() as usize) as u32)
        }
    }

    impl<T: Modulo> From<u64> for ModInt<T> {
        fn from(val: u64) -> ModInt<T> {
            ModInt::new_unchecked((val % T::modulo() as u64) as u32)
        }
    }

    impl<T: Modulo> From<i64> for ModInt<T> {
        fn from(val: i64) -> ModInt<T> {
            let m = T::modulo() as i64;
            ModInt::new((val % m + m) as u32)
        }
    }

    #[allow(dead_code)]
    impl<T> ModInt<T> {
        pub fn new_unchecked(d: u32) -> Self {
            ModInt(d, PhantomData)
        }
        pub fn zero() -> Self {
            ModInt::new_unchecked(0)
        }
        pub fn one() -> Self {
            ModInt::new_unchecked(1)
        }
        pub fn is_zero(&self) -> bool {
            self.0 == 0
        }
    }

    #[allow(dead_code)]
    impl<T: Modulo> ModInt<T> {
        pub fn new(d: u32) -> Self {
            ModInt::new_unchecked(d % T::modulo())
        }
        pub fn pow(&self, mut n: u64) -> Self {
            let mut t = Self::one();
            let mut s = *self;
            while n > 0 {
                if n & 1 == 1 {
                    t *= s;
                }
                s *= s;
                n >>= 1;
            }
            t
        }
        pub fn inv(&self) -> Self {
            assert!(self.0 != 0);
            self.pow(T::modulo() as u64 - 2)
        }
    }

    #[allow(dead_code)]
    pub fn mod_pow(r: u64, mut n: u64, m: u64) -> u64 {
        let mut t = 1 % m;
        let mut s = r % m;
        while n > 0 {
            if n & 1 == 1 {
                t = t * s % m;
            }
            s = s * s % m;
            n >>= 1;
        }
        t
    }
}
// ---------- end ModInt ----------
// ---------- begin Precalc ----------
mod precalc {
    use super::modint::*;
    #[allow(dead_code)]
    pub struct Precalc<T> {
        inv: Vec<ModInt<T>>,
        fact: Vec<ModInt<T>>,
        ifact: Vec<ModInt<T>>,
    }
    #[allow(dead_code)]
    impl<T: Modulo> Precalc<T> {
        pub fn new(n: usize) -> Precalc<T> {
            let mut inv = vec![ModInt::one(); n + 1];
            let mut fact = vec![ModInt::one(); n + 1];
            let mut ifact = vec![ModInt::one(); n + 1];
            for i in 2..(n + 1) {
                fact[i] = fact[i - 1] * ModInt::new_unchecked(i as u32);
            }
            ifact[n] = fact[n].inv();
            if n > 0 {
                inv[n] = ifact[n] * fact[n - 1];
            }
            for i in (1..n).rev() {
                ifact[i] = ifact[i + 1] * ModInt::new_unchecked((i + 1) as u32);
                inv[i] = ifact[i] * fact[i - 1];
            }
            Precalc {
                inv: inv,
                fact: fact,
                ifact: ifact,
            }
        }
        pub fn inv(&self, n: usize) -> ModInt<T> {
            assert!(n > 0);
            self.inv[n]
        }
        pub fn fact(&self, n: usize) -> ModInt<T> {
            self.fact[n]
        }
        pub fn ifact(&self, n: usize) -> ModInt<T> {
            self.ifact[n]
        }
        pub fn perm(&self, n: usize, k: usize) -> ModInt<T> {
            if k > n {
                return ModInt::zero();
            }
            self.fact[n] * self.ifact[n - k]
        }
        pub fn comb(&self, n: usize, k: usize) -> ModInt<T> {
            if k > n {
                return ModInt::zero();
            }
            self.fact[n] * self.ifact[k] * self.ifact[n - k]
        }
    }
}
// ---------- end Precalc ----------
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, bytes) => {
        read_value!($iter, String).bytes().collect::<Vec<u8>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

use std::io::Write;

use modint::*;
use precalc::*;

type M = ModInt<Mod>;

fn run() {
    input! {
        n: usize,
    }
    let pc = Precalc::new(n);
    let ans: M = pc.fact(n) - ModInt::new(2).pow((n - 1) as u64);
    println!("{}", ans);
}

fn main() {
    run();
}


use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::str::*;

// scanner from https://codeforces.com/contest/1396/submission/91365784
struct Scanner {
    stdin: Stdin,
    buffer: VecDeque<String>,
}
#[allow(dead_code)]
impl Scanner {
    fn new() -> Self {
        Scanner {
            stdin: stdin(),
            buffer: VecDeque::new(),
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.is_empty() {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.cin::<String>().chars().collect()
    }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.cin()).collect()
    }
    fn u(&mut self) -> usize {
        self.cin()
    }
    fn vecu(&mut self, n: usize) -> Vec<usize> {
        self.vec(n)
    }
}

//
// ModInt
//

const M: i64 = 1000_000_007;
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
struct ModInt {
    val: i64,
}
#[allow(dead_code)]
const M0: ModInt = ModInt { val: 0 };
const M1: ModInt = ModInt { val: 1 };
//const M_ERROR: ModInt = ModInt { val: -1 };

impl ModInt {
    fn new(v: i64) -> ModInt {
        ModInt {
            val: ModInt::val_from_i64(v),
        }
    }
    #[allow(dead_code)]
    fn new_raw(v: i64) -> ModInt {
        ModInt { val: v }
    }
    fn val_from_i64(v: i64) -> i64 {
        let t = v % M;
        if t < 0 {
            t + M
        } else {
            t
        }
    }
    fn val_from_addval(t: i64) -> i64 {
        if t >= M {
            t - M
        } else {
            t
        }
    }

    fn pow(self, exp: i64) -> ModInt {
        if exp == 0 {
            M1
        } else {
            let x = self.pow(exp / 2);
            if exp % 2 == 0 {
                x * x
            } else {
                self * x * x
            }
        }
    }

    fn inv(self) -> ModInt {
        self.pow(M - 2)
    }
}

impl std::ops::Add for ModInt {
    type Output = ModInt;
    fn add(self, rhs: ModInt) -> ModInt {
        ModInt {
            val: ModInt::val_from_addval(self.val + rhs.val),
        }
    }
}
impl std::ops::Add<i64> for ModInt {
    type Output = ModInt;
    fn add(self, rhs: i64) -> ModInt {
        ModInt {
            val: ModInt::val_from_i64(self.val + rhs),
        }
    }
}
impl std::ops::AddAssign for ModInt {
    fn add_assign(&mut self, other: ModInt) {
        self.val = ModInt::val_from_addval(self.val + other.val);
    }
}
impl std::ops::AddAssign<i64> for ModInt {
    fn add_assign(&mut self, other: i64) {
        self.val = ModInt::val_from_i64(self.val + other);
    }
}

impl std::ops::Sub for ModInt {
    type Output = ModInt;
    fn sub(self, rhs: ModInt) -> ModInt {
        ModInt {
            val: ModInt::val_from_addval(self.val - rhs.val + M),
        }
    }
}
impl std::ops::Sub<i64> for ModInt {
    type Output = ModInt;
    fn sub(self, rhs: i64) -> ModInt {
        self - ModInt::new(rhs)
    }
}
impl std::ops::SubAssign for ModInt {
    fn sub_assign(&mut self, other: ModInt) {
        self.val = ModInt::val_from_addval(self.val - other.val + M);
    }
}
impl std::ops::SubAssign<i64> for ModInt {
    fn sub_assign(&mut self, other: i64) {
        self.val = ModInt::val_from_i64(self.val - other);
    }
}

impl std::ops::Neg for ModInt {
    type Output = ModInt;
    fn neg(self) -> ModInt {
        ModInt {
            val: if self.val == 0 { 0 } else { M - self.val },
        }
    }
}

impl std::ops::Mul for ModInt {
    type Output = ModInt;
    fn mul(self, rhs: ModInt) -> ModInt {
        ModInt {
            val: self.val * rhs.val % M,
        }
    }
}
impl std::ops::Mul<i64> for ModInt {
    type Output = ModInt;
    fn mul(self, rhs: i64) -> ModInt {
        self * ModInt::new(rhs)
    }
}
impl std::ops::MulAssign for ModInt {
    fn mul_assign(&mut self, other: ModInt) {
        self.val = self.val * other.val % M;
    }
}
impl std::ops::MulAssign<i64> for ModInt {
    fn mul_assign(&mut self, other: i64) {
        self.mul_assign(ModInt::new(other));
    }
}

impl std::ops::Div for ModInt {
    type Output = ModInt;
    fn div(self, rhs: ModInt) -> ModInt {
        self * rhs.inv()
    }
}
impl std::ops::Div<i64> for ModInt {
    type Output = ModInt;
    fn div(self, rhs: i64) -> ModInt {
        self / ModInt::new(rhs)
    }
}

impl std::fmt::Display for ModInt {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        // '
        write!(f, "{}", self.val)
    }
}

//
// nCr
//
#[derive(Debug, Clone)]
struct Comb {
    fac: Vec<ModInt>,
    finv: Vec<ModInt>,
    inv: Vec<ModInt>,
}

impl Comb {
    fn new(size: usize) -> Comb {
        let mut fac = vec![M1; size];
        let mut finv = vec![M1; size];
        let mut inv = vec![M1; size];

        for i in 2..size {
            fac[i] = fac[i - 1] * (i as i64);
            inv[i] = -inv[M as usize % i] * (M / (i as i64));
            finv[i] = finv[i - 1] * inv[i];
        }

        return Comb {
            fac: fac,
            finv: finv,
            inv: inv,
        };
    }
}
trait CombC<T> {
    fn c(&self, n: T, k: T) -> ModInt;
    fn p(&self, n: T, k: T) -> ModInt;
}

impl CombC<usize> for Comb {
    fn c(&self, n: usize, k: usize) -> ModInt {
        if n < k {
            M0
        } else {
            self.fac[n] * self.finv[k] * self.finv[n - k]
        }
    }
    fn p(&self, n: usize, k: usize) -> ModInt {
        if n < k {
            M0
        } else {
            self.fac[n] * self.finv[n - k]
        }
    }
}

impl CombC<i64> for Comb {
    fn c(&self, n: i64, k: i64) -> ModInt {
        if n < 0 || k < 0 || n < k {
            M0
        } else {
            self.c(n as usize, k as usize)
        }
    }
    fn p(&self, n: i64, k: i64) -> ModInt {
        if n < 0 || k < 0 || n < k {
            M0
        } else {
            self.p(n as usize, k as usize)
        }
    }
}

#[derive(Clone, Debug, Default)]
struct Solver {}

impl Solver {
    fn solve(&mut self, scan: &mut Scanner, out: &mut BufWriter<Stdout>) {
        // 1391c
        let n = scan.u();

        /*
            cyclicでない == pに谷が無い、つまり p[j]==nならp[0..=j]は増加、p[j..n]は減少
        */
        let comb = Comb::new(n + 1);
        let mut ans = M0;
        for j in 0..n {
            ans += comb.c(n - 1, j);
        }

        writeln!(out, "{}", comb.p(n, n) - ans).ok();
    }
}

fn solve() {
    let mut scan = Scanner::new();
    let out = &mut BufWriter::new(stdout());

    let testcase = 1;
    //let testcase: usize = scan.cin();
    for _ in 0..testcase {
        let mut s: Solver = Default::default();
        s.solve(&mut scan, out);
    }
}

fn main() {
    let th = std::thread::Builder::new().stack_size(64 * 1024 * 1024);
    th.spawn(|| solve()).unwrap().join().unwrap()
}


use std::io;

fn mpow(mut base: u32, mut ex: u32, p: u32) -> u32 {
    let mut ans = 1u32;
    while ex != 0 {
        if ex & 1u32 != 0 {
            ans = (ans as u64 * base as u64 % p as u64) as u32;
        }
        base = (base as u64 * base as u64 % p as u64) as u32;
        ex >>= 1;
    }
    return ans;
}

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    let n: u32 = input.trim().parse().unwrap();
    let p = 1000000007u32;
    let pow = mpow(2u32, n - 1, p);
//     println!("{}", pow);
    let mut fact = 1u32;
    for i in 2..(n+1) {
        fact = (fact as u64 * i as u64 % p as u64) as u32;
    }
//     println!("{}", fact);
    let ans;
    if fact < pow {
        ans = fact + p - pow;
    } else {
        ans = fact - pow;
    }
    println!("{}", ans);
}


fn main() {
    let keyb = "qwertyuiopasdfghjkl;zxcvbnm,./";
    let mut r = String::new();
    let mut inp = String::new();
    std::io::stdin()
        .read_line(&mut r)
        .expect("failed reading from stdin");
    std::io::stdin()
        .read_line(&mut inp)
        .expect("failed reading from stdin");
    let keys = inp.trim().chars();
    for i in keys {
        if r.trim() == "R" {
            let idx = keyb.find(i).unwrap() - 1;
            print!("{}", keyb.chars().nth(idx).unwrap())
        } else {
            let idx = keyb.find(i).unwrap() + 1;
            print!("{}", keyb.chars().nth(idx).unwrap())
        }
    }
}


#[allow(unused_imports)]
use std::cmp::{max,min};

#[allow(unused_macros)]
macro_rules! readln {
    () => {{
        use std::io;

        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        buf.trim().to_string()
    }};
    ( $t:ty ) => {{
        let input = readln!();
        input.parse::<$t>().unwrap()
    }};
    ( $( $t:ty ),+ ) => {{
        let input = readln!();
        let mut input = input.split_whitespace();
        (
            $(
                input.next().unwrap().parse::<$t>().unwrap(),
            )+
        )
    }}
}

#[allow(unused_macros)]
macro_rules! readvec {
    ( $t:ty ) => {{
        let input = readln!();
        let mut input = input.split_whitespace();
        let mut result = Vec::new();
        for elem in input {
            result.push(elem.parse::<$t>().unwrap());
        }
        result
    }}
}

fn main() {
    let a = [
        "qwertyuiop",
        "asdfghjkl;",
        "zxcvbnm,./",
    ];
    let b = readln!();
    let c = readln!();
    let d :i32= if b == "R" { -1 } else { 1 };
    let mut res = String::new();
    for x in c.chars() {
        for s in &a {
            if let Some(i) = s.find(x) {
                res.push(s.as_bytes()[(i as i32+d) as usize] as char);
            } else {
                continue;
            }
        }
    }
    println!("{}",res);
}


//spnauti-rust
#[allow(unused_macros)]
macro_rules! a {
    ($c: tt, $x: expr, $y: expr) => {{
        let b = $y; let a = &mut $x;
        if b $c *a { *a = b; true } else { false }
    }};
}
use std::str::*;
use std::fmt::Debug;
struct WordReader<'a> { it : SplitAsciiWhitespace<'a>, }
#[allow(dead_code)]
impl<'a> WordReader<'a> {
    fn new<T: std::io::Read>(b: &mut String, mut r: T) -> WordReader {
        b.clear();
        r.read_to_string(b).unwrap();
        WordReader { it: b.split_ascii_whitespace() }
    }
    fn from_stdin(b: &mut String) -> WordReader {
        WordReader::new(b, std::io::stdin())
    }
    fn sl(&mut self) ->  &str { self.it.next().unwrap() }
    fn bs(&mut self) -> &[u8] { self.sl().as_bytes()    }
    fn s(&mut self) -> String { String::from(self.sl()) }
    fn i(&mut self) ->    i32 { self.p()                }
    fn p<T: FromStr>(&mut self) -> T where T::Err: Debug {
        self.sl().parse::<T>().unwrap()
    }
    fn vp<T: FromStr>(&mut self, n: usize) -> Vec<T> where T::Err: Debug {
        (0..n).map(|_| self.p()).collect()
    }
}

fn main() {
    let mut buffer = String::new();
    let mut input = WordReader::from_stdin(&mut buffer);

    use std::collections::HashMap;
    const K: &[u8] = b"qwertyuiopasdfghjkl;zxcvbnm,./";
    let ml = K.iter().zip(K.iter().skip(1)).collect::<HashMap<_,_>>();
    let mr = K.iter().skip(1).zip(K.iter()).collect::<HashMap<_,_>>();
    let c = input.bs()[0];
    let s = input.bs();
    let m = if c == b'L' { ml } else { mr };
    for x in s {
        print!("{}", *(m[x]) as char);
    }
}


type Keyboard = [[char; 10]; 3];

fn raw_input() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_string()
}

fn find(row: &[char; 10], letter: char) -> Result<usize, ()> {
    for i in 0..row.len() {
        if row[i] == letter {
            return Ok(i);
        }
    }
    Err(())
}

fn shift_message(message: &String, kb: &Keyboard, dir: isize) -> String {
    let mut new_message = String::with_capacity(message.len());
    for letter in message.chars() {
        for row in kb.iter() {
            if let Ok(index) = find(row, letter) {
                new_message.push(row[(index as isize + dir) as usize]);
                break;
            }
        }
    }
    new_message
}

fn main() {
    let dir = raw_input();
    let mut message = raw_input();
    let keyboard = [
        ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p'],
        ['a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';'],
        ['z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/'],
    ];

    match &dir[..] {
        "L" => message = shift_message(&message, &keyboard, 1),
        "R" => message = shift_message(&message, &keyboard, -1),
        _ => unreachable!(),
    }

    println!("{}", message);
}


// {{{ by shik

use std::io;

#[allow(dead_code)]
fn gets() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(unused_macros)]
macro_rules! R {
    ( $ty:ty, ... ) => {
        gets().split_whitespace().map(|x| x.parse::<$ty>().unwrap()).collect::<Vec<_>>()
    };
    ( $($ty:ty),* ) => {{
        let line = gets();
        let mut it = line.split_whitespace();
        ( $(it.next().unwrap().parse::<$ty>().unwrap(),)* )
    }}
}

#[allow(unused_macros)]
macro_rules! W {
    ( $x:expr ) => {{
        println!("{}", $x);
    }};
    ( $x:expr, $($xs:expr),* ) => {{
        print!("{} ", $x);
        W!($($xs),*);
    }}
}

#[allow(unused_macros)]
macro_rules! join {
    ($x:expr, $($xs:expr),*; $sep:expr) => { concat!($x, $($sep, $xs),*) }
}

#[allow(unused_macros)]
macro_rules! dump {
    ($($x:expr),*) => {
        eprintln!(join!($(concat!(stringify!($x), " = {:?}")),*; ", "), $($x),*);
    }
}

// }}}

fn main() {
    let s = "qwertyuiopasdfghjkl;zxcvbnm,./";
    let sft = if R!(String).0 == "R" { -1i32 } else { 1i32 };
    let ans: String = R!(String).0.chars().map(|c| (s.find(c).unwrap() as i32 + sft) as usize).map(|i| s.get(i..i+1).unwrap()).collect();
    W!(ans);
}


struct Scan {
    buffer: std::collections::VecDeque<String>
}

impl Scan {
    fn new() -> Scan {
        Scan { buffer: std::collections::VecDeque::new() }
    }

    fn next<T: std::str::FromStr>(&mut self)-> T {
        loop {
            if let Some(token) = self.buffer.pop_front() {
                break token.parse::<T>().ok().unwrap();
            }
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).expect("Fail to read");
            self.buffer = line.split_whitespace().map(String::from).collect();
        }
    }

    fn next_n<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.next::<T>()).collect()
    }

}

fn _main() {
    let mut scan = Scan::new();
    let keyboard: Vec<char> = "qwertyuiopasdfghjkl;zxcvbnm,./".chars()
        .collect();
    let dir: char = scan.next();
    let input: String = scan.next::<String>();
    let offset: isize = if dir == 'R' { -1 } else { 1 };
    for c in input.chars() {
        let mut index = keyboard.iter().position(|&x| x==c).unwrap();
        print!("{}", keyboard[(index as isize + offset) as usize]);
    }

}

fn main() {
    std::thread::Builder::new()
        .stack_size(1<<23).spawn(_main).unwrap().join().unwrap();
}


#![allow(dead_code, unused_imports, unused_macros)]

use std::fmt::Debug;
use std::str::FromStr;

fn read_stdin() -> String {
    let mut s = String::new();
    std::io::stdin()
        .read_line(&mut s)
        .expect("cannot read stdin");
    s.trim().to_string()
}

fn read<T>() -> T
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    read_stdin().parse::<T>().unwrap()
}

fn read_usize() -> usize {
    read::<usize>()
}

fn read_2<A, B>() -> (A, B)
where
    A: FromStr,
    <A as FromStr>::Err: Debug,
    B: FromStr,
    <B as FromStr>::Err: Debug,
{
    let s = read_stdin();
    let mut s = s.split_whitespace();
    let a = s.next().unwrap().parse::<A>().unwrap();
    let b = s.next().unwrap().parse::<B>().unwrap();
    (a, b)
}

fn read_3<A, B, C>() -> (A, B, C)
where
    A: FromStr,
    <A as FromStr>::Err: Debug,
    B: FromStr,
    <B as FromStr>::Err: Debug,
    C: FromStr,
    <C as FromStr>::Err: Debug,
{
    let s = read_stdin();
    let mut s = s.split_whitespace();
    let a = s.next().unwrap().parse::<A>().unwrap();
    let b = s.next().unwrap().parse::<B>().unwrap();
    let c = s.next().unwrap().parse::<C>().unwrap();
    (a, b, c)
}

fn read_4<A, B, C, D>() -> (A, B, C, D)
where
    A: FromStr,
    <A as FromStr>::Err: Debug,
    B: FromStr,
    <B as FromStr>::Err: Debug,
    C: FromStr,
    <C as FromStr>::Err: Debug,
    D: FromStr,
    <D as FromStr>::Err: Debug,
{
    let s = read_stdin();
    let mut s = s.split_whitespace();
    let a = s.next().unwrap().parse::<A>().unwrap();
    let b = s.next().unwrap().parse::<B>().unwrap();
    let c = s.next().unwrap().parse::<C>().unwrap();
    let d = s.next().unwrap().parse::<D>().unwrap();
    (a, b, c, d)
}

fn read_multiple<T: FromStr>() -> Vec<T>
where
    <T as FromStr>::Err: Debug,
{
    read_stdin()
        .split_whitespace()
        .map(|x| x.parse::<T>().expect("cannot parse stdin"))
        .collect()
}

/// NOTE: sort iter beforehand if required
fn count<T>(iter: &mut impl Iterator<Item = T>) -> Vec<(T, usize)>
where
    T: std::cmp::Ord,
{
    let iter = iter.collect::<Vec<_>>();
    //iter.sort();
    let (mut v, o, c) =
        iter.into_iter()
            .fold((Vec::new(), None, 0), |(mut v, last, count), item| {
                if let Some(o) = last {
                    if item == o {
                        (v, Some(o), count + 1)
                    } else {
                        v.push((o, count));
                        (v, Some(item), 1)
                    }
                } else {
                    (v, Some(item), 1)
                }
            });
    if let Some(i) = o {
        v.push((i, c));
    }
    v
}

fn partial_sum<T>(v: impl Iterator<Item = T>) -> impl Iterator<Item = T>
where
    T: Default + std::ops::Add<Output = T> + Copy,
{
    v.scan(T::default(), |state, x| {
        *state = *state + x;
        Some(*state)
    })
}

fn partial_max<T>(v: impl Iterator<Item = T>) -> impl Iterator<Item = T>
where
    T: Default + Ord + Copy,
{
    v.scan(T::default(), |state, x| {
        *state = max(*state, x);
        Some(*state)
    })
}

fn partial_min(v: impl Iterator<Item = u64>) -> impl Iterator<Item = u64> {
    v.scan(std::u64::MAX, |state, x| {
        *state = min(*state, x);
        Some(*state)
    })
}

fn max_subarray(v: impl Iterator<Item = i64>) -> (i64, (usize, usize)) {
    //assert!(v.len() > 0);
    let mut best_sum = 0;
    let (mut best_start, mut best_end) = (0, 0);
    let mut current_sum = 0;
    let mut current_start = 0;
    for (end, val) in v.enumerate() {
        if current_sum <= 0 {
            current_start = end;
            current_sum = val;
        } else {
            current_sum += val;
        }
        if current_sum > best_sum {
            best_sum = current_sum;
            best_start = current_start;
            best_end = end + 1;
        }
    }
    (best_sum, (best_start, best_end))
}

fn gcd(mut a: u64, mut b: u64) -> u64 {
    while a != 0 {
        let old_m = a;
        a = b % a;
        b = old_m;
    }
    b
}

/// returns gcd, and pair (x, y), such that x * a + b * y == gcd
fn egcd(a: i64, b: i64) -> (i64, i64, i64) {
    if a == 0 {
        (b, 0, 1)
    } else {
        let (g, x, y) = egcd(b % a, a);
        (g, y - (b / a) * x, x)
    }
}

fn factorize(mut n: u64) -> Vec<u64> {
    if n <= 3 {
        return vec![n];
    }
    let mut v = Vec::new();
    while n % 2 == 0 {
        n /= 2;
        v.push(2);
    }
    while n % 3 == 0 {
        n /= 3;
        v.push(3);
    }
    let mut f = 6;
    while (f - 1) * (f - 1) <= n {
        while n % (f - 1) == 0 {
            n /= f - 1;
            v.push(f - 1);
        }
        while n % (f + 1) == 0 {
            n /= f + 1;
            v.push(f + 1);
        }
        f += 6;
    }
    if n > 1 {
        v.push(n);
    }
    v
}

fn compact_factors(n: u64) -> Vec<(u64, usize)> {
    count(&mut factorize(n).into_iter())
}

fn all_factors(n: u64) -> Vec<u64> {
    if n == 0 {
        return vec![0];
    } else if n == 1 {
        return vec![1];
    }
    let factors = compact_factors(n);
    let mut v = vec![1];
    for (fac, num) in factors {
        let ori = v.clone();
        for i in 1..num + 1 {
            v.append(
                &mut ori
                    .clone()
                    .into_iter()
                    .map(|f| f * fac.pow(i as u32))
                    .collect::<Vec<_>>(),
            )
        }
    }
    v.sort();
    v
}

fn abs_diff<T>(a: T, b: T) -> T
where
    T: PartialOrd + std::ops::Sub<Output = T>,
{
    if a > b {
        a - b
    } else {
        b - a
    }
}

struct Permutations<T> {
    inner: Vec<T>,
    state: Vec<usize>,
    i: usize,
    start: bool,
}

impl<T> Permutations<T> {
    fn new(inner: Vec<T>) -> Self {
        Self {
            state: vec![0; inner.len()],
            i: 0,
            start: true,
            inner,
        }
    }
}

/*impl<T, X> From<X> for Permutations<T>
where
    X: IntoIterator<Item = T>,
{
    fn from(f: X) -> Self {
        Self::new(f.into_iter().collect::<Vec<T>>())
    }
}*/

impl<T> Iterator for Permutations<T>
where
    T: Clone,
{
    type Item = Vec<T>;
    fn next(&mut self) -> Option<Self::Item> {
        if self.start {
            self.start = false;
            return Some(self.inner.clone());
        }
        while self.i < self.inner.len() {
            if self.state[self.i] < self.i {
                if self.i % 2 == 0 {
                    self.inner.swap(0, self.i)
                } else {
                    self.inner.swap(self.state[self.i], self.i)
                }
                self.state[self.i] += 1;
                self.i = 0;
                return Some(self.inner.clone());
            } else {
                self.state[self.i] = 0;
                self.i += 1;
            }
        }
        None
    }
}

use std::cmp::{max, min, Ord, Ordering};
use std::collections::{BinaryHeap, VecDeque};
use std::mem::swap;

#[derive(Clone)]
struct Graph {
    nodes: usize,
    edges: Vec<Vec<(usize, u64)>>,
}

impl Graph {
    fn new(n: usize) -> Self {
        Self {
            nodes: n,
            edges: vec![Vec::new(); n + 1],
        }
    }

    fn add_edge(&mut self, x: usize, y: usize, cost: u64) {
        self.edges[x].push((y, cost));
        self.edges[y].push((x, cost));
    }

    fn dijkstra(&mut self, start: usize, end: usize) -> u64 {
        let mut dist = vec![None; self.nodes + 1];
        let mut prev = vec![None; self.nodes + 1];
        dist[start] = Some(0);
        let mut queue = (1..=self.nodes).collect::<Vec<_>>();
        queue.sort_unstable_by_key(|node| dist[*node].unwrap_or(std::u64::MAX));
        queue.reverse();
        while let Some(next_node) = queue.pop() {
            if next_node == end {
                return dist[next_node].unwrap();
            }
            for (neighbour, cost) in self.edges[next_node].iter() {
                let alt = dist[next_node].unwrap() + cost;
                if dist[*neighbour].is_none() {
                    dist[*neighbour] = Some(alt);
                    prev[*neighbour] = Some(next_node);
                } else {
                    if alt < dist[*neighbour].unwrap() {
                        dist[*neighbour] = Some(alt);
                        prev[*neighbour] = Some(next_node);
                    }
                }
            }
            //println!("{:?} {:?}", dist, prev);
            queue.sort_unstable_by_key(|node| dist[*node].unwrap_or(std::u64::MAX));
            queue.reverse();
        }
        0
    }

    fn set_cost(&mut self, x: usize, y: usize, cost: u64) {
        for i in 0..self.edges[x].len() {
            if self.edges[x][i].0 == y {
                self.edges[x][i].1 = cost
            }
        }
        for i in 0..self.edges[y].len() {
            if self.edges[y][i].0 == x {
                self.edges[y][i].1 = cost
            }
        }
    }
}

const MODULO: u64 = 1_000_000_007;

#[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
struct BigPrimeRing {
    inner: u64,
}

impl<T> From<T> for BigPrimeRing
where
    T: Into<u64>,
{
    fn from(n: T) -> Self {
        Self {
            inner: n.into() % MODULO,
        }
    }
}

impl<T> std::ops::Add<T> for BigPrimeRing
where
    T: Into<Self>,
{
    type Output = BigPrimeRing;
    fn add(self, rhs: T) -> Self::Output {
        Self {
            inner: (self.inner + rhs.into().inner) % MODULO,
        }
    }
}

impl<T> std::ops::AddAssign<T> for BigPrimeRing
where
    T: Into<Self>,
{
    fn add_assign(&mut self, rhs: T) {
        self.inner += rhs.into().inner;
        self.inner %= MODULO;
    }
}

impl<T> std::ops::Sub<T> for BigPrimeRing
where
    T: Into<Self>,
{
    type Output = BigPrimeRing;
    fn sub(self, rhs: T) -> Self::Output {
        Self {
            inner: (self.inner + MODULO - rhs.into().inner) % MODULO,
        }
    }
}

impl<T> std::ops::SubAssign<T> for BigPrimeRing
where
    T: Into<Self>,
{
    fn sub_assign(&mut self, rhs: T) {
        self.inner += MODULO;
        self.inner -= rhs.into().inner;
        self.inner %= MODULO;
    }
}

impl<T> std::ops::Mul<T> for BigPrimeRing
where
    T: Into<Self>,
{
    type Output = BigPrimeRing;
    fn mul(self, rhs: T) -> Self::Output {
        Self {
            inner: (self.inner * rhs.into().inner) % MODULO,
        }
    }
}

impl<T> std::ops::MulAssign<T> for BigPrimeRing
where
    T: Into<Self>,
{
    fn mul_assign(&mut self, rhs: T) {
        self.inner *= rhs.into().inner;
        self.inner %= MODULO;
    }
}

impl BigPrimeRing {
    fn inverse(self) -> Self {
        if self.inner == 0 {
            return self;
        }
        let (_g, mut x, _y) = egcd(self.inner as i64, MODULO as i64);
        if x < 0 {
            x += MODULO as i64;
        }
        Self { inner: x as u64 }
    }
}

macro_rules! max_with {
    ($x: expr, $y: expr) => {
        $x = max($x, $y)
    };
}

macro_rules! min_with {
    ($x: expr, $y: expr) => {
        $x = max($x, $y)
    };
}

fn is_prime(n: u64) -> bool {
    factorize(n).len() == 1
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let n = read::<u64>();
    let sum = n * (n + 1) / 2;
    println!("{}", sum % 2);
    Ok(())
}


#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_labels)]

use std::char::*;
use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::str::FromStr;

macro_rules! debug {($($a:expr),*) => {eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::f64;

fn min<T: PartialOrd>(a:T, b:T) -> T {
    if a < b { a }
    else { b }
}

fn max<T: PartialOrd>(a:T, b:T) -> T {
    if a < b { b }
    else { a }
}

const MAX:usize = 30;
const INF:i64 = std::i64::MAX;
const MOD:i64 = 1e9 as i64 + 7;

fn divisor(n:i64) -> Vec<i64> {
    let mut res = Vec::new();
    let mut i = 1;
    while i*i <= n {
        if n%i == 0 {
            res.push(i);
            if i != n/i { res.push(n/i); }
        }
        i += 1;
    }
    res.sort();
    res
}

fn main() {
    //let t:usize = read();

    //'outer: for _ in 0..t {
        let n:i64 = read();
        let sum = n*(n+1)/2;
        println!("{}", sum%2);
    //}
}

/*

*/


use std::io;

fn main() {
    let n: u64 = {
        let mut read_buf = String::new();
        io::stdin().read_line(&mut read_buf).unwrap();
        read_buf.trim().parse().unwrap()
    };
    if n % 4 == 0 {
        println!("0");
    } else if n % 4 == 1 {
        println!("1");
    } else if n % 4 == 2 {
        println!("1");
    } else if n % 4 == 3 {
        println!("0");
    }
}


fn main() {
    let mut input = IO::new();
    let n: u32 = input.read();
    let ans = match n % 4 {
        1 | 2 => 1,
        _ => 0,
    };
    println!("{}", ans);
}

struct IO {
    tokens: Vec<String>,
}

impl IO {
    fn new() -> IO {
        IO { tokens: Vec::new() }
    }

    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.read_token().parse::<T>().ok().unwrap()
    }

    fn read_token(&mut self) -> String {
        if self.tokens.is_empty() {
            self.tokens = self
                .read_line()
                .split_whitespace()
                .map(|x| x.to_string())
                .collect();
            self.tokens.reverse();
        }
        self.tokens.pop().unwrap()
    }

    fn read_line(&mut self) -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).expect("die");
        s.trim_right().to_string()
    }
}


//spnauti-rust
use std::io::*;
use std::str::*;
use std::fmt::Debug;
#[allow(unused_imports)] use std::cmp::Ordering::*;
#[allow(unused_imports)] use std::collections::*;

#[allow(unused_macros)]
macro_rules! a {
    ($c: tt, $x: expr, $y: expr) => {{
        let b = $y; let a = &mut $x;
        if b $c *a { *a = b; true } else { false }
    }};
}
struct WordReader<'a> { it : SplitAsciiWhitespace<'a>, }
#[allow(dead_code)]
impl<'a> WordReader<'a> {
    fn new<T: Read>(b: &mut String, mut r: T) -> WordReader {
        b.clear();
        r.read_to_string(b).unwrap();
        WordReader { it: b.split_ascii_whitespace() }
    }
    fn from_stdin(b: &mut String) -> WordReader {
        WordReader::new(b, stdin())
    }
    fn sl(&mut self) ->  &str { self.it.next().unwrap() }
    fn bs(&mut self) -> &[u8] { self.sl().as_bytes()    }
    fn s(&mut self) -> String { String::from(self.sl()) }
    fn i(&mut self) ->    i32 { self.p()                }
    fn u(&mut self) ->  usize { self.p()                }
    fn vi(&mut self, n: usize) -> Vec<i32> {
        self.vp::<i32>(n)
    }
    fn p<T: FromStr>(&mut self) -> T where T::Err: Debug {
        self.sl().parse::<T>().unwrap()
    }
    fn vp<T: FromStr>(&mut self, n: usize) -> Vec<T> where T::Err: Debug {
        (0..n).map(|_| self.p()).collect()
    }
}

#[allow(dead_code)]
fn build_counting_hashmap<K: Eq + std::hash::Hash, T>(i: T) -> HashMap<K,usize>
    where T: Iterator<Item = K> {
    let mut m = HashMap::new();
    for k in i {
        let n = 1 + if let Some(&n) = m.get(&k) { n } else { 0 };
        m.insert(k, n);
    }
    m
}

fn main() {
    let mut bin = String::new();
    let mut input = WordReader::from_stdin(&mut bin);

    let n: i64 = input.p();
    let x = n * (n + 1) / 2;
    println!("{}", x % 2);
}


fn input() -> u64 {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

fn main() {
    print!("{}", 1 - ((input() - 1) / 2) % 2);
}


use std::io;

fn gcd(u: u32, v: u32) -> u32 {
    if u == 0 {
        return u;
    }
    if v == 0 {
        return v;
    }
    let mut shift = 0;
    let mut aux : [u32; 2] = [(u | v), 1];
    while aux[0] & aux[1] == 0 {
        shift += 1;
        aux[1] <<= 1;
    }
    let mut u = u >> shift;
    let mut v = v >> shift;

    while u & 1 == 0 {
        u >>= 1;
    }

    loop {
        while v & 1 == 0 {
            v >>= 1;
        }

        if u > v {
            aux[0] = v;
            v = u;
            u = aux[0];
        }
        v = v - u;

        if v == 0 {
            break;
        }
    }
    u << shift
}

fn main() {
    let mut buffer = String::new();
    io::stdin().read_line(&mut buffer).expect("failed to read input");
    let n: u32 = buffer.trim().parse().expect("invalid input");

    let mut i = n / 2 + 1;
    while gcd(i, n - i) != 1 {
        i += 1;
    }
    println!("{} {}", n - i, i);
}


use std::io;

fn gcd(mut a: u32, mut b: u32) -> u32 {
    while a != 0 {
        b %= a;
        let t = a;
        a = b;
        b = t;
    }
    return b;
}

fn main() {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line).unwrap();
    let n: u32 = line.trim().parse().unwrap();
    // let a = n / 2;
    for i in 0 .. n / 2 {
        let a: u32 = n / 2 - i;
        if gcd(a, n - a) == 1 {
            println!("{} {}", a, n - a);
            break;
        }
    }
    // println!("{} {}", a - (1 - n % 2), a + 1);
}


use std::io::{ self, BufRead };
use std::collections::*;

macro_rules! scan_line {
    () => ({
        let stdin = io::stdin();
        let mut handle = stdin.lock();
        let mut buffer = String::new();
        handle.read_line(&mut buffer)
            .expect("scan_line: failed at `handle.read_line`.");
        buffer
    });
    ( $($t:ty)+ ) => ({
        let stdin = io::stdin();
        let mut handle = stdin.lock();
        let mut buffer = String::new();
        handle.read_line(&mut buffer)
            .expect("scan_line: failed at `handle.read_line`.");
        let mut chunks = buffer.split_whitespace();

        ($(
            {
                chunks.next()
                    .expect("scan_line: failed at `next`, # of space separated strings not equal to requested #")
                .parse::<$t>()
                    .expect("scan_line: failed at `parse::<$t>`.")
            },
        )+)
    })
}

fn main() {
    let (mut n, ) = scan_line!(i64);

    n -= 3;
    let mut numerator = 1;
    let mut denominator = 2;

    while n >= 1 {
        if numerator + 1 < denominator {
            numerator += 1;
        } else {
            denominator += 1;
        }
        n -= 1;
    }

    let primes = vec![2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101];

    loop {
        if numerator == 1 { break; }
        let mut good = true;
        for p in primes.iter() {
            if denominator % *p == 0 && numerator % *p == 0 {
                denominator += 1;
                numerator -= 1;
                good = false;
                break;
            }
        }
        if good { break; }
    }

    println!("{} {}", numerator, denominator);
}


use std::io;
use std::str::FromStr;

use std::cmp::{max, min};

fn get_line() -> String {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    input
}

fn get_vec<T>(s: String) -> Vec<T>
    where T: FromStr,
          <T as FromStr>::Err: std::fmt::Debug,
{
    s.split_whitespace().map(|k| k.parse().unwrap()).collect()
}

fn gcd(a: u32, b: u32) -> u32 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    let n: u32 = get_line().trim().parse().unwrap();

    let (a, b) = if n % 2 == 0 {
        let p = n / 2;
        let i = (1..1000).find(|&k| gcd(p + k, p - k) == 1).unwrap();
        (p - i, p + i)
    } else {
        (n / 2, n / 2 + 1)
    };

    println!("{} {}", a, b);
}


//spnauti-rusT {{{
use std::io::*; use std::str::{self,*}; use std::fmt::Debug;
#[allow(unused_imports)] use std::cmp::Ordering::{self,*};
#[allow(unused_imports)] use std::ops::{self,*};
#[allow(unused_imports)] use std::iter::{self,*};
#[allow(unused_imports)] use std::collections::*;
#[allow(unused_imports)] use std::cell::*;
#[allow(unused_macros)] macro_rules! min {
	($x:expr,$y:expr) => {{ let b=$y; let a=&mut$x; if b < *a {*a=b; true} else {false} }};
}
#[allow(unused_macros)] macro_rules! max {
	($x:expr,$y:expr) => {{ let b=$y; let a=&mut$x; if b > *a {*a=b; true} else {false} }};
}
#[allow(unused_macros)] macro_rules! l {
	($($v:ident),+ =$e:expr) => {$(let$v=$e;)+};
	($($v:ident),+:$t:ty=$e:expr) => {$(let$v:$t=$e;)+};
	(mut $($v:ident),+ =$e:expr) => {$(let mut$v=$e;)+};
	(mut $($v:ident),+:$t:ty=$e:expr) => {$(let mut$v:$t=$e;)+};
}
#[allow(unused_macros)] macro_rules! v {
	([$d:expr]$($s:tt)+) => {vec![v!($($s)+);$d]};
	([]) => {Vec::new()}; ([$e:expr]) => {Vec::with_capacity($e)}; (=$e:expr) => {$e};
}
#[allow(unused_macros)] macro_rules! rep { {[$c:expr]$($s:tt)+} => {for _ in 0..$c {$($s)+}} }
#[allow(dead_code)] fn reader() -> WordReaderC { WordReaderC::new() }
#[allow(dead_code)] fn writer() -> BufWriter<Stdout> { BufWriter::new(stdout()) }
struct WordReaderC {buf: Vec<u8>, pos: usize, q: std::io::StdinLock<'static>}//'
#[allow(dead_code)] impl WordReaderC {
	fn new() -> Self {
		let r = unsafe {&*Box::into_raw(Box::new(stdin()))};
		Self { q: r.lock(), buf: v!([]), pos: 0 }
	}
	fn next_line(&mut self) -> bool {
		self.buf.clear(); self.pos = 0;
		self.q.read_until(b'\n', &mut self.buf).unwrap_or(0) > 0
	}
	fn is_ws(c: u8) -> bool {
		c == b' ' || c == b'\r' || c == b'\n' || c == b'\t'
	}
	fn byte(&mut self) -> Option<u8> {
		if self.pos == self.buf.len() { if !self.next_line() { return None; } }
		self.pos += 1; Some(self.buf[self.pos - 1])
	}
	fn vb(&mut self) -> Vec<u8> {
		let mut s = v!([8]);
		let mut f = false;
		loop {
			if let Some(c) = self.byte() {
				if !Self::is_ws(c) {
					s.push(c);
					f = true;
				} else if f { break; }
			} else { break; }
		}
		s
	}
	fn board(&mut self, r: usize, c: Option<usize>) -> Vec<Vec<u8>> {
		let mut res = v!([r]);
		let c = c.unwrap_or(0);
		rep!{[r]
			let t = self.vb();
			assert!(c == 0 || t.len() == c);
			res.push(t);
		}
		res
	}
	fn framed_board(&mut self, r: usize, c: usize, f: u8) -> Vec<Vec<u8>> {
		let mut res = v!([r+2]);
		res.push( v!([c+2] = f) );
		rep!{[r]
			let mut t = self.vb();
			assert!(t.len() == c);
			t.reserve(2);
			t.insert(0,f);
			t.push(f);
			res.push(t);
		}
		res.push( v!([c+2] = f) );
		res
	}
	fn s(&mut self) -> String { String::from_utf8(self.vb()).expect("invalid utf8") }
	fn i(&mut self) ->    i32 { self.p() }
	fn l(&mut self) ->    i64 { self.p() }
	fn u(&mut self) ->  usize { self.p() }
	fn f(&mut self) ->    f64 { self.p() }
	fn vi(&mut self, n: usize) -> Vec<i32> { self.vp(n) }
	fn vl(&mut self, n: usize) -> Vec<i64> { self.vp(n) }
	fn vu(&mut self, n: usize) -> Vec<usize> { self.vp(n) }
	fn ii(&mut self, n: usize) -> impl Iterator<Item=i32> { self.ip(n).into_iter() }
	fn iu(&mut self, n: usize) -> impl Iterator<Item=usize> { self.ip(n).into_iter() }
	fn p<T: FromStr>(&mut self) -> T where T::Err: Debug {
		let w = self.vb(); str::from_utf8(w.as_ref()).unwrap().parse::<T>().unwrap()
	}
	fn vp<T: FromStr>(&mut self, n: usize) -> Vec<T> where T::Err: Debug {
		(0..n).map(|_|self.p()).collect()
	}
	fn ip<T: FromStr>(&mut self, n: usize) -> impl Iterator<Item=T> where T::Err: Debug {
		self.vp(n).into_iter()
	}
	fn graph(&mut self, n: usize, m: usize) -> Vec<Vec<usize>> {
		let mut e = v!([n][]); rep!{[m] l!(a,b = self.u()-1); e[a].push(b); e[b].push(a); } e
	}
	fn graph_w<T: Copy+FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<(usize,T)>> where T::Err: Debug {
		let mut e = v!([n][]); rep!{[m] l!(a,b = self.u()-1); let c: T = self.p(); e[a].push((b,c)); e[b].push((a,c)); } e
	}
}
//------------------- End rusT }}}

fn main() {
	let mut rin = reader();
	let mut rout = writer();

	let s = rin.vb();
	let n = s.len();
	let mut sol = 1000;
	for (y,x) in vec![(b'2',b'5'), (b'5',b'0'), (b'7',b'5'), (b'0',b'0')] {
		l!(mut px,py = n);
		for i in (0..n).rev() {
			if px == n && s[i] == x {
				px = i;
			} else if py == n && s[i] == y {
				py = i;
			}
		}
		if px < n && py < n {
			let mut res = 2*n - 3 - px - py;
			if px < py {
				res += 1;
			}
			let mut add = 0;
			let mut done = false;
			for i in 0..n {
				if i == px || i == py {
					continue;
				}
				if s[i] != b'0' {
					done = true;
					break;
				}
				add += 1;
			}
			res += add;
			min!(sol, res);
		}
	}
	if sol < 1000 {
		writeln!(rout, "{}", sol).ok();
	} else {
		writeln!(rout, "-1").ok();
	}
}


macro_rules! parse_line {
    ($t: ty) => ({
        let mut a_str = String::new();
        std::io::stdin().read_line(&mut a_str).expect("read error");
        let a_str = a_str.trim();
        a_str.parse::<$t>().expect("parse error")
    });
    ($($t: ty),+) => ({
        let mut a_str = String::new();
        std::io::stdin().read_line(&mut a_str).expect("read error");
        let mut a_iter = a_str.split_whitespace();
        (
            $(
            a_iter.next().unwrap().parse::<$t>().expect("parse error"),
            )+
        )
    })
}

macro_rules! parse_line_to_vec {
    ($t: ty) => {{
        let mut a_str = String::new();
        std::io::stdin().read_line(&mut a_str).expect("read error");
        (a_str
            .split_whitespace()
            .map(|x| x.parse::<$t>().unwrap())
            .collect::<Vec<$t>>())
    }};
}

fn solve_zeroes(s: &Vec<u8>, count: &Vec<usize>) -> usize {
    if count[0] < 2 {
        return std::usize::MAX;
    }
    let mut first = true;
    let mut result = 0;
    for i in 0..s.len() {
        if s[i] != 0 {
            continue;
        }
        if first {
            first = false;
            result += i;
        }else if !first {
            result += i - 1;
            break;
        }
    }
    return result;
}

fn solve_half(s: &Vec<u8>, count: &Vec<usize>) -> usize {
    if count[5] == 0 || count[0] == 0 {
        return std::usize::MAX;
    }
    if s[0] == 0 && s[1] == 5 {
        return 0;
    }
    if s[0] == 5 && s[1] == 0 {
        return 1;
    }
    if count[5] == 1 && count[0] + 1 == s.len() {
        return std::usize::MAX;
    }
    let mut result = 0;
    let mut first = [std::usize::MAX, std::usize::MAX];
    let mut other = std::usize::MAX;
    for i in 0..s.len() {
        if s[i] != 0 && s[i] != 5 || s[i] == 5 && first[1] != std::usize::MAX {
            other = i;
        }
        if first[0] == std::usize::MAX && s[i] == 0 {
            result += i;
            first[0] = i;
        }
        if first[1] == std::usize::MAX && s[i] == 5 {
            result += i - 1;
            first[1] = i;
        }
    }
    if first[0] > first[1] {
        result += 1;
    }
    if first[1] + 1 == s.len() {
        if s[s.len() - 2] == 0 || first[0] + 2 == s.len() && s[s.len() - 3] == 0 {
            result += s.len() - other - 2;
            if first[0] > other {
                result -= 1;
            }
        }
    }
    return result;
}

fn solve_one(s: &Vec<u8>, count: &Vec<usize>, b: usize, a: usize) -> usize {
    if count[a] == 0 || count[b] == 0 {
        return std::usize::MAX;
    }
    if s[0] == a as u8 && s[1] == b as u8 {
        return 0;
    }
    if s[0] == b as u8 && s[1] == a as u8 {
        return 1;
    }
    if count[a] == 1 && count[b] == 1 && count[0] + 2 == s.len() {
        return std::usize::MAX;
    }
    let mut result = 0;
    let mut first = [std::usize::MAX, std::usize::MAX];
    let mut other = std::usize::MAX;
    for i in 0..s.len() {
        if s[i] != 0 && s[i] != a as u8 && s[i] != b as u8 ||
            s[i] == a as u8 && first[0] != std::usize::MAX ||
            s[i] == b as u8 && first[1] != std::usize::MAX {
            other = i;
        }
        if first[0] == std::usize::MAX && s[i] == a as u8 {
            result += i;
            first[0] = i;
        }
        if first[1] == std::usize::MAX && s[i] == b as u8 {
            result += i - 1;
            first[1] = i;
        }
    }
    if first[0] > first[1] {
        result += 1;
    }
    if first[1] + 1 == s.len() {
        if s[s.len() - 2] == 0 || first[0] + 2 == s.len() && s[s.len() - 3] == 0 {
            result += s.len() - other - 2;
            if first[0] > other {
                result -= 1;
            }
        }
    }else if first[0] + 1 == s.len() {
        if s[s.len() - 2] == 0 || first[1] + 2 == s.len() && s[s.len() - 3] == 0 {
            result += s.len() - other - 2;
            if first[1] > other {
                result -= 1;
            }
        }
    }
    return result;
}

fn solve() {
    let mut s: Vec<_> = parse_line!(String).bytes().map(|x| x - b'0').collect();
    if s.len() == 1 {
        return println!("-1");
    }
    s.reverse();
    let mut counts = vec![0; 10];
    for &c in s.iter() {
        counts[c as usize] += 1;
    }
    let result = std::cmp::min(solve_zeroes(&s, &counts), std::cmp::min(
                solve_one(&s, &counts, 2, 5), std::cmp::min(solve_one(&s, &counts, 7, 5),
                solve_half(&s, &counts))));
    if result == std::usize::MAX {
        println!("-1");
    }else{
        println!("{}", result);
    }
}

fn main() {
    let tests = 1; // parse_line!(usize);
    for _ in 0..tests {
        solve();
    }
}


#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

const INF: i32 = 1 << 29;

fn calc(n: &[char], pat: &[char]) -> i32 {
    let len = n.len();
    let mut mi = INF;
    if len == 2 {
        for j in 0 .. len {
            if pat[0] != n[j] { continue; }
            for k in 0 .. len {
                if j == k || pat[1] != n[k] { continue; }
                let mut cost = 0;
                let mut x = j as i32;
                let mut y = k as i32;
                cost += (y - len as i32 + 1).abs();
                if x > y { x -= 1; }
                cost += (x - len as i32 + 2).abs();
                eprintln!("{:?} ==> {}", (j, k), cost);
                mi = min(mi, cost);
            }
        }
        return mi;
    }
    for i in 0 .. len {
        if n[i] == '0' { continue; }
        for j in 0 .. len {
            if i == j || pat[0] != n[j] { continue; }
            for k in 0 .. len {
                if i == k || j == k || pat[1] != n[k] { continue; }
                let mut cost = 0;
                cost += i as i32;
                let mut x = if i < j { j } else { j + 1 } as i32;
                let mut y = if i < k { k } else { k + 1 } as i32;
                cost += (y - len as i32 + 1).abs();
                if x > y { x -= 1; }
                cost += (x - len as i32 + 2).abs();
                eprintln!("{:?} ==> {}", (i, j, k), cost);
                mi = min(mi, cost);
            }
        }
    }
    return mi;
}

fn solve() {
    let n: Vec<char> = get_word().chars().collect();
    let mut mi = INF;
    for pat in [['0', '0'], ['2', '5'], ['5', '0'], ['7', '5']].iter() {
        mi = min(mi, calc(&n, pat));
    }
    println!("{}", if mi == INF { -1 } else { mi });
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


use std::io;
use std::io::Stdin;
use std::str::FromStr;

fn read_line(stdin : &Stdin, line : &mut String) {
    match stdin.read_line(line) {
        Ok(_) => return,
        Err(msg) => panic!("Could not read line! Message: {}.", msg),
    }
}

fn parse_t<T : FromStr>(s : &str) -> T {
    match s.trim().parse() {
        Ok(y) => y,
        Err(_) => panic!("Could not read from string!"),
    }
}

fn read_t<T : FromStr>(stdin : &Stdin) -> T {
    let mut line = String::new();
    read_line(stdin, &mut line);
    parse_t(&line)
}

fn digit_indices(ds : &Vec<u64>, di : &mut Vec<Vec<usize>>) {
    di.clear();
    for _ in 0 .. 10 {
        let ev = vec![];
        di.push(ev);
    }
    for i in 0 .. ds.len() {
        di[ds[i] as usize].push(i);
    }
}

fn digits(n : u64, ds : &mut Vec<u64>) {
    ds.clear();
    if n == 0 {
        ds.push(0);
    } else {
        let mut x = n;
        loop {
            if x == 0 {
                break;
            } else {
                let x_mod_10 = x % 10;
                let x_div_10 = x / 10;
                ds.push(x_mod_10);
                x = x_div_10;
            }
        }
    }
}

fn move_digits(from : usize, to : usize, dgts : &mut Vec<u64>) -> u64 {
    let mut num_swaps = 0;
    let dgt_from = dgts[from];
    let mut idx = from - 1;
    loop {
        if idx == to {
            dgts[idx + 1] = dgts[idx];
            dgts[idx] = dgt_from;
            num_swaps = num_swaps + 1;
            break;
        } else {
            dgts[idx + 1] = dgts[idx];
            idx = idx - 1;
            num_swaps = num_swaps + 1;
        }
    }
    num_swaps
}

fn swap_zero_out(from : usize, to : usize, dgts : &mut Vec<u64>) -> Option<u64> {
    if from < 2 {
        None
    } else {
        let mut found = false;
        let mut idx = from - 2;
        if idx < to {
            None
        } else {
            loop {
                if idx == to {
                    if dgts[idx] == 0 {
                        // Do nothing ...
                    } else {
                        found = true;
                    }
                    break;
                } else {
                    if dgts[idx] == 0 {
                        idx = idx - 1;
                    } else {
                        found = true;
                        break;
                    }
                }
            }
            if found {
                let num_swaps = move_digits(from - 1, idx, dgts);
                Some(num_swaps)
            } else {
                None
            }
        }
    }
}

fn swap_to_index(from : usize, to : usize, dgts : &mut Vec<u64>) -> Option<u64> {
    if from < to {
        panic!("Check failed: from({}) >= to({}).", from, to);
    } else if from == to {
        Some(0)
    } else {
        let num_dgts = dgts.len();
        if from == (num_dgts - 1) {
            // From is the highest digit, we have to check whether
            // the digit immediately to the right of it is a zero.
            if dgts[from - 1] == 0 {
                // We have to swap zero out of its location.
                match swap_zero_out(from, to, dgts) {
                    None => None,
                    Some(x) => {
                        let y = move_digits(from, to, dgts);
                        let num_swaps = x + y;
                        Some(num_swaps)
                    },
                }
            } else {
                // We don't have to worry about swapping a zero into
                // the highest digit.
                let num_swaps = move_digits(from, to, dgts);
                Some(num_swaps)
            }
        } else {
            // From is not the highest digit, so we need not
            // worry about swapping a zero into its place.
            let num_swaps = move_digits(from, to, dgts);
            Some(num_swaps)
        }
    }
}

fn num_swaps_for_digits(n : u64,
                        d_1 : usize,
                        m_1 : usize,
                        d_2 : usize,
                        m_2 : usize) -> Option<u64> {
    let mut dgts = vec![];
    digits(n, &mut dgts);
    let mut dgt_indxs = vec![];
    digit_indices(&dgts, &mut dgt_indxs);
    let mut could_swap = true;
    let mut num_swaps = u64::max_value();
    match swap_to_index(dgt_indxs[d_1][m_1], 0, &mut dgts) {
        None => {
            could_swap = false;
        },
        Some(x) => {
            num_swaps = x;
        },
    };
    if could_swap {
        let mut could_swap_2 = true;
        digit_indices(&dgts, &mut dgt_indxs);
        match swap_to_index(dgt_indxs[d_2][m_2], 1, &mut dgts) {
            None => {
                could_swap_2 = false;
            },
            Some(x) => {
                num_swaps = num_swaps + x;
            },
        };
        if could_swap_2 {
            Some(num_swaps)
        } else {
            None
        }
    } else {
        None
    }
}

fn num_swaps_to_divisible_by_25(n : u64) -> Option<u64> {
    let mut dgts = vec![];
    digits(n, &mut dgts);
    let mut dgt_indxs = vec![];
    digit_indices(&dgts, &mut dgt_indxs);
    let num_digits = dgts.len();
    // Check for at least two digits.
    if num_digits < 2 {
        None
    } else {
        let mut min_num_swaps = u64::max_value();
        // Check for two zeros.
        if dgt_indxs[0].len() >= 2 {
            // We have to swap the digits into place...
            match num_swaps_for_digits(n, 0, 0, 0, 1) {
                None => (),
                Some(x) => {
                    if x < min_num_swaps {
                        min_num_swaps = x;
                    }
                }
            }
        }
        digits(n, &mut dgts);
        digit_indices(&dgts, &mut dgt_indxs);
        if (dgt_indxs[0].len() >= 1) && (dgt_indxs[5].len() >= 1) {
            let mut could_swap = true;
            let mut num_swaps = u64::max_value();
            match swap_to_index(dgt_indxs[0][0], 0, &mut dgts) {
                None => {
                    could_swap = false;
                },
                Some(x) => {
                    num_swaps = x;
                },
            };
            if could_swap {
                let mut could_swap_2 = true;
                digit_indices(&dgts, &mut dgt_indxs);
                match swap_to_index(dgt_indxs[5][0], 1, &mut dgts) {
                    None => {
                        could_swap_2 = false;
                    },
                    Some(x) => {
                        num_swaps = num_swaps + x;
                    },
                };
                if could_swap_2 {
                    if num_swaps < min_num_swaps {
                        min_num_swaps = num_swaps;
                    }
                }
            }
        }
        digits(n, &mut dgts);
        digit_indices(&dgts, &mut dgt_indxs);
        if (dgt_indxs[2].len() >= 1) && (dgt_indxs[5].len() >= 1) {
            let mut could_swap = true;
            let mut num_swaps = u64::max_value();
            match swap_to_index(dgt_indxs[5][0], 0, &mut dgts) {
                None => {
                    could_swap = false;
                },
                Some(x) => {
                    num_swaps = x;
                },
            };
            if could_swap {
                let mut could_swap_2 = true;
                digit_indices(&dgts, &mut dgt_indxs);
                match swap_to_index(dgt_indxs[2][0], 1, &mut dgts) {
                    None => {
                        could_swap_2 = false;
                    },
                    Some(x) => {
                        num_swaps = num_swaps + x;
                    },
                };
                if could_swap_2 {
                    if num_swaps < min_num_swaps {
                        min_num_swaps = num_swaps;
                    }
                }
            }
        }
        digits(n, &mut dgts);
        digit_indices(&dgts, &mut dgt_indxs);
        if (dgt_indxs[7].len() >= 1) && (dgt_indxs[5].len() >= 1) {
            let mut could_swap = true;
            let mut num_swaps = u64::max_value();
            match swap_to_index(dgt_indxs[5][0], 0, &mut dgts) {
                None => {
                    could_swap = false;
                },
                Some(x) => {
                    num_swaps = x;
                },
            };
            if could_swap {
                let mut could_swap_2 = true;
                digit_indices(&dgts, &mut dgt_indxs);
                match swap_to_index(dgt_indxs[7][0], 1, &mut dgts) {
                    None => {
                        could_swap_2 = false;
                    },
                    Some(x) => {
                        num_swaps = num_swaps + x;
                    },
                };
                if could_swap_2 {
                    if num_swaps < min_num_swaps {
                        min_num_swaps = num_swaps;
                    }
                }
            }
        }
        if min_num_swaps < u64::max_value() {
            Some(min_num_swaps)
        } else {
            None
        }
    }
}

fn main() {
    let stdin = io::stdin();
    let n = read_t(&stdin);
    match num_swaps_to_divisible_by_25(n) {
        None => println!("-1"),
        Some(s) => println!("{}", s),
    }
}


use std::io;
use std::io::Stdin;
use std::str::FromStr;

fn read_line(stdin : &Stdin, line : &mut String) {
    match stdin.read_line(line) {
        Ok(_) => return,
        Err(msg) => panic!("Could not read line! Message: {}.", msg),
    }
}

fn parse_t<T : FromStr>(s : &str) -> T {
    match s.trim().parse() {
        Ok(y) => y,
        Err(_) => panic!("Could not read from string!"),
    }
}

fn read_t<T : FromStr>(stdin : &Stdin) -> T {
    let mut line = String::new();
    read_line(stdin, &mut line);
    parse_t(&line)
}

fn digit_indices(ds : &Vec<u64>, di : &mut Vec<Vec<usize>>) {
    di.clear();
    for _ in 0 .. 10 {
        let ev = vec![];
        di.push(ev);
    }
    for i in 0 .. ds.len() {
        di[ds[i] as usize].push(i);
    }
}

fn digits(n : u64, ds : &mut Vec<u64>) {
    ds.clear();
    if n == 0 {
        ds.push(0);
    } else {
        let mut x = n;
        loop {
            if x == 0 {
                break;
            } else {
                let x_mod_10 = x % 10;
                let x_div_10 = x / 10;
                ds.push(x_mod_10);
                x = x_div_10;
            }
        }
    }
}

fn move_digits(from : usize, to : usize, dgts : &mut Vec<u64>) -> u64 {
    let mut num_swaps = 0;
    let dgt_from = dgts[from];
    let mut idx = from - 1;
    loop {
        if idx == to {
            dgts[idx + 1] = dgts[idx];
            dgts[idx] = dgt_from;
            num_swaps = num_swaps + 1;
            break;
        } else {
            dgts[idx + 1] = dgts[idx];
            idx = idx - 1;
            num_swaps = num_swaps + 1;
        }
    }
    num_swaps
}

fn swap_zero_out(from : usize, to : usize, dgts : &mut Vec<u64>) -> Option<u64> {
    if from < 2 {
        None
    } else {
        let mut found = false;
        let mut idx = from - 2;
        if idx < to {
            None
        } else {
            loop {
                if idx == to {
                    if dgts[idx] == 0 {
                        // Do nothing ...
                    } else {
                        found = true;
                    }
                    break;
                } else {
                    if dgts[idx] == 0 {
                        idx = idx - 1;
                    } else {
                        found = true;
                        break;
                    }
                }
            }
            if found {
                let num_swaps = move_digits(from - 1, idx, dgts);
                Some(num_swaps)
            } else {
                None
            }
        }
    }
}

fn swap_to_index(from : usize, to : usize, dgts : &mut Vec<u64>) -> Option<u64> {
    if from < to {
        panic!("Check failed: from({}) >= to({}).", from, to);
    } else if from == to {
        Some(0)
    } else {
        let num_dgts = dgts.len();
        if from == (num_dgts - 1) {
            // From is the highest digit, we have to check whether
            // the digit immediately to the right of it is a zero.
            if dgts[from - 1] == 0 {
                // We have to swap zero out of its location.
                match swap_zero_out(from, to, dgts) {
                    None => None,
                    Some(x) => {
                        let y = move_digits(from, to, dgts);
                        let num_swaps = x + y;
                        Some(num_swaps)
                    },
                }
            } else {
                // We don't have to worry about swapping a zero into
                // the highest digit.
                let num_swaps = move_digits(from, to, dgts);
                Some(num_swaps)
            }
        } else {
            // From is not the highest digit, so we need not
            // worry about swapping a zero into its place.
            let num_swaps = move_digits(from, to, dgts);
            Some(num_swaps)
        }
    }
}

fn num_swaps_to_divisible_by_25(n : u64) -> Option<u64> {
    let mut dgts = vec![];
    digits(n, &mut dgts);
    let mut dgt_indxs = vec![];
    digit_indices(&dgts, &mut dgt_indxs);
    let num_digits = dgts.len();
    // Check for at least two digits.
    if num_digits < 2 {
        None
    } else {
        let mut min_num_swaps = u64::max_value();
        // Check for two zeros.
        if dgt_indxs[0].len() >= 2 {
            // We have to swap the digits into place...
            let mut could_swap = true;
            let mut num_swaps = u64::max_value();
            match swap_to_index(dgt_indxs[0][0], 0, &mut dgts) {
                None => {
                    could_swap = false;
                },
                Some(x) => {
                    num_swaps = x;
                },
            };
            if could_swap {
                let mut could_swap_2 = true;
                digit_indices(&dgts, &mut dgt_indxs);
                match swap_to_index(dgt_indxs[0][1], 1, &mut dgts) {
                    None => {
                        could_swap_2 = false;
                    },
                    Some(x) => {
                        num_swaps = num_swaps + x;
                    },
                };
                if could_swap_2 {
                    if num_swaps < min_num_swaps {
                        min_num_swaps = num_swaps;
                    }
                }
            }
        }
        digits(n, &mut dgts);
        digit_indices(&dgts, &mut dgt_indxs);
        if (dgt_indxs[0].len() >= 1) && (dgt_indxs[5].len() >= 1) {
            let mut could_swap = true;
            let mut num_swaps = u64::max_value();
            match swap_to_index(dgt_indxs[0][0], 0, &mut dgts) {
                None => {
                    could_swap = false;
                },
                Some(x) => {
                    num_swaps = x;
                },
            };
            if could_swap {
                let mut could_swap_2 = true;
                digit_indices(&dgts, &mut dgt_indxs);
                match swap_to_index(dgt_indxs[5][0], 1, &mut dgts) {
                    None => {
                        could_swap_2 = false;
                    },
                    Some(x) => {
                        num_swaps = num_swaps + x;
                    },
                };
                if could_swap_2 {
                    if num_swaps < min_num_swaps {
                        min_num_swaps = num_swaps;
                    }
                }
            }
        }
        digits(n, &mut dgts);
        digit_indices(&dgts, &mut dgt_indxs);
        if (dgt_indxs[2].len() >= 1) && (dgt_indxs[5].len() >= 1) {
            let mut could_swap = true;
            let mut num_swaps = u64::max_value();
            match swap_to_index(dgt_indxs[5][0], 0, &mut dgts) {
                None => {
                    could_swap = false;
                },
                Some(x) => {
                    num_swaps = x;
                },
            };
            if could_swap {
                let mut could_swap_2 = true;
                digit_indices(&dgts, &mut dgt_indxs);
                match swap_to_index(dgt_indxs[2][0], 1, &mut dgts) {
                    None => {
                        could_swap_2 = false;
                    },
                    Some(x) => {
                        num_swaps = num_swaps + x;
                    },
                };
                if could_swap_2 {
                    if num_swaps < min_num_swaps {
                        min_num_swaps = num_swaps;
                    }
                }
            }
        }
        digits(n, &mut dgts);
        digit_indices(&dgts, &mut dgt_indxs);
        if (dgt_indxs[7].len() >= 1) && (dgt_indxs[5].len() >= 1) {
            let mut could_swap = true;
            let mut num_swaps = u64::max_value();
            match swap_to_index(dgt_indxs[5][0], 0, &mut dgts) {
                None => {
                    could_swap = false;
                },
                Some(x) => {
                    num_swaps = x;
                },
            };
            if could_swap {
                let mut could_swap_2 = true;
                digit_indices(&dgts, &mut dgt_indxs);
                match swap_to_index(dgt_indxs[7][0], 1, &mut dgts) {
                    None => {
                        could_swap_2 = false;
                    },
                    Some(x) => {
                        num_swaps = num_swaps + x;
                    },
                };
                if could_swap_2 {
                    if num_swaps < min_num_swaps {
                        min_num_swaps = num_swaps;
                    }
                }
            }
        }
        if min_num_swaps < u64::max_value() {
            Some(min_num_swaps)
        } else {
            None
        }
    }
}

fn main() {
    let stdin = io::stdin();
    let n = read_t(&stdin);
    match num_swaps_to_divisible_by_25(n) {
        None => println!("-1"),
        Some(s) => println!("{}", s),
    }
}


pub fn main() {
    let mut input = io::Input::new();

    let num: String = input.next();

    if num.len() == 1 {
        println!("-1");
        return;
    }

    let p = vec![
        try(&num, '5', '2'),
        try(&num, '5', '7'),
        try(&num, '0', '0'),
        try(&num, '0', '5'),
    ];

    println!("{}", match p.iter().min() {
        Some(&::std::usize::MAX) => -1,
        Some(&result) => result as i32,
        _ => unreachable!(),
    });
}

fn try(num: &String, s0: char, s1: char) -> usize {

    let mut num = num.clone();
    let mut swaps = 0usize;

    // find first

    let pos = num.rfind(s0);
    if let Some(pos) = pos {

        swaps += num.len() - pos - 1;

        num.remove(pos);

        // find second

        let pos = num.rfind(s1);

        if let Some(pos) = pos {

            swaps += num.len() - pos - 1;

            num.remove(pos);
            num.push(s1);
            num.push(s0);

            // correct leading zeroes, if necessary and possible

            if num.starts_with('0') {
                let pos = num.find(|c| c != '0');
                if let Some(pos) = pos {
                    if pos < num.len() - 2 {
                        swaps += pos;
                        return swaps;
                    }
                }
            } else {
                return swaps;
            }
        }
    }

    ::std::usize::MAX
}

#[allow(unused)]
pub mod io {

    const BUFFER_SIZE: usize = 8192;

    use std::collections::VecDeque;
    use std::str::FromStr;
    use std::io;
    use std::io::Read;

    type AsciiStr = Vec<u8>;

    pub struct Input {
        token_buffer: VecDeque<String>,
        remaining: String,
    }

    impl Input {

        pub fn new() -> Input {
            Input {
                token_buffer: VecDeque::with_capacity(100),
                remaining: String::new(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T
            where T::Err: ::std::fmt::Debug
        {
            self.fill_buffer();
            self.token_buffer.pop_front().unwrap().parse().unwrap()
        }

        pub fn next_ascii_string(&mut self) -> AsciiStr {
            self.fill_buffer();
            Vec::from(self.token_buffer.pop_front().unwrap().as_bytes())
        }

        fn fill_buffer(&mut self) {
            while self.token_buffer.is_empty() {
                let mut minibuffer = [0u8; BUFFER_SIZE];
                let size = io::stdin().read(&mut minibuffer[..]).unwrap();

                self.remaining += &String::from_utf8_lossy(&minibuffer[..size]);

                if self.remaining.trim().len() > 0 {
                    for token in self.remaining.trim().split_whitespace() {
                        self.token_buffer.push_back(String::from(token))
                    }

                    if size > 0 && ! self.remaining.ends_with(|c: char|char::is_ascii_whitespace(&c)) {
                        self.remaining = self.token_buffer.pop_back().unwrap();
                    } else {
                        self.remaining.clear();
                    }

                } else if size == 0 {
                    panic!("EOF");
                }
            }
        }
    }
}


use std::io;

fn main() {
    let debug = false;
    let stdin: io::Stdin = io::stdin();
    let mut s: String = String::new();

    stdin.read_line(&mut s).unwrap();

    s = s.trim().to_string();

    let ends = [
        ('0', '0'),
        ('2', '5'),
        ('5', '0'),
        ('7', '5'),
    ];

    let mut mc = 100;

    for (l, r) in ends.iter() {
        if debug { println!("--------------") }
        if debug { println!("({}{})", l, r) }
        let mut l_pos = 100;
        let mut r_pos = 100;
        for (i, c) in s.chars().rev().enumerate() {
            if l_pos == 100 && c == *l {
                l_pos = i;
                if *l == *r && r_pos == 100 { l_pos = 100 }
            }
            if r_pos == 100 && c == *r {
                r_pos = i;
            }
        }

        if debug { println!("lpos {} rpos {}", l_pos, r_pos) }
        if l_pos == 100 || r_pos == 100 {
            continue;
        }

        let mut cc = l_pos + r_pos - if l_pos > r_pos { 1 } else { 0 };

        if s.len() > 2 && (l_pos == s.len() - 1 || r_pos == s.len() - 1) {
            let mut m_pos = 100;
            for (i, c) in s.chars().enumerate() {
                if i == s.len() - 1 - l_pos { continue }
                if i == s.len() - 1 - r_pos { continue }
                if c != '0' {
                    m_pos = i;
                    break;
                }
            }

            if debug { println!("mpos {}", m_pos) }
            if m_pos == 100 {
                cc = 101
            } else {
                cc += m_pos;
                if s.len() - 1 - l_pos < m_pos {
                    cc -= 1;
                }
                if s.len() - 1 - r_pos < m_pos {
                    cc -= 1;
                }
            }
        }
        if debug { println!("cc {}", cc) }

        if cc < mc {
            mc = cc;
        }
    }

    if mc == 100 {
        println!("-1");
    } else {
        println!("{}", mc);
    }
}


use std::io::stdin;

fn main() {
    let mut input = String::new();
    stdin().read_line(&mut input).unwrap();

    let emploees: i32 = input.trim().parse().unwrap();
    let mut counter = 0;

    for leaders in 1..emploees {
        if (emploees - leaders) % leaders == 0 {
            counter = counter + 1;
        }
    }

    println!("{}", counter);
}


struct Scan {
    buffer: std::collections::VecDeque<String>,
}

impl Scan {
    fn new() -> Scan {
        Scan {
            buffer: std::collections::VecDeque::new(),
        }
    }

    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop_front() {
                break token.parse::<T>().ok().unwrap();
            }
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).expect("Fail to read");
            self.buffer = line.split_whitespace().map(String::from).collect();
        }
    }
}

fn _main() {
    let mut scan = Scan::new();
    let n: usize = scan.next();
    let mut result = 0usize;
    for i in 1..=(n / 2) {
        if (n - i) % i == 0 {
            result += 1;
        }
    }
    println!("{}", result);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(1 << 23)
        .spawn(_main)
        .unwrap()
        .join()
        .unwrap();
}


use std::io;

fn get_line() -> io::Result<String> {
	let mut buffer = String::new();
	io::stdin().read_line(&mut buffer)?;
	Ok(buffer)
}

fn main() {
	let employees;
	{
		let input = get_line().unwrap();
		employees = input.trim().parse::<u32>().unwrap();
	}

	let mut ways = 0;
	for i in 1..employees {
		if (employees - i) % i == 0 {
			ways += 1;
		}
	}
	print!("{}", ways);
}


//spnauti-rust
#[allow(unused_macros)]
macro_rules! a {
    ($c: tt, $x: expr, $y: expr) => {{
        let b = $y; let a = &mut $x;
        if b $c *a { *a = b; true } else { false }
    }};
}
use std::io::*;
use std::str::*;
use std::fmt::Debug;
struct WordReader<'a> { it : SplitAsciiWhitespace<'a>, }
#[allow(dead_code)]
impl<'a> WordReader<'a> {
    fn new<T: Read>(b: &mut String, mut r: T) -> WordReader {
        b.clear();
        r.read_to_string(b).unwrap();
        WordReader { it: b.split_ascii_whitespace() }
    }
    fn from_stdin(b: &mut String) -> WordReader {
        WordReader::new(b, stdin())
    }
    fn sl(&mut self) ->  &str { self.it.next().unwrap() }
    fn bs(&mut self) -> &[u8] { self.sl().as_bytes()    }
    fn s(&mut self) -> String { String::from(self.sl()) }
    fn i(&mut self) ->    i32 { self.p()                }
    fn p<T: FromStr>(&mut self) -> T where T::Err: Debug {
        self.sl().parse::<T>().unwrap()
    }
    fn vp<T: FromStr>(&mut self, n: usize) -> Vec<T> where T::Err: Debug {
        (0..n).map(|_| self.p()).collect()
    }
}

fn main() {
    let mut bin = String::new();
    let mut input = WordReader::from_stdin(&mut bin);

    let n = input.i();
    let mut sol = 0;
    for i in 1.. {
        if i * i > n { break; }
        if i * i == n { sol += 1; }
        else if n % i == 0 { sol += 2; }
    }
    println!("{}", sol - 1);
}


fn main() {
    let mut no = String::new();
    std::io::stdin().read_line(&mut no)
        .expect("Error  input");
    let no_employees: usize = no.trim().parse().unwrap();
    print!("{}",  (1..no_employees).map(|i| no_employees % i).filter(|e| *e == 0).count());
}


use std::io;

fn main() -> io::Result<()> {
    let mut input = String::new();

    io::stdin().read_line(&mut input)?;

    let n = input.trim().parse::<usize>().unwrap();

    let mut l = 0;
    for i in 1..n {
        if i > (n - i) {
            break;
        }
        if (n - i) % i == 0 {
            l += 1;
        }
    }

    println!("{}", l);

    Ok(())
}


use std::io;
fn main() {
	let mut inp_str = String::new();
	io::stdin().read_line(&mut inp_str).expect("Failed to read line");
	let emp_num: u128 = inp_str.trim().parse().expect("Failed to parse");
	let mut  way: u128 = 0;
	for i in (1..emp_num).rev() {
		if (emp_num - i) % i == 0 {
			way+=1;
		}
	}
	println!("{}", way);
}


use std::io::{BufReader, BufRead};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let n = BufReader::new(std::io::stdin())
        .lines()
        .next()
        .unwrap()?
        .parse::<usize>()?;

    let sqrt = (n as f32).sqrt().floor() as usize;
    let perfect = n == sqrt * sqrt;
    let mut divisors = 0;

    for divisor in 1..=sqrt {
        if n % divisor == 0 {
            divisors += if perfect && divisor == sqrt { 1 } else { 2 };;
        }
    }

    println!("{}", divisors - 1);
    Ok(())
}


use std::io;
use std::str::FromStr;

use std::cmp::{max, min};

fn get_line() -> String {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    input
}

fn get_vec<T>(s: String) -> Vec<T>
    where T: FromStr,
          <T as FromStr>::Err: std::fmt::Debug,
{
    s.split_whitespace().map(|k| k.parse().unwrap()).collect()
}

fn main() {
    let (l, r, x, y, k) = {
        let input = get_line();
        let mut it = input.split_whitespace().map(|k| k.parse::<u64>().unwrap());
        (
            it.next().unwrap(),
            it.next().unwrap(),
            it.next().unwrap(),
            it.next().unwrap(),
            it.next().unwrap(),
            )
    };

    let l2 = k * x;
    let r2 = k * y;

    let l = max(l, l2);
    let r = min(r, r2);

    let q = l / k;

    let ans = r < l || (k * q < l && r < k * (q + 1));
    let ans = !ans;

    if ans {
        println!("YES");
    } else {
        println!("NO");
    }
}


#![allow(unused_imports)]
use std::io::{ self, Write };
use std::str::FromStr;
use std::cmp::{ min, max };
use std::collections::{ BinaryHeap, VecDeque };

#[allow(unused_macros)]
macro_rules! trace {
    ($var:expr) => {
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($var), $var);
    };
    ($($args:expr),*) => {
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($($args),*), ($($args),*));
    };
}

const M: usize = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let l: u64 = sc.cin();
    let r: u64 = sc.cin();
    let x: u64 = sc.cin();
    let y: u64 = sc.cin();
    let k: u64 = sc.cin();

    for b in x..(y + 1) {
        let a = k * b;
        if l <= a && a <= r {
            println!("YES");
            return;
        }
    }
    println!("NO");
}

#[allow(dead_code)]
struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn reserve(&mut self) {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        self.reserve();
        match self.buffer.pop_front().unwrap().parse::<T>() {
            Ok(a) => a,
            Err(_) => panic!("parse err")
        }
    }
    fn get_char(&mut self) -> char {
        self.reserve();
        let head = self.buffer[0].chars().nth(0).unwrap();
        let tail = String::from( &self.buffer[0][1..] );
        if tail.len()>0 { self.buffer[0]=tail } else { self.buffer.pop_front(); }
        head
    }
}


//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

use std::io::Write;

fn run() {
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    input! {
        n: usize,
        x: [u32; n],
    }
    for x in x {
        let mut ans = "NO";
        for a in 0..=100 {
            for b in 0..=100 {
                if 3 * a + 7 * b == x {
                    ans = "YES";
                }
            }
        }
        writeln!(out, "{}", ans).ok();
    }
}

fn main() {
    run();
}


fn main() {
    let mut d = [false; 100];

    for i in (0..).take_while(|&i| 7 * i <= 100) {
        for j in (0..).take_while(|&j| 7 * i + 3 * j <= 100) {
            if i != 0 || j != 0 {
                d[7 * i + 3 * j - 1] = true;
            }
        }
    }

    let mut input = String::new();
    use std::io::prelude::*;
    std::io::stdin().read_to_string(&mut input).unwrap();
    let mut it = input.split_whitespace().map(|x| x.parse::<i32>().unwrap());

    let n = it.next().unwrap();

    let mut ans_str = String::with_capacity(100 * 5);

    for _ in 0..n {
        let x = it.next().unwrap();

        if d[x as usize - 1] {
            ans_str.push_str("YES\n");
        } else {
            ans_str.push_str("NO\n");
        }
    }

    write!(std::io::stdout(), "{}", ans_str).unwrap();
}


use std::io;
fn main(){
    let mut s:String=String::new();
    io::stdin().read_line(&mut s).unwrap();
    let n:i64=s.trim().parse::<i64>().unwrap();
    let mut b:i64=0;
    let mut p:i64=0;
    let mut m:i64=0;
    for c in 0..n{
        s.clear();
        io::stdin().read_line(&mut s).unwrap();
        b=s.trim().parse::<i64>().unwrap();
        if b%7==0 || b%3==0{println!("YES")}
        else{
            p=b/7;
            m=p*7;
            while p!=0 && m!=b{
                m+=3;
                if m>b{p-=1;m=p*7}
            }
            if p==0{println!("NO")}
            else{println!("YES")}
        }
    }
}


use std::io;

fn main() {
  let mut buffer = String::new();
  io::stdin().read_line(&mut buffer).unwrap();
  let n = buffer.trim().parse::<usize>().unwrap();
  for _ in 0..n {
    buffer.clear();
    io::stdin().read_line(&mut buffer).unwrap();
    let x = buffer.trim().parse::<u8>().unwrap();
    let mut ok = false;
    for a in 0..34 {
      for b in 0..15 {
        ok |= (a *  3 + b * 7) == x;
      }
    }
    if ok {
      println!("YES");
    } else {
      println!("NO");
    }
  }
}


use std::cmp;
use std::fs::File;
use std::io::Read;

// fn pow_speedt_with_mod(mut p: i64, mut q: i64, m: i64) -> i64 {
//     p %= m;
//     let mut r = p;
//     let mut ret: i64 = 1;
//     while q > 0 {
//         ret *= if q % 2 == 1 {r} else {1};
//         r *= r;
//         r %= m;
//         q /= 2;
//         ret %= m;
//     }
//     return ret;
// }

fn main() {
    let inputstatus = 1;

    let mut buf = String::new();
    let filename = "inputrust.txt";

    if inputstatus == 0 {
        let mut f = File::open(filename).expect("file not found");
        f.read_to_string(&mut buf)
            .expect("something went wrong reading the file");
    } else {
        std::io::stdin().read_to_string(&mut buf).unwrap();
    }

    let mut iter = buf.split_whitespace();
    let a: i32 = iter.next().unwrap().parse().unwrap();
    let b: i32 = iter.next().unwrap().parse().unwrap();
    let c: i32 = iter.next().unwrap().parse().unwrap();

    let v: [i32; 3] = [a / 3, b / 2, c / 2];
    let week: i32 = *v.iter().min().unwrap() as i32;

    let fish: i32 = a - 3 * week;
    let rabbit: i32 = b - 2 * week;
    let chicken: i32 = c - 2 * week;
    let mut ans = 0;
    let menu: [usize; 7] = [0, 1, 2, 0, 2, 1, 0];

    for df in 0..7 {
        let mut rest: [i32; 3] = [fish, rabbit, chicken];
        for di in 0..7 {
            let d = menu[(df + di) % 7];
            rest[d] -= 1;
            if rest[d] < 0 {
                ans = cmp::max(ans, di as i32);
                break;
            }
        }
    }

    println!("{}", ans + week * 7);

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

    // if p + 1 >= m

    // println!("{}", n);
    // println!("{}", k);
    // println!("{:?}", num);
    // println!("{:?}", cum_num);
}