//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 = input.u();
    let a = input.vi(n);
    let sol = if n == 1 && a[0] % 15 > 0 {
        "-1"
    } else if a[n-1] == 0 || (a[n-1] != 15 && a[n-2] < a[n-1]) {
        "UP"
    } else {
        "DOWN"
    };
    println!("{}", sol);
}


#[allow(unused_imports)]
use std::io;
use std::cmp::{min, max};
use std::mem;
use std::str::FromStr;
use std::cmp::Ordering;
use std::collections::BinaryHeap;

pub struct Scanner<B> {
    reader: B,
    buffer: Vec<String>,
}

impl<B: io::BufRead> Scanner<B> {
    pub fn new(reader: B) -> Scanner<B> {
        Scanner {
            reader: reader,
            buffer: Vec::new(),
        }
    }

    /// Use "turbofish" syntax next::<T>() to select data type of next token.
    pub fn next<T: ::std::str::FromStr>(&mut self) -> T
        where
            T::Err: ::std::fmt::Debug,
    {
        if let Some(front) = self.buffer.pop() {
            front.parse::<T>().expect(&front)
        } else {
            let mut input = String::new();
            self.reader.read_line(&mut input).expect("Line not read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
            self.next()
        }
    }

    pub fn next_vec<T: ::std::str::FromStr>(&mut self, len: usize) -> Vec<T>
        where
            T::Err: ::std::fmt::Debug,
    {
        (0..len).map(|_| self.next::<T>()).collect::<Vec<T>>()
    }
}

fn main1() {
    let stdin = io::stdin();
    let mut input = Scanner::new(stdin.lock());
    let n = input.next::<usize>();
    let a = input.next_vec::<i64>(n);
    if a[n - 1] == 15 {
        println!("DOWN");
    } else if a[n - 1] == 0 {
        println!("UP");
    } else {
        if n == 1 {
            println!("-1");
        } else if a[n - 2] < a[n - 1] {
            println!("UP");
        } else {
            println!("DOWN");
        }
    }

}

fn main() {
    std::thread::Builder::new().stack_size(50 << 20)
        .spawn(main1).unwrap().join().unwrap();
}


use std::io;

fn main() {
  	let mut input = String::new();
    let stdin = io::stdin();
  	stdin.read_line(&mut input).unwrap();
  	let n = input.trim().parse::<usize>().unwrap();
	let mut v: Vec<i32> = Vec::new();
input.clear();
  	stdin.read_line(&mut input)
          .expect("correct input");
	for u in input.trim().split(' ') {
          let cur_txt = u.trim();
          if cur_txt.len() > 0 {
            let cur_num: i32 = cur_txt.parse().unwrap();
            v.push(cur_num);
        }
    }
    if n == 1 {
    	if v[0] == 15 {
			println!("DOWN");
		} else if v[0] == 0 {
			println!("UP");
		} else {
			println!("-1");
		}
    } else {
    	if v[n-1] == 15 {
			println!("DOWN");
		} else if v[n-1] == 0 {
			println!("UP");
		} else if v[n-2] > v[n-1] {
			println!("DOWN");
		} else {
			println!("UP");
		}
    }
}


#[allow(unused_imports)]
use std::cmp::{min,max};
use std::collections::{*};
use std::io::{BufWriter, stdin, stdout, Write};
const BITS: usize = 19;

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>
}
impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn main() {
    let mut scanner = Scanner::default();
    let mut n: u128 = scanner.next();
    let mut week: Vec<u128> = (1..=7).map(|_| scanner.next()).collect();
    let mut cur: u128 = 0;
    let mut i: usize = 0;
    while cur < n {
    	cur += week[i];
    	if cur >= n {
    		println!["{}", i+1];
    	}
    	i += 1;
    	i %= 7;
    }
}


fn main() {
    let n: u32 = get_input().parse().unwrap();
    let days: Vec<u32> = get_input().split_ascii_whitespace().map(|v| v.parse().unwrap()).collect();
    let total: u32 = days.iter().sum();
    //println!("total is {}", total);
    let m =  {
        if total > n {
            n
        } else if total == n || n % total == 0 {
            total
        } else {
            n % total
        }
    };

    let mut c = 0;

    //println!("mod is {}", m);
    for i in 0..days.len() {
        //println!("c is {}", c);
        c += days[i];

        if c >= m {
            println!("{}", i+1);
            break;
        }
    }
}

fn get_input() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).expect("Failed");
    buffer.trim().to_owned()
}

fn get_input_usize() -> usize {
    get_input().parse().unwrap()
}


use std::io;

// type Matrix = Vec<Vec<char>>;

fn read_line() -> String {
    let mut input_line = String::new();
    io::stdin().read_line(&mut input_line).unwrap();
    return String::from(input_line.trim());
}

fn read_line_vec() -> Vec<u32> {
    return read_line().split(' ')
        .map(|s| s.parse().unwrap())
        .collect();
}

fn main() {
    let mut n: u32 = read_line().parse().unwrap();
    let week = read_line_vec();
    let s: u32 = week.iter().sum();

    n = ((n - 1) % s) + 1;

    for i in 0..week.len() {
        if n <= week[i] {
            println!("{}", i + 1);
            break;
        }
        n -= week[i];
    }

}


#[allow(unused_imports)]
use std::io::{stdin, Read, StdinLock};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::{HashSet, HashMap, BinaryHeap};
#[allow(unused_imports)]
use std::vec::Vec;

#[allow(dead_code)]
const INF: i32 = 1000_000_000;
#[allow(dead_code)]
const INFLL: i64 = 1000_000_000_000_000_000;
#[allow(dead_code)]
const EPS: f64 = 1.0e-10;
#[allow(dead_code)]
const MOD: i32 = 1000_000_007;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    #[allow(dead_code)]
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }

    #[allow(dead_code)]
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }

    #[allow(dead_code)]
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: i64 = sc.read();
    let max_r = 9 * (n + 1) - n;
    let mut min_r: i64 = i64::max_value();
    for a in 2..n+2 {
        if (a - 1) * (a - 1) > n {
            break;
        }
        if n % (a - 1) != 0 {
            continue;
        }
        let m = n / (a - 1);
        for b in 3..m+3 {
            if (b - 2) * (b - 2) > m {
                break;
            }
            if m % (b - 2) == 0 {
                let c = m / (b - 2) + 2;
                min_r = min(min_r, a * b * c - n);
            }
        }
    }

    println!("{} {}", min_r, max_r);
}


use std::io::Read;

fn main() {
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).expect("Err: read line failed");
    let vec = input.lines().map(|line| {
        line.trim().split_whitespace().map(|word| {
            word.parse::<i32>().expect("Err: parse to i32 failed")
        }).collect::<Vec<i32>>()
    }).collect::<Vec<Vec<i32>>>();

    for number in &vec[1] {
        for digit in &vec[2] {
            if digit == number {
                print!("{} ", &digit);
            }
        }
    }

    println!("");
}


// A. Fingerprints
// http://codeforces.com/problemset/problem/994/A

fn main() {
    let stdin = std::io::stdin();
    let mut buf = String::new();

    stdin.read_line(&mut buf).unwrap();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();

    let xs =
        buf.split_whitespace().filter_map(|s| s.parse::<i32>().ok());
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    let set: std::collections::HashSet<i32> =
        buf.split_whitespace().filter_map(|s| s.parse::<i32>().ok()).collect();

    xs.filter(|x| set.contains(&x)).for_each(|x| print!("{} ", x));
}


use std::io::{self, BufRead};
use std::collections::*; // HashSet, HashMap, BTreeSet, BTreeMap, ...

fn main() {
    let stdin: io::Stdin = io::stdin();
    let mut lines: io::Lines<io::StdinLock> = stdin.lock().lines();

    #[allow(unused_assignments)]
    let mut next_line = lines.next()
        .unwrap() // Option<Result> { Some(Result), None }
        .unwrap(); // Result<String, io::Error> { Ok(String), Err(io::Error) }

    next_line = lines.next()
        .unwrap() // Option<Result> { Some(Result), None }
        .unwrap(); // Result<String, io::Error> { Ok(String), Err(io::Error) }

    let flv: Vec<u32> = next_line
        .trim()
        .split(' ')
        .map(|n| {
            n.parse().unwrap()
        })
        .collect();

    next_line = lines.next()
        .unwrap() // Option<Result> { Some(Result), None }
        .unwrap(); // Result<String, io::Error> { Ok(String), Err(io::Error) }

    let slh: HashSet<u32> = next_line
        .trim()
        .split(' ')
        .map(|n| {
            n.parse::<u32>().unwrap()
        })
        .collect();

    let mut ans: String = String::new();

    for n in flv.iter() {
        if slh.contains(&n) {
            ans.push_str(" ");
            ans.push_str(&n.to_string());
        }
    }

    println!("{}", ans.trim());
}


// ---------- begin ModInt ----------
const MOD: u32 = 1_000_000_007;

#[derive(Clone, Copy)]
struct ModInt(u32);

impl std::ops::Add for ModInt {
    type Output = ModInt;
    fn add(self, rhs: ModInt) -> Self::Output {
        let mut d = self.0 + rhs.0;
        if d >= MOD {
            d -= MOD;
        }
        ModInt(d)
    }
}

impl std::ops::AddAssign for ModInt {
    fn add_assign(&mut self, rhs: ModInt) {
        *self = *self + rhs;
    }
}

impl std::ops::Sub for ModInt {
    type Output = ModInt;
    fn sub(self, rhs: ModInt) -> Self::Output {
        let mut d = self.0 + MOD - rhs.0;
        if d >= MOD {
            d -= MOD;
        }
        ModInt(d)
    }
}

impl std::ops::SubAssign for ModInt {
    fn sub_assign(&mut self, rhs: ModInt) {
        *self = *self - rhs;
    }
}

impl std::ops::Mul for ModInt {
    type Output = ModInt;
    fn mul(self, rhs: ModInt) -> Self::Output {
        ModInt((self.0 as u64 * rhs.0 as u64 % MOD as u64) as u32)
    }
}

impl std::ops::MulAssign for ModInt {
    fn mul_assign(&mut self, rhs: ModInt) {
        *self = *self * rhs;
    }
}

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

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

#[allow(dead_code)]
impl ModInt {
    pub fn new(n: u32) -> ModInt {
        ModInt(n % MOD)
    }
    pub fn zero() -> ModInt {
        ModInt(0)
    }
    pub fn one() -> ModInt {
        ModInt(1)
    }
    pub fn pow(self, mut n: u32) -> ModInt {
        let mut t = ModInt::one();
        let mut s = self;
        while n > 0 {
            if n & 1 == 1 {
                t *= s;
            }
            s *= s;
            n >>= 1;
        }
        t
    }
    pub fn inv(self) -> ModInt {
        self.pow(MOD - 2)
    }
}
// ---------- end ModInt ----------
// ---------- begin Precalc ----------
#[allow(dead_code)]
struct Precalc {
    inv: Vec<ModInt>,
    fact: Vec<ModInt>,
    ifact: Vec<ModInt>,
}

#[allow(dead_code)]
impl Precalc {
    pub fn new(n: usize) -> Precalc {
        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) {
            inv[i] = -inv[MOD as usize % i] * ModInt(MOD / i as u32);
            fact[i] = fact[i - 1] * ModInt(i as u32);
            ifact[i] = ifact[i - 1] * inv[i];
        }
        Precalc {
            inv: inv,
            fact: fact,
            ifact: ifact,
        }
    }
    pub fn inv(&self, n: usize) -> ModInt {
        self.inv[n]
    }
    pub fn fact(&self, n: usize) -> ModInt {
        self.fact[n]
    }
    pub fn ifact(&self, n: usize) -> ModInt {
        self.ifact[n]
    }
    pub fn comb(&self, n: usize, k: usize) -> ModInt {
        if k > n {
            return ModInt::zero();
        }
        self.fact[n] * self.ifact[k] * self.ifact[n - k]
    }
}
// ---------- end Precalc ----------

fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let n: usize = s.trim().parse().unwrap();
    let mut len = 0;
    while (2 << len) <= n {
        len += 1;
    }
    let mut cnt = vec![0; len + 2];
    for i in 0..=len {
        cnt[i] = n / (1 << i);
    }
    let mut dp = vec![ModInt::zero(); len + 2];
    dp[len] = ModInt::one();
    for i in 1..n {
        let mut next = vec![ModInt::zero(); len + 2];
        for j in 0..len {
            if cnt[j] > i {
                next[j] += dp[j] * ModInt((cnt[j] - i) as u32);
                next[j] += dp[j + 1] * ModInt((cnt[j] - cnt[j + 1]) as u32);
            }
        }
        dp = next;
    }
    let mut ans = dp[0];
    if (1 << len) / 2 * 3 <= n {
        let len = len - 1;
        let mut cnt = vec![vec![0; len + 2]; 2];
        for i in 0..=len {
            cnt[0][i] = n / (1 << i);
            cnt[1][i] = n / (1 << i) / 3;
        }
        let mut dp = vec![vec![ModInt::zero(); len + 2]; 2];
        dp[1][len] = ModInt::one();
        for i in 1..n {
            let mut next = vec![vec![ModInt::zero(); len + 2]; 2];
            for j in 0..=len {
                if cnt[0][j] > i {
                    next[0][j] += dp[0][j] * ModInt((cnt[0][j] - i) as u32);
                    next[0][j] += dp[1][j] * ModInt((cnt[0][j] - cnt[1][j]) as u32);
                    next[0][j] += dp[0][j + 1] * ModInt((cnt[0][j] - cnt[0][j + 1]) as u32);
                }
                if cnt[1][j] > i {
                    next[1][j] += dp[1][j] * ModInt((cnt[1][j] - i) as u32);
                    next[1][j] += dp[1][j + 1] * ModInt((cnt[1][j] - cnt[1][j + 1]) as u32);
                }
            }
            dp = next;
        }
        ans += dp[0][0];
    }
    println!("{}", ans.0);
}

fn main() {
    run();
}


fn read_line() -> String {
    let mut line = String::new();
    std::io::stdin()
        .read_line(&mut line)
        .expect("Could not read line");
    String::from(&line[..line.len() - 1])
}

macro_rules! read_line {
    ([$t: ty]) => {{
        read_line().split_whitespace().map(|token| {
            <$t as std::str::FromStr>::from_str(token).expect(
                &format!(concat!("Could not parse {} into ", stringify!($t)), token))
        })
    }};
    ($($t: ty),*) => {{
        let line = read_line();
        let mut iter = line.split_whitespace();
        ($({
            let token = iter.next().expect("Not enough tokens");
            <$t as std::str::FromStr>::from_str(token).expect(
                &format!(concat!("Could not parse {} into ", stringify!($t)), token))
        }),*)
    }};
}

fn main() {
    read_line!(usize);
    enum State {
        Up,
        Hold,
        Down,
    }
    let mut state = State::Up;
    let mut prev = 0;
    let mut ans = true;
    for x in read_line!([u16]) {
        match state {
            State::Hold => {
                if x > prev {
                    ans = false;
                    break;
                }
            }
            State::Down => {
                if x >= prev {
                    ans = false;
                    break;
                }
            }
            State::Up => {}
        }
        state = if x < prev {
            State::Down
        } else if x > prev {
            State::Up
        } else {
            State::Hold
        };
        prev = x;
    }
    println!("{}", if ans { "YES" } else { "NO" });
}


use std::error::Error;
use std::io;
use std::process;

fn main() {
    if let Err(e) = run() {
        println!("{}", e);
        process::exit(1);
    }
}

fn run() -> Result<(), Box<Error>> {
    let mut n = String::new();
    io::stdin().read_line(&mut n)?;
    let mut n: usize = n.trim().parse()?;
    let mut a = String::new();
    io::stdin().read_line(&mut a)?;
    let mut a: Vec<&str> = a
        .trim()
        .split(" ")
        .collect();
    let mut cur = 0;
    let mut pre = 0;
    let mut inc = false;
    let mut con = false;
    let mut dec = false;
    for i in 0..n {
        if i == 0 {
            cur = a[i].parse()?;
            continue;
        }
        pre = cur;
        cur = a[i].parse()?;
        if pre < cur {
            if con || dec {
                println!("NO");
                return Ok(());
            }
            inc = true;
        } else if pre == cur {
            if dec {
                println!("NO");
                return Ok(());
            }
            con = true;
        } else {
            dec = true;
        }
    }
    println!("YES");
    Ok(())
}


fn main() {
    let mut input = String::new();

    use std::io::stdin;

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

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

    let a: Vec<u32> = input.split_whitespace().map(|c| c.parse().unwrap()).collect();

    let cnt = a.iter().skip(1).zip(a.iter()).skip_while(|&(b, a)| b > a).skip_while(|&(b, a)| b == a).skip_while(|&(b, a)| b < a).count();

    if cnt > 0 {
        println!("NO");
    } else {
        println!("YES");
    }
}


use std::collections::VecDeque;

fn main() {
    let m: f32 = get_input().split_ascii_whitespace().last().unwrap().parse().unwrap();
    let children: Vec<f32> = get_input().split_ascii_whitespace().map(|v| v.parse().unwrap()).collect();

    let mut max = 0f32;
    let candies: Vec<Candy> = children.iter().enumerate().map(|(index, value)| {
        let candy = Candy::new((value / m).ceil(), index + 1);
        if candy.value > max {
            max = candy.value;
        }
        candy
    }).collect();

    let mut iter = candies.iter();
    let mut next_from_back = iter.next_back().unwrap();

    while next_from_back.value != max {
        next_from_back = iter.next_back().unwrap();
    }

    println!("{:?}", next_from_back.index);
}

fn get_input() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).expect("Failed");
    buffer.trim().to_owned()
}

fn get_input_usize() -> usize {
    get_input().parse().unwrap()
}

#[derive(Debug)]
struct Candy {
    value: f32,
    index: usize,
}

impl Candy {
    pub fn new(value: f32, index: usize) -> Self {
        Candy {
            value,
            index
        }
    }
}


//spnauti-rust
use std::io::*;
use std::str::*;
use std::fmt::Debug;
#[allow(unused_imports)] use std::cmp::Ordering::{self,*};
#[allow(unused_imports)] use std::ops::*;
#[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).ok();
        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 = input.u();
    let m = input.i();
    let (a,_) = input.vi(n).into_iter().map(|x| (x + m - 1) / m).
        enumerate().fold((0,0), |(a,x),(b,y)| {
            if x > y { (a,x) } else { (b,y) }
        });
    println!("{}", a + 1);
}


use std::collections::VecDeque;

fn main() {
    let m: i32 = get_input().split_ascii_whitespace().last().unwrap().parse().unwrap();
    let children: Vec<i32> = get_input().split_ascii_whitespace().map(|v| v.parse().unwrap()).collect();

    let candies: Vec<Candy> = children.iter().enumerate().map(|(index, value)| {
        let candy = Candy::new(*value, index + 1);
        candy
    }).collect();

    let mut stack = VecDeque::new();

    for candy in candies {
        stack.push_back(candy);
    };

    while stack.len() > 1 {
        let next = stack.pop_front().unwrap();
        let temp = next.value - m;

        if temp > 0 {
            stack.push_back(Candy::new(temp, next.index));
        }
    }

    println!("{}", stack.pop_front().unwrap().index);
}

fn get_input() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).expect("Failed");
    buffer.trim().to_owned()
}

fn get_input_usize() -> usize {
    get_input().parse().unwrap()
}

#[derive(Debug)]
struct Candy {
    value: i32,
    index: usize,
}

impl Candy {
    pub fn new(value: i32, index: usize) -> Self {
        Candy {
            value,
            index
        }
    }
}


use std::io::*;

fn reads<T: std::str::FromStr>(i: &mut StdinLock) -> Vec<T> {
    let mut s = String::new();
    i.by_ref().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn gcd_worker(a: u64, b: u64) -> u64 {
    match b {
        0 => a,
        _ => gcd_worker(b, a % b),
    }
}

fn gcd(a: u64, b: u64) -> u64 {
    let greater = std::cmp::max(a, b);
    let smaller = std::cmp::min(a, b);
    gcd_worker(greater, smaller)
}

fn main() {
    // initialize stdin
    let sin = std::io::stdin();
    let mut sin = sin.lock();
    let sin = &mut sin;

    let params: Vec<u64> = reads(sin);

    let a = params[0];
    let b = params[1];
    let heap = params[2];

    let mut remain = heap;
    let mut turn_of_antisimon = false;

    loop {
        let have_to_take = gcd(if turn_of_antisimon { b } else { a }, remain);
        if remain < have_to_take {
            break;
        }

        remain = remain - have_to_take;
        turn_of_antisimon = !turn_of_antisimon;
    }

    println!("{}", if turn_of_antisimon { 0 } else { 1 });
}


fn readln() -> Vec<i32> {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();

    line.split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect()
}

fn gcd(mut a :  i32, mut b : i32) -> i32 {
    while a > 0 && b > 0 {
        if a > b {
            a %= b;
        }
        else {
            b %= a;
        }
    }
    a + b
}

fn main() {
    let input = readln();

    let a = input[0];
    let b = input[1];
    let mut n = input[2];

    let mut cnt = 0;
    while n > 0 {
        if cnt % 2 == 0 {
            n -= gcd(a, n);
        }
        else {
            n -= gcd(b, n);
        }
        cnt += 1;
    }

    println!("{}", if cnt % 2 == 1 {0} else {1});
}


//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 }
    }};
}
struct WordReader {
    it : std::vec::IntoIter<String>,
}
#[allow(dead_code)]
impl WordReader {
    fn new<T: std::io::Read>(mut reader: T) -> WordReader {
        let mut s = String::new();
        reader.read_to_string(&mut s).unwrap();
        WordReader {
            it : s.split_ascii_whitespace().map(String::from)
            .collect::<Vec<_>>().into_iter()
        }
    }
    fn from_stdin() -> WordReader {
        WordReader::new(std::io::stdin())
    }
    fn s(&mut self) -> String {
        self.it.next().unwrap()
    }
    fn ab(&mut self) -> Vec<u8> {
        self.it.next().unwrap().into_bytes()
    }
    fn i(&mut self) -> i32 {
        self.it.next().unwrap().parse().unwrap()
    }
    fn ai(&mut self, n: usize) -> Vec<i32> {
        let mut a = Vec::with_capacity(n);
        for _ in 0..n { a.push(self.i()); }
        a
    }
}

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

fn main() {
    let mut input = WordReader::from_stdin();
    let a = input.i();
    let b = input.i();
    let x = [b, a];
    let mut n = input.i();
    let mut t: usize = 1;
    while n > 0 {
        n -= gcd(n, x[t]);
        t = 1 - t;
    }
    println!("{}", t);
}


use std::io;
fn pgcd(mut a:i8,mut b:i8) -> i8 {
    while (a != b){
        if a > b {
            a = a -b;

        }else{
            b = b - a;
        }}
    return a;
}
fn main() {
    let mut line = String::new();
    io::stdin()
        .read_line(&mut line)
        .expect("error");

    let line: String = line.trim().parse().expect("no");
    let inputs: Vec<i8> = line.split(" ")
        .map(|x| x.parse().expect("Not an integer!"))
        .collect();
    let mut pgcd_a;
    let mut pgcd_b;

    let (mut a, mut b, mut n) = (inputs[0], inputs[1], inputs[2]);
    loop {
          pgcd_a = pgcd(a, n); // 3,9 => 3
        //println!("{}",pgcd_a);
        n = n -pgcd_a;  // 9 - 3 = 6
        if pgcd_a > n {
            println!("0");
            break;
        }
         pgcd_b = pgcd(b,n); // 5,6 => 1
        //println!("{}",pgcd_b);

        n = n-pgcd_b;
        if pgcd_b > n {
            println!("1");
            break;
        }

    }
}


#![allow(non_snake_case, unused_imports, deprecated, dead_code)]

// Input macros
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)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $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, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{VecDeque,HashMap,HashSet,BTreeMap,BTreeSet,BinaryHeap};
// Module for v1.15.1
use std::ascii::AsciiExt; // deprecated since 1.26.0: use inherent method instead

// Functions
fn gcd(a: u64, b: u64) -> u64 {
    assert!(a != 0 || b != 0);
    if a == 0 {
        return b;
    }
    else {
        return gcd(b%a, a);
    }
}

// Main
fn main() {

    input! {
        A: u64,
        B: u64,
        mut N: u64,
    }

    let mut turn = 0;
    let stones = vec![A,B];
    loop {
        let d = gcd(stones[turn], N);
        if N > d {
            N -= d;
            turn = 1-turn;
        } else if N==d {
            turn = 1-turn;
            break;
        } else {
            break;
        }
    }

    println!("{}", 1-turn);
}


//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 }
    }};
}
struct WordReader {
    it : std::vec::IntoIter<String>,
}
#[allow(dead_code)]
impl WordReader {
    fn new<T: std::io::Read>(mut reader: T) -> WordReader {
        let mut s = String::new();
        reader.read_to_string(&mut s).unwrap();
        WordReader {
            it : s.split_ascii_whitespace().map(String::from)
            .collect::<Vec<_>>().into_iter()
        }
    }
    fn from_stdin() -> WordReader {
        WordReader::new(std::io::stdin())
    }
    fn s(&mut self) -> String {
        self.it.next().unwrap()
    }
    fn ab(&mut self) -> Vec<u8> {
        self.it.next().unwrap().into_bytes()
    }
    fn i(&mut self) -> i32 {
        self.it.next().unwrap().parse().unwrap()
    }
    fn ai(&mut self, n: usize) -> Vec<i32> {
        let mut a = Vec::with_capacity(n);
        for _ in 0..n { a.push(self.i()); }
        a
    }
}

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

fn main() {
    let mut input = WordReader::from_stdin();
    let a = input.i();
    let b = input.i();
    let mut n = input.i();
    let mut t = 1;
    while n > 0 {
        if t == 1 {
            n -= gcd(a,n);
        } else {
            n -= gcd(b,n);
        }
        t = 1 - t;
    }
    println!("{}", t);
}


fn gcd(a: i32, b: i32) -> i32 {
    let (mut a, mut b) = if a > b { (b, a) } else { (a, b) };
    while a != 0 {
        let tmp = a;
        a = b % a;
        b = tmp;
    }
    return b;
}

fn main() {
    let v: Vec<i32> = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().split(" ").map(|s| s.parse::<i32>().unwrap()).collect()
    };
    let (a, b, mut n) = (v[0], v[1], v[2]);

    loop {
        n -= gcd(a, n);
        if n == 0 {
            println!("0");
            break;
        }
        n -= gcd(b, n);
        if n == 0 {
            println!("1");
            break;
        }
    }
}


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_ts<T : FromStr>(stdin : &Stdin, ts : &mut Vec<T>) {
    let mut line = String::new();
    read_line(stdin, &mut line);
    let word_iter = line.split_whitespace();
    for word in word_iter {
        let x = parse_t(word);
        ts.push(x);
    }
}

fn gcd(x : usize, y : usize) -> usize {
    if x == 0 {
        y
    } else if x <= y {
        let r = y % x;
        gcd(r, x)
    } else {
        gcd(y, x)
    }
}

fn main() {
    let stdin = io::stdin();
    let mut a_b_n : Vec<usize> = vec![];
    read_ts(&stdin, &mut a_b_n);
    let a = a_b_n[0];
    let b = a_b_n[1];
    let n = a_b_n[2];
    let mut num_stones = n;
    let mut player = 0;
    loop {
        if player == 0 {
            let g = gcd(a, num_stones);
            if num_stones < g {
                println!("1");
                break;
            } else {
                player = 1;
                num_stones = num_stones - g;
            }
        } else {
            let g = gcd(b, num_stones);
            if num_stones < g {
                println!("0");
                break;
            } else {
                player = 0;
                num_stones = num_stones - g;
            }
        }
    }
}


#![allow(unused_imports)]
use std::io::{self, BufRead};
use std::cmp::*;
use std::collections::*;

macro_rules! scan_to_vec {
    ($count:expr, $t:ty) => ({
        let mut result = Vec::new();
        let stdin = io::stdin();
        let mut handle = stdin.lock();

        for _ in 0..$count {
            let mut buffer = String::new();
            handle.read_line(&mut buffer)
                .expect("scan_to_vec: failed at `handle.read_line`.");
            result.push(buffer.trim().parse::<$t>()
                .expect("scan_to_vec: failed at `parse::<$t>`."));
        }
        result
    })
}

macro_rules! scan_line_to_vec {
    ($t:ty) => ({
        let mut result = Vec::new();
        let stdin = io::stdin();
        let mut handle = stdin.lock();
        handle.read_line(&mut buffer)
            .expect("scan_line_to_vec: failed at `handle.read_line`.");

        for s in chunks.split_whitespace() {
            result.push(s.parse::<$t>()
                .expect("scan_line_to_vec: failed at `parse::<$t>`."));
        }
        result
    })
}

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 (n,) = scan_line!(i64);

    if n % 2 == 0 {
        let result = n / 2 - 1;
        println!("{}", result);
    } else {
        let result = (n + 1) / 2 - 1;
        println!("{}", result);
    }
}


//spnauti-rust
use std::io::*;
use std::str::*;
use std::fmt::Debug;
#[allow(unused_imports)] use std::cmp::Ordering::{self,*};
#[allow(unused_imports)] use std::ops::*;
#[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).ok();
        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);

    println!("{}", (input.i() - 1) / 2);
}


//#[derive(Debug)]

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

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

    #[allow(dead_code)]
    pub fn p<T>(t: T)
        where
            T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
        where
            T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
        where
            T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
        where
            T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}
use input::*;

fn main() {
    let mut n:i32;
    let mut ans:i32 = 1;

    input!(n);
    while n>=10
    {
        ans+=10-n%10;
        n/=10;n+=1;
        while n%10==0 {n/=10;}
    }

    p(ans+8);
}


#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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")
    };
}

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

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

#[allow(unused_imports)]
use std::io::Write;
type I = usize;

fn f(i: u64) -> u64 {
    let ss = (i+1).to_string();
    let ss: Vec<char> = ss.chars().collect();
    let mut index = ss.len();
    for i in (0..ss.len()).rev() {
        if ss[i] == '0' {
            index = i;
        } else {
            break;
        }
    }
    let ret = &ss[0..index];
    let ret: String = ret.iter().collect();
    return ret.parse().unwrap();
}

fn main() {
    input!{
      mut n: u64,
    }
    let mut seen = std::collections::HashMap::new();

    let mut ans = 0;
    while !seen.contains_key(&n) {
        ans += 1;
        seen.insert(n, true);
        n = f(n);
    }
    println!("{}", ans);
}


fn main() {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).expect("INPUT::Read line failed");

    let number = input.trim().parse::<i32>().expect("NUMBER::Parse to i32 failed");

    let mut vec = vec![];
    vec.push(number);
    let mut fx = function(number);
    let mut is_repeats = is_repeat(&vec, fx);

    while !is_repeats {
        vec.push(fx);
        fx = function(fx);
        is_repeats = is_repeat(&vec, fx);

    }

    println!("{}",vec.len());
}

fn function(number : i32) -> i32 {
    let mut number = number + 1;

    let mut last_number = number % 10;

    while last_number == 0 {
        number /= 10;
        last_number = number % 10;
    }

    number

}

fn is_repeat(vec : &Vec<i32>, fx:i32) -> bool {
    let mut is_repeat = false;

    for i in 0..vec.len() {
        if fx == vec[i] {
            is_repeat = true;
            break;
        }

    }
    is_repeat
}


//#[derive(Debug)]

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

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

    #[allow(dead_code)]
    pub fn p<T>(t: T)
        where
            T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
        where
            T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
        where
            T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
        where
            T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}
use input::*;
use std::collections::HashSet;

fn main() {
    let mut n: i32;
    let mut set = HashSet::new();

    input!(n);
    set.insert(n);
    while n > 0 {
        n += 1;
        while n % 10 == 0 {
            n /= 10;
        }
        if set.contains(&n) {
            break;
        }
        set.insert(n);
    }
    p(set.len());
}


use std::io::{Read,stdin};
use std::collections::HashSet;

fn main() {
    let mut buf = String::new();
    stdin().read_to_string(&mut buf).unwrap();
    let mut tok = buf.split_whitespace();
    let mut get = || tok.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }

    let mut n = get!(u64);
    let mut hs = HashSet::new();
    loop {
        if !hs.insert(n) {
            break;
        }
        n = f(n);
    }
    println!("{:?}", hs.len());
}

fn f(n: u64) -> u64 {
    let mut r = n + 1;
    while r % 10 == 0 {
        r /= 10;
    }
    r
}


use std::io::{self, prelude::*};
use std::str;
use std::collections::HashSet;

struct Scanner<R> {
    reader: R,
    buf_str: Vec<u8>,
    buf_iter: str::SplitWhitespace<'static>,
}
impl<R: io::BufRead> Scanner<R> {
    fn new(reader: R) -> Self {
        Self { reader, buf_str: Vec::new(), buf_iter: "".split_whitespace() }
    }
    fn next<T: str::FromStr>(&mut self) -> T {
        loop {
                if let Some(token) = self.buf_iter.next() {
                    return token.parse().ok().expect("Failed parse");
                }
                self.buf_str.clear();
                self.reader.read_until(b'\n', &mut self.buf_str).expect("Failed read");
                self.buf_iter = unsafe {
                    let slice = str::from_utf8_unchecked(&self.buf_str);
                    std::mem::transmute(slice.split_whitespace())
            }
        }
    }
}

fn main() {

    let (stdin, stdout) = (io::stdin(), io::stdout());
    let mut scan = Scanner::new(stdin.lock());
    let mut out = io::BufWriter::new(stdout.lock());

    let mut n = scan.next::<i32>();
    let mut set = HashSet::new();

    while set.insert(n) {
        n+=1;
        while n%10==0 {
            n/=10;
        }
    }
    println!("{}", set.len());
}


use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input)
        .expect("error");
    let mut input = input.trim().parse().expect("error not a number ");
    let mut ans = 9 ;
    while input > 9
        {
            ans += 1 ;
            input = f(input)
        }

    print!("{}",ans);
}

fn f(x: u32) -> u32 {
    let mut y = x + 1;
    while y % 10 == 0
        {
            y = y / 10
        }
    return y;
}


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 resolve(hy: i64, ay: i64, dy: i64, hm: i64, am: i64, dm: i64) -> bool {
    let ay = ay - dm;
    let am = am - dy;
    if ay <= 0 {
        return false;
    }
    if am <= 0 {
        return true;
    }
    let yt = (hy - 1) / am;
    let mt = (hm - 1) / ay;
    yt > mt
}

fn solve() {
    let (hy, ay, dy) = parse_line!(i64, i64, i64);
    let (hm, am, dm) = parse_line!(i64, i64, i64);
    let (h, a, d) = parse_line!(i64, i64, i64);
    let mut ans = std::i64::MAX;
    for aadd in 0..500 {
        for dadd in 0..500 {
            let ay = ay + aadd;
            let dy = dy + dadd;
            let mut l: i64 = -1;
            let mut r: i64 = 100001;
            while r - l > 1 {
                let m = (l + r) / 2;
                let hy = hy + m;
                if resolve(hy, ay, dy, hm, am, dm) {
                    r = m;
                }else{
                    l = m;
                }
            }
            let cost = aadd * a + dadd * d + r * h;
            ans = std::cmp::min(ans, cost);
        }
    }
    println!("{}", ans);
}

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


// ---------- begin input macro ----------
// reference: 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")
    };
}
// ---------- end input macro ----------

use std::cmp::*;

fn run() {
    input! {
        yang: (i64, i64, i64),
        mons: (i64, i64, i64),
        h: i64,
        a: i64,
        d: i64,
    }
    let win = |h: i64, a: i64, b: i64| -> bool {
        let yang = (yang.0 + h, yang.1 + a, yang.2 + b);
        let x = max(yang.1 - mons.2, 0);
        if x <= 0 {
            return false;
        }
        let y = max(mons.1 - yang.2, 0);
        if y <= 0 {
            return true;
        }
        let a = (yang.0 + y - 1) / y;
        let b = (mons.0 + x - 1) / x;
        a > b
    };
    // DEFを100, ATK を100買えば勝てる、これ以下
    let mut ans = 100 * a + 100 * d;
    for i in 0..=21000 {
        if i * h > ans {
            break;
        }
        for j in 0..=200 {
            if j * a > ans - i * h {
                break;
            }
            for k in 0..=200 {
                if win(i, j, k) {
                    ans = min(ans, i * h + j * a + k * d);
                }
            }
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


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();
    // e.g: 3 -> 3 + (2*(2-1)+1) + 1
    // e.g: 4 -> 4 + 3 + 2 + 1 =
    let n: isize = scan.next();
    if n == 1 {
        println!("1");
        return;
    }
    let mut result: isize = n + 1;
    let mut i = n-1;
    while i >= 2 {
        result += i*(n-i) + 1;
        i -= 1;
    }
    println!("{}", result);
}

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


// {{{ 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 (n, ) = R!(usize);
    let mut ans = 0;
    for i in 1..n {
        ans += (n-i) * i;
    }
    println!("{}", ans + n);

}


use std::io;

fn read_line<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut input = String::new();
    io::stdin()
        .read_line(&mut input)
        .expect("Error reading line");

    input
        .trim()
        .split_ascii_whitespace()
        .map(|e| e.parse().ok().expect("Parsing error"))
        .collect()
}

fn main() {
    let mut n = read_line::<i32>()[0];

    if n == 1 {
        println!("1");
    } else {
        let mut sum = n;
        let mut button = 2;
        n = n - 1;
        while n > 1 {
            sum += 1 + button * (n - 1);
            n -= 1;
            button += 1;
        }
        sum += 1;
        println!("{}", sum);
    }
}


//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 }
    }};
}
struct WordReader {
    it : std::vec::IntoIter<String>,
}
#[allow(dead_code)]
impl WordReader {
    fn new<T: std::io::Read>(mut reader: T) -> WordReader {
        let mut s = String::new();
        reader.read_to_string(&mut s).unwrap();
        WordReader {
            it : s.split_ascii_whitespace().map(String::from)
            .collect::<Vec<_>>().into_iter()
        }
    }
    fn from_stdin() -> WordReader {
        WordReader::new(std::io::stdin())
    }
    fn s(&mut self) -> String {
        self.it.next().unwrap()
    }
    fn ab(&mut self) -> Vec<u8> {
        self.it.next().unwrap().into_bytes()
    }
    fn i(&mut self) -> i32 {
        self.it.next().unwrap().parse().unwrap()
    }
    fn ai(&mut self, n: usize) -> Vec<i32> {
        let mut a = Vec::with_capacity(n);
        for _ in 0..n { a.push(self.i()); }
        a
    }
}

fn main() {
    let mut input = WordReader::from_stdin();
    let n = input.i();
    let sol = n + (1..n).zip((1..n).rev())
        .fold(0, |c,(a,b)| a * b + c);
    println!("{}", sol);
}


//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")
    };
}

//

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

fn lcm(a: u64, b: u64) -> u64 {
    if a == 0 || b == 0 {
        a + b
    } else {
        a / gcd(a, b) * b
    }
}

fn run() {
    input! {
        w: u64,
        c: [u64; 8],
    }
    let m = (1..=8).fold(0, |s, a| lcm(s, a));
    let mut ans = 0;
    let mut w = w;
    let mut c = c;
    for (i, c) in c.iter_mut().enumerate() {
        let k = (i + 1) as u64;
        let v = m / k;
        let q = *c / v;
        let d = std::cmp::min(w / m * m, q * v * k);
        ans += d;
        w -= d;
        *c -= d / k;
        if *c > v {
            *c = v;
        }
    }
    if w >= 8 * m {
        ans += c.iter().enumerate().fold(0, |s, (i, c)| s + (i + 1) as u64 * c);
    } else {
        let w = w as usize;
        let mut dp = vec![false; w + 1];
        dp[0] = true;
        for (i, &c) in c.iter().enumerate() {
            let k = i + 1;
            for _ in 0..c {
                for j in (k..=w).rev() {
                    dp[j] |= dp[j - k];
                }
            }
            println!();
        }
        ans += dp.iter().rposition(|p| *p).unwrap() as u64;
    }
    println!("{}", ans);
}

fn main() {
    run();
}


#![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),*) => { trace!(($($args),*)) }
}

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

fn gcd(a: u64, b: u64) -> u64 { if b == 0 { a } else { gcd(b, a % b) } }
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 mut divs = vec![];
    for i in 1..y {
        if i * i > y {
            break
        } else if i * i == y {
            divs.push(i);
        } else if y % i == 0 {
            divs.push(i);
            divs.push(y/i);
        }
    }
    // trace!(divs);

    let mut ans = 0;
    for k in divs.iter() {
        let a = k * x;
        let b = y / k;
        if l <= a && a <= r && l <= b && b <= r && gcd(a, b) == x {
            ans += 1;
        }
    }
    put!(ans);
}

#[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")
        }
    }
}


use std::io::prelude::*;
use std::io;
use std::str::FromStr;
#[cfg(local)]
use std::fs::File;
#[cfg(local)]
use std::io::BufReader;

#[cfg(local)]
fn buf_read() -> io::Result<(Vec<String>)> {
    let f = try!(File::open("input.txt"));
    let input_lines: Vec<_> = BufReader::new(f).lines().collect();
    let lines: Vec<String> = input_lines.into_iter().map(|e| e.unwrap()).collect();
    Ok((lines))
}

#[cfg(not(local))]
fn buf_read() -> io::Result<(Vec<String>)> {
    let stdin = io::stdin();
    let input_lines: Vec<_> = stdin.lock().lines().collect();
    let lines: Vec<String> = input_lines.into_iter().map(|e| e.unwrap()).collect();
    Ok((lines))
}

fn main() {
    type Element = u32;
    let input = buf_read().unwrap();
    let mut input_vectors: Vec<Vec<Element>> = vec![];
    for input_line in input {
        let input_str: Vec<String> = input_line.split(' ').map(String::from).collect();
        let mut input_vector: Vec<Element> = vec![];
        for input_elem_str in input_str {
            let elem: Element = Element::from_str(input_elem_str.as_str()).unwrap();
            input_vector.push(elem);
        }
        input_vectors.push(input_vector);
    }
    let input = input_vectors[0][0];
    if input == 0 {
        println!("1");

    } else {
        match input % 4 {
            1 => println!("8"),
            2 => println!("4"),
            3 => println!("2"),
            _ => println!("6"),
        }
    }
}


#[allow(unused_imports)]
use std::io;
use std::cmp::{min, max};
pub struct Scanner<B> {
    reader: B,
    buffer: Vec<String>,
}

impl<B: io::BufRead> Scanner<B> {
    pub fn new(reader: B) -> Scanner<B> {
        Scanner {
            reader: reader,
            buffer: Vec::new(),
        }
    }

    /// Use "turbofish" syntax next::<T>() to select data type of next token.
    pub fn next<T: ::std::str::FromStr>(&mut self) -> T
        where
            T::Err: ::std::fmt::Debug,
    {
        if let Some(front) = self.buffer.pop() {
            front.parse::<T>().expect(&front)
        } else {
            let mut input = String::new();
            self.reader.read_line(&mut input).expect("Line not read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
            self.next()
        }
    }

    pub fn next_vec<T: ::std::str::FromStr>(&mut self, len: usize) -> Vec<T>
        where
            T::Err: ::std::fmt::Debug,
    {
        (0..len).map(|_| self.next::<T>()).collect::<Vec<T>>()
    }
}

fn main1() {
    let stdin = io::stdin();
    let mut input = Scanner::new(stdin.lock());
    let mut n = input.next::<i64>();
    if n == 0 {
        println!("1");
        return;
    }
    n %= 4;
    let mut answer = 6;
    for _ in 0..n {
        answer = answer * 8 % 10;
    }
    println!("{}", answer);

}

fn main() {
    std::thread::Builder::new().stack_size(50 << 20)
        .spawn(main1).unwrap().join().unwrap();
}


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 pattern = [8, 4, 2, 6];
    println!("{}", if n==0 {1} else {pattern[(n-1)%4]});
}

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


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

#[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 n = readln!(i32);
    let aaa = vec![6,8,4,2];
    let ans : i32 = if n == 0 { 1 } else {aaa[(n%4) as usize]};
    println!("{}",ans);
}


//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();
    println!("{}", if n == 0 {
        1
    } else {
        [6,8,4,2][(n % 4) as usize]
    });
}


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

pub struct Scanner<R> {
    reader: R,
    buffer: Vec<String>,
}

impl<R: io::BufRead> Scanner<R> {
    pub fn new(reader: R) -> Self {
        Self {
            reader,
            buffer: vec![],
        }
    }

    pub fn token<T: str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            self.reader.read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn solve<R: io::BufRead, W: io::Write>(scan: &mut Scanner<R>, out: &mut W) {
    let n: u32 = scan.token();
    let ans = if n == 0 {
        1
    } else if n % 4 == 0 {
        6
    } else if n % 4 == 1 {
        8
    } else if n % 4 == 2 {
        4
    } else if n % 4 == 3 {
        2
    } else {
        1
    };
    writeln!(out, "{}", ans).ok();
}

fn main() {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let mut scan = Scanner::new(stdin.lock());
    let mut out = io::BufWriter::new(stdout.lock());
    solve(&mut scan, &mut out);
}


use std::io::*;

fn read<T: std::str::FromStr>(i: &mut StdinLock) -> T {
    let mut s = String::new();
    i.by_ref().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    // initialize stdin
    let sin = std::io::stdin();
    let mut sin = sin.lock();
    let sin = &mut sin;

    let positions: String = read(sin);

    if positions.contains("01111111")
        || positions.contains("11111110")
        || positions.contains("10000000")
        || positions.contains("00000001")
    {
        println!("YES");
    } else {
        println!("NO");
    }
}


fn main() {
    // The input binary string
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();

    let mut cnt: [i32; 2] = [0, 0];
    let mut ind: usize = 0;

    for c in s.trim().chars() {
        if 7 <= cnt[ind] {
            break;
        }

        if (c as usize) - ('0' as usize) == ind {
            cnt[ind] += 1;
        } else {
            ind = (c as usize) - ('0' as usize);
            cnt[ind] = 1;
        }
    }

    // Display results
    if cnt[ind] >= 7 {
        println!("YES");
    } else {
        println!("NO");
    }
}


use std::io::{self, Write};
use std::string::String;

fn get_input() -> String {
    let mut buffer = String::new();
    io::stdin().read_line(&mut buffer).expect("Failed");
    return buffer.trim().to_string();
}

fn main() {
    let input: String = get_input();
    if input.contains("1111111") || input.contains("0000000") {
        println!("YES");
    } else {
        println!("NO");
    }
    io::stdout().flush().unwrap();
}


use std::io::{self, prelude::*};
use std::str;
use std::string::String;
use std::vec::Vec;

#[allow(unused_must_use)]
fn run<B: BufRead, W: Write>(mut reader: Scanner<B>, mut writer: W) {
    let input: String = reader.next_line();
    if input.contains("0000000") || input.contains("1111111") {
        writeln!(writer, "YES");
    } else {
        writeln!(writer, "NO");
    }
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();

    let reader = Scanner::new(stdin.lock());
    let writer = io::BufWriter::new(stdout.lock());
    run(reader, writer);
    io::stdout().flush().unwrap();
}

pub struct Scanner<B> {
    reader: B,
    buffer_string: Vec<u8>,
    buffer_iterator: str::SplitWhitespace<'static>,
}

impl <B: BufRead> Scanner<B> {
    pub fn new(reader: B) -> Self {
        return Self {
            reader,
            buffer_string: Vec::new(),
            buffer_iterator: "".split_whitespace()
        };
    }

    pub fn next<T: str::FromStr>(&mut self) -> T {
        loop {
            //if buffer already exists, just use existing buffer
            if let Some(token) = self.buffer_iterator.next() {
                return token.parse().ok().expect("Fail to parse token");
            }

            //get new line
            self.buffer_string.clear();
            self.reader.read_until(b'\n', &mut self.buffer_string).expect("Failed to read");

            //split by white space
            self.buffer_iterator = unsafe {
                let slice = str::from_utf8_unchecked(&self.buffer_string);
                std::mem::transmute(slice.split_whitespace())
            };
        }
    }

    pub fn next_line(&mut self) -> String {
        //reset buffer
        self.buffer_iterator = "".split_whitespace();
        self.buffer_string.clear();

        let mut input: String = String::new();
        self.reader.read_line(&mut input).expect("Failed to read line");
        return input.trim().to_string();
    }
}


use std::io;

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

    io::stdin().read_line(&mut input)?;
    let mut counter: i8 = 0;
    let mut current: char = '1';
    for player in input.trim().chars(){
        if player != current{
            current = player;
            counter = 1;
            continue;
        }
        counter += 1;
        if counter >= 7 {
            println!("YES");
            return Ok(());
        }
    };

    println!("NO");

    return Ok(());
}


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

    let mut cnt0 = 0;
    let mut cnt1 = 0;
    let mut ans = "NO";
    for ch in line.chars() {
        if ch == '0' {
            cnt0 += 1;
            cnt1 = 0;
        }
        else {
            cnt1 += 1;
            cnt0 = 0;
        }

        if cnt0 >= 7 || cnt1 >= 7 {
            ans = "YES";
            break;
        }
    }

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


fn main() {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line);
    let mut line: String = line.trim().to_string();
    line.push('y');
    let mut iter = line.chars();

    let (total, _, _) = iter.fold((0, 0, 'x'), |(total, current, prev), p| if prev == 'x' {
        (0, 1, p)
    } else if p == prev {
        (total, current + 1, p)
    } else {
        (std::cmp::max(total, current), 1, p)
    });
    println!("{}", if total >= 7 { "YES" } else { "NO" });
}


use std::io;
fn main() {
    let input = read();
    let mut val = 'a';
    let mut count = 1;
    let mut danger = 0;
    for d in input.chars(){
        if d == val{
            count += 1;
            if count == 7 {
                danger = 1;
                break;
            }
        }
        else {
            count = 1;
            val = d;
        }
    }
    if danger == 1{
        println!("YES");
    }
    else{
        println!("NO");
    }
}
fn read() -> String{
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    input.trim().parse::<String>().unwrap()
}


#[allow(unused_imports)]
use std::io::{stdin, Read, StdinLock};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::{HashSet, HashMap, BinaryHeap};
#[allow(unused_imports)]
use std::vec::Vec;

#[allow(dead_code)]
const INF: i32 = 1000_000_000;
#[allow(dead_code)]
const INFLL: i64 = 1000_000_000_000_000_000;
#[allow(dead_code)]
const EPS: f64 = 1.0e-10;
#[allow(dead_code)]
const MOD: i32 = 1000_000_007;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    #[allow(dead_code)]
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }

    #[allow(dead_code)]
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }

    #[allow(dead_code)]
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let r1: i32 = sc.read();
    let r2: i32 = sc.read();
    let c1: i32 = sc.read();
    let c2: i32 = sc.read();
    let d1: i32 = sc.read();
    let d2: i32 = sc.read();
    let mut ans: Vec<Vec<i32>> = vec![vec![-1; 4]; 4];
    for a in 1..10 {
        for b in 1..10 {
            for c in 1..10 {
                for d in 1..10 {
                    let mut s: Vec<i32> = vec![a, b, c, d];
                    s.sort(); s.dedup();
                    if s.len() != 4 {
                        continue;
                    }
                    if a + b == r1 && c + d == r2 && a + c == c1 && b + d == c2 && a + d == d1 && b + c == d2 {
                        ans[0][0] = a;
                        ans[0][1] = b;
                        ans[1][0] = c;
                        ans[1][1] = d;
                    }
                }
            }
        }
    }
    if ans[0][0] != -1 {
        for i in 0..2 {
            println!("{} {}", ans[i][0], ans[i][1]);
        }
    } else {
        println!("-1");
    }
}


fn main() {
    let (r1, r2) = parse();
    let (c1, c2) = parse();
    let (d1, d2) = parse();
    let mut v1 = vec![];
    let mut v2 = vec![];

    for a in 1..10 {
        for b in 1..10 {
            if a != b && a + b == d1 {
                v1.push((a, b));
            }
            if a != b && a + b == d2 {
                v2.push((a, b))
            }
        }
    }
    for a in &v1 {
        for b in &v2 {
            if a.0 + b.0 == r1
                && a.1 + b.1 == r2
                && a.0 + b.1 == c1
                && a.1 + b.0 == c2
                && a.0 != b.0
                && a.0 != b.1
                && a.1 != b.0
                && a.1 != b.1
            {
                print_result(*a, *b);
                return;
            }
        }
    }
    println!("-1");
}
fn print_result(a: (usize, usize), b: (usize, usize)) {
    println!("{} {}", a.0, b.0);
    println!("{} {}", b.1, a.1)
}
fn parse() -> (usize, usize) {
    let mut text = String::new();
    std::io::stdin().read_line(&mut text).unwrap();
    let text: Vec<usize> = text
        .trim()
        .split_whitespace()
        .map(|e| e.parse().unwrap())
        .collect();
    (text[0], text[1])
}


//! http://codeforces.com/contest/143/problem/A

#[macro_export]
macro_rules! scanln {
  ($($var:ident : $ty:path),+) => {
    $(let $var: $ty;)+
    {
      use std::io;
      let mut __buf = String::new();
      io::stdin().read_line(&mut __buf).unwrap();
      let mut eles = __buf.split_whitespace();
      $($var = Scan::scan(&mut eles);)+
    }
  }
}

pub trait Scan {
  fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator<Item=&'a str>;
}

macro_rules! impl_scan_single {
  ($ty:ty) => {
    impl Scan for $ty {
      fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator<Item=&'a str> {
        let next = eles.next().unwrap();
        match next.parse() {
          Ok(res) => res,
          Err(_) => panic!()
        }
      }
    }
  }
}

impl_scan_single!(u8);
impl_scan_single!(u16);
impl_scan_single!(u32);
impl_scan_single!(u64);
impl_scan_single!(usize);
impl_scan_single!(i8);
impl_scan_single!(i16);
impl_scan_single!(i32);
impl_scan_single!(i64);
impl_scan_single!(f32);
impl_scan_single!(f64);
impl_scan_single!(isize);
impl_scan_single!(String);

const __IMPL_SCAN_FOR_VEC: () = {
  use std::str::FromStr;
  impl<T> Scan for Vec<T> where T: FromStr {
    fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator<Item=&'a str> {
      eles.map(|str| match str.parse() {
        Ok(res) => res,
        Err(_) => panic!()
      }).collect()
    }
  }
};

// -----------------------------------------------------------------------------

fn main() {
  scanln!(r1: u32, r2: u32);
  scanln!(c1: u32, c2: u32);
  scanln!(d1: u32, d2: u32);
  for a in 1..10 {
    for b in 1..10 {
      for c in 1..10 {
        for d in 1..10 {
          if a == b || a == c || a == d || b == c || b == d || c == d { continue; }
          let cond =
            a + b == r1 &&
            c + d == r2 &&
            a + c == c1 &&
            b + d == c2 &&
            a + d == d1 &&
            b + c == d2;
          if cond {
            println!("{} {}", a, b);
            println!("{} {}", c, d);
            return;
          }
        }
      }
    }
  }
  println!("-1");
}


fn solution(r1:u32, r2:u32, c1:u32, c2:u32, d1:u32, d2: u32) -> [u32;4] {
  let mut r = [0,0,0,0];

  'outer:
  for a in 1..=9 {
    for b in 1..=9 {
      if b==a {continue};
      for c in 1..=9 {
        if c==b || c==a {continue};
        for d in 1..=9 {
          if d==a || d==b || d==c {continue};
          if a+b==r1 && c+d==r2 && a+c==c1 && b+d==c2 && a+d==d1 && b+c==d2 {
            r = [a,b,c,d];
            break 'outer;
          }
        }
      }
    }
  }
  r
}

fn main() {
  assert_eq!([1,2,3,4],solution(3, 7, 4, 6, 5, 5));
  assert_eq!([4, 7, 9, 1],solution(11, 10, 13, 8, 5, 16));
  assert_eq!([0,0,0,0], solution(1, 2, 3, 4, 5, 6));
  assert_eq!([0,0,0,0], solution(10, 10, 10, 10, 10, 10));

  let mut r = String::new();
  std::io::stdin().read_line(&mut r).unwrap();
  let mut ns1 = r.split_whitespace().map(|x| x.parse::<u32>().unwrap());
  let r1=ns1.next().unwrap();
  let r2=ns1.next().unwrap();
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).unwrap();
  let mut ns2 = s.split_whitespace().map(|x| x.parse::<u32>().unwrap());
  let c1=ns2.next().unwrap();
  let c2=ns2.next().unwrap();
  let mut t = String::new();
  std::io::stdin().read_line(&mut t).unwrap();
  let mut ns3 = t.split_whitespace().map(|x| x.parse::<u32>().unwrap());
  let d1=ns3.next().unwrap();
  let d2=ns3.next().unwrap();
  let a=solution(r1,r2,c1,c2,d1,d2);
  if a[0]==0 {
    println!("-1");
  } else {
    println!("{} {}\n{} {}",a[0], a[1], a[2], a[3]);
  }
}


use std::io::prelude::*;
use std::io::stdin;

fn main() {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    println!("{}", if buf.contains('1') && buf.trim_left_matches('0').matches('0').count() >= 6 { "yes" } else { "no" });
}


#![allow(dead_code)]
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(overflowing_literals)]
#![allow(unused_must_use)]
#![allow(non_camel_case_types)]

use std::collections::*;
use std::io::*;
use std::cmp::{max, min};
use std::f64::consts::*;
use std::mem::swap;
use std::fs::File;
use std::rc::*;
use std::ascii::*;
use std::ops::*;

const INF: i32 = std::i32::MAX;
const LINF: i64 = std::i64::MAX;
const MOD: usize = 1000000007;

struct Input<Buf: BufRead> {
	buffer: Buf,
}

impl<Buf: BufRead> Input<Buf> {
	fn read_line(&mut self) -> String {
		let mut v = Vec::new();
		let mut x = [255u8];
		self.buffer.read(&mut x).expect("EOF");
		while x[0] < b' ' && x[0] != 255u8 {
			x[0] = 255u8;
			self.buffer.read(&mut x).expect("EOF");
		}
		while x[0] >= b' ' && x[0] != 255u8 {
			v.push(x[0]);
			x[0] = 255u8;
			self.buffer.read(&mut x).expect("EOF");
		}
		String::from_utf8(v).unwrap()
	}

	fn read_word(&mut self) -> String {
		let mut v = Vec::new();
		let mut x = [255u8];
		self.buffer.read(&mut x).expect("EOF");
		while x[0] <= b' ' && x[0] != 255u8 {
			x[0] = 255u8;
			self.buffer.read(&mut x).expect("EOF");
		}
		while x[0] > b' ' && x[0] != 255u8 {
			v.push(x[0]);
			x[0] = 255u8;
			self.buffer.read(&mut x).expect("EOF");
		}
		String::from_utf8(v).unwrap()
	}
	#[inline]
	fn read_int(&mut self) -> i32 {
		self.read_word().parse::<i32>().expect("Parsing error")
	}
	#[inline]
	fn read_long(&mut self) -> i64 {
		self.read_word().parse::<i64>().expect("Parsing error")
	}
	#[inline]
	fn read_usize(&mut self) -> usize {
		self.read_word().parse::<usize>().expect("Parsing error")
	}
	#[inline]
	fn read_double(&mut self) -> f64 {
		self.read_word().parse::<f64>().expect("Parsing error")
	}
}
macro_rules! read {
    () => {};
	($inf:ident, $($t:ty),+) => ({($({$inf.read_word().parse::<$t>().expect("Parsing error")}),*)});
}
fn gcd<T: RemAssign + Ord + From<i32> + Copy + Clone>(mut a: T, mut b: T) -> T {
	while b > T::from(0) {
		a %= b;
		swap(&mut a, &mut b);
	}
	a
}

fn main() {
	match std::env::var("home") {
		Ok(_x) => {
			let mut inf = Input {
				buffer: BufReader::new(File::open("input.txt").expect("File not found"))
			};
			let mut ouf = BufWriter::new(stdout());
			let stack_size = 268_435_456 / 4; // 256 MB
			let thd = std::thread::Builder::new().stack_size(stack_size);
			thd.spawn(move || solve(&mut inf, &mut ouf)).unwrap().join().unwrap();
		}
		Err(_e) => {
			let mut inf = Input { buffer: BufReader::new(stdin()) };
			let mut ouf = BufWriter::new(stdout());
			let stack_size = 268_435_456 / 4; // 256 MB
			let thd = std::thread::Builder::new().stack_size(stack_size);
			thd.spawn(move || solve(&mut inf, &mut ouf)).unwrap().join().unwrap();
		}
	}
}

fn dfs<'a>(g: &'a Vec<Vec<usize>>, u: &'a mut Vec<bool>, v: usize) {
	if u[v] {
		return;
	}
	u[v] = true;
	for &x in &g[v] {
		dfs(g, u, x);
	}
}

type int = i32;
type long = i64;
type uint = u32;
type ulong = u64;

fn solve<Inner: BufRead, Output: Write>(inf: &mut Input<Inner>, ouf: &mut Output) {
	let s = inf.read_word().as_bytes().to_vec();
	let mut pos = 0;
	while pos < s.len() && s[pos] == b'0' {
		pos += 1;
	}
	let mut ans = 0;
	for i in pos + 1..s.len() {
		if s[i] == b'0' {
			ans += 1;
		}
	}
	if ans >= 6 {
		writeln!(ouf, "yes");
	} else {
		writeln!(ouf, "no");
	}
}


#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

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

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
                   ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
                   ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let str :Vec<char> = util::line().chars().collect();
    let mut flag = 0;
    let mut ans =0;
    for c in str {
        if c == '1' {
            flag = 1;
        } else if flag == 1 {
            ans += 1;
        }
    }
    if ans >= 6 {
        println!("yes");
    } else {
        println!("no");
    }
}


use std::io::prelude::*;
use std::io::stdin;

fn main() {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let mut chrs = buf.chars().skip_while(|&c| c == '0');
    println!("{}", if chrs.next() == Some('1') && chrs.filter(|&c| c == '0').count() >= 6 { "yes" } else { "no" });
}


#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap};
#[allow(unused_imports)]
use std::iter::FromIterator;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

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

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }

    #[allow(dead_code)]
    pub fn get2<T: FromStr, U: FromStr>() -> (T, U)
    where
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }

    #[allow(dead_code)]
    pub fn get3<S: FromStr, T: FromStr, U: FromStr>() -> (S, T, U)
    where
        <S as FromStr>::Err: Debug,
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }
}

#[allow(unused_macros)]
macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn main() {
    let s = util::line();

    let mut zeros = 0;
    for c in s.chars().rev() {
        if c == '0' {
            zeros += 1;
        } else {
            if zeros >= 6 {
                println!("yes");
                return;
            }
        }
    }

    println!("no");
}


use std::io;

fn read_line() -> String {
    let mut input_line = String::new();
    io::stdin().read_line(&mut input_line).unwrap();
    return String::from(input_line.trim());
}

fn main() {
    let s = read_line();

    match s.chars().skip_while(|x| *x == '0').filter(|x| *x == '0').count() >= 6 {
        true => println!("yes"),
        false => println!("no")
    }

}