use std::io::{stdin, BufRead, Stdin, StdinLock};

fn get_average_time(time1: (usize, usize), time2: (usize, usize)) -> (usize, usize) {
    let time1_minutes: usize = time1.0 * 60 + time1.1;
    let time2_minutes: usize = time2.0 * 60 + time2.1;

    let time3_minutes = (time1_minutes + time2_minutes) / 2;

    return ((time3_minutes / 60), (time3_minutes % 60));
}

#[cfg(test)]
mod test {
    use super::get_average_time;

    #[test]
    fn test1() {
        let time1: (usize, usize) = (10, 0);
        let time2: (usize, usize) = (11, 0);
        let time_result: (usize, usize) = get_average_time(time1, time2);

        assert_eq!(time_result, (10, 30));
    }
    #[test]
    fn test2() {
        let time1: (usize, usize) = (11, 10);
        let time2: (usize, usize) = (11, 12);
        let time_result: (usize, usize) = get_average_time(time1, time2);

        assert_eq!(time_result, (11, 11));
    }
    #[test]
    fn test3() {
        let time1: (usize, usize) = (1, 2);
        let time2: (usize, usize) = (3, 2);
        let time_result: (usize, usize) = get_average_time(time1, time2);

        assert_eq!(time_result, (2, 2));
    }
}

fn read_data() -> ((usize, usize), (usize, usize)) {
    let stdin_stream: Stdin = stdin();
    let mut stdin_handle: StdinLock = stdin_stream.lock();

    let mut str1: String = String::new();
    stdin_handle.read_line(&mut str1).unwrap();
    let str1_tokens: Vec<usize> = str1
        .trim()
        .split(":")
        .map(|s| s.parse::<usize>().unwrap())
        .collect();

    let mut str2: String = String::new();
    stdin_handle.read_line(&mut str2).unwrap();
    let str2_tokens: Vec<usize> = str2
        .trim()
        .split(":")
        .map(|s| s.parse::<usize>().unwrap())
        .collect();

    return (
        (str1_tokens[0], str1_tokens[1]),
        (str2_tokens[0], str2_tokens[1]),
    );
}

fn main() {
    let (time1, time2): ((usize, usize), (usize, usize)) = read_data();

    let time_result: (usize, usize) = get_average_time(time1, time2);

    println!("{}:{}", time_result.0, time_result.1);
}


use std::collections::HashSet;

fn main() {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line);
    let mut line = String::new();
    std::io::stdin().read_line(&mut line);
    let line = line.trim();
    let characters: HashSet<_> = line.chars().collect();
    println!("{}", if characters.len() == 27 { "YES" } else { "NO" })
}


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 digit_sum(x: i64) -> i64 {
    let mut x = x;
    let mut ans = 0;
    while x > 0 {
        ans += x % 10;
        x /= 10;
    }
    ans
}

fn solve<R: io::BufRead, W: io::Write>(scan: &mut Scanner<R>, out: &mut W) {
    let a: u32 = scan.token();
    let b: i64 = scan.token();
    let c: i64 = scan.token();
    let mut ans = Vec::new();

    for s_x in 1i64..=81i64 {
        let x = b * s_x.pow(a) + c;
        if digit_sum(x) == s_x {
            ans.push(x.to_string());
        }
    }
    writeln!(out, "{}", ans.len()).ok();
    writeln!(out, "{}", ans.join(" ")).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;
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 digit_sum(x: i64) -> i64 {
    let mut x = x;
    let mut ans = 0;
    while x > 0 {
        ans += x % 10;
        x /= 10;
    }
    ans
}

fn solve<R: io::BufRead, W: io::Write>(scan: &mut Scanner<R>, out: &mut W) {
    let a: u32 = scan.token();
    let b: i64 = scan.token();
    let c: i64 = scan.token();
    let mut ans = Vec::new();

    for s_x in 1i64..=81i64 {
        let x = b * s_x.pow(a) + c;
        if x >= 1000000000 {
            break;
        }
        if x < digit_sum(x) == s_x {
            ans.push(x.to_string());
        }
    }
    writeln!(out, "{}", ans.len()).ok();
    writeln!(out, "{}", ans.join(" ")).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);
}


#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

#[allow(unused_macros)]
macro_rules! invec {
    ( $ t : ty ) => {{
        let mut s = String::new();
        match std::io::stdin().read_line(&mut s) {
            Ok(0) => Vec::<$t>::new(),
            Ok(n) => s
                .trim()
                .split_whitespace()
                .map(|s| s.parse::<$t>().unwrap())
                .collect::<Vec<$t>>(),
            Err(_) => Vec::<$t>::new(),
        }
    }};
}

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

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut 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)*}
    };
    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

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

    ($next:expr, [$t:tt]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $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")
    };
}

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = i64::max_value() / 2;
#[allow(dead_code)]
static INF_I32: i32 = i32::max_value() / 2;
#[allow(dead_code)]
static INF_USIZE: usize = usize::max_value() / 2;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    let (a, b, c) = get!(i64, i64, i64);
    let mut k = vec![];
    for i in 0..100 {
        k.push((b * ((i as i64).pow(a as u32)) + c, i));
    }
    let mut ans = vec![];
    for &(d, e) in &k {
        if d < 0 {
            continue;
        } else if d > 10_i64.pow(9) {
            continue;
        }
        let f = d
            .to_string()
            .chars()
            .map(|x| x as usize - '0' as usize)
            .fold(0, |a, x| a + x);
        if f == e {
            ans.push(d);
        }
    }
    echo!(ans.len());
    echo!(ans.joinToString(" "));
}


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

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

    fn next_line(&self) -> String {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).expect("Fail to read");
        line
    }

    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 line = self.next_line();
            self.buffer = line.split_whitespace().map(String::from).collect();
        }
    }
}

fn sumdigits(x: i64) -> usize {
    let mut result = 0usize;
    let mut tmp = x;
    while tmp > 0 {
        result += (tmp % 10) as usize;
        tmp /= 10;
    }
    result
}

fn _main() {
    let mut scan = Scan::new();
    let a: u32 = scan.next();
    let b: isize = scan.next();
    let c: isize = scan.next();
    let mut result: Vec<i64> = vec![];
    for i in 0usize..=72 {
        let x: i64 = (i.pow(a) as i64) * (b as i64) + (c as i64);
        if x <= 0 {
            continue;
        }
        if x >= 1000000000 {
            break;
        }
        if sumdigits(x) == i {
            result.push(x);
        }
    }
    println!("{}", result.len());
    for &item in &result {
        print!("{} ", item);
    }
    if result.len() != 0 {
        println!();
    }
}

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


use std::io::stdin;
fn main() {
    let mut text = String::new();
    stdin().read_line(&mut text).unwrap();
    let text = text.trim();
    let mut counter4: usize = 0;
    let mut counter7: usize = 0;
    for i in text.chars() {
        if '4' == i {
            counter4 += 1;
        } else if '7' == i {
            counter7 -= 1;
        }
    }
    if counter4 == 0 && counter7 == 0 {
        println!("-1");
    } else if counter4 > counter7 {
        println!("4")
    } else {
        println!("7")
    }
}

fn delete_leading_zeroes(arr: Vec<char>) -> Vec<char> {
    let mut finded = false;
    let mut last = 0;
    for i in 0..arr.len() {
        if '0' == arr[i] {
            continue;
        } else {
            last = i;
            finded = true;
            break;
        }
    }
    if finded {
        arr[last..].to_vec()
    } else {
        arr
    }
}


fn main() {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line);
    let mut v: Vec<i32> = line.trim().split(" ").map(|s| s.parse::<i32>().unwrap()).collect();
    v.sort();
    println!("{}", v.iter().map(|i| i.to_string()).collect::<Vec<_>>().connect(" "));
}


use std::str::FromStr;

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

fn read_vec<T: FromStr>(split_char: char) -> Vec<T> {
    read_str()
        .split(split_char)
        .map(|value| value.parse::<T>().ok().expect("Error"))
        .collect()
}

fn main() {
    read_str();
    let mut blocks: Vec<String> = read_vec(' ');
    blocks.sort();
    println!("{}", blocks.join(" "));
}


use std::io::stdin;
use std::cmp::min;

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

    let input_iter = input_line.
        split_whitespace().
        map(|x| x.parse::<usize>().unwrap());

    let input: Vec<_> = input_iter.collect();

    let owned = input[0];
    if owned % 4 == 0 {
        // Already meet criteria
        println!("0");
        return;
    }

    let purchase = 4 - owned % 4;

    let mut dp = vec![usize::max_value(); 9];
    dp[0] = 0;

    for i in 0..9 {
        for j in 1..4 {
            if i >= j {
                dp[i] = min(dp[i - j] + input[j], dp[i]);
            }
        }
    }

    println!("{}", min(dp[purchase], dp[purchase + 4]));
}


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

use std::cmp;

#[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 = i64;
    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 k = input_vectors[0][0];
    let a = input_vectors[0][1];
    let b = input_vectors[0][2];
    let c = input_vectors[0][3];
    let required_copies = match k % 4 {
        0 => 0,
        n => 4 - n,
    };
    let cost = match required_copies {
        1 => cmp::min(a * 1, cmp::min(b * 1, cmp::min(c * 1, c * 3))),
        2 => cmp::min(cmp::min(a * 2, b * 1), cmp::min(a * 1 + c * 1, c * 2)),
        3 => cmp::min(a * 3, cmp::min(a * 1 + b * 1, c * 1)),
        _ => 0,
    };
    println!("{}", cost);
}


use std::io::{self, Stdin};
use std::str::{self, FromStr};
use std::error::Error;
use std::thread;
use std::cmp::*;
fn exec() {
    let mut sc = Scanner::new();
    let n: usize = sc.ne();
    let a: usize = sc.ne();
    let b: usize = sc.ne();
    let c: usize = sc.ne();
    let ans = match n % 4 {
        0 => 0,
        1 => min(a * 3, min(a + b, c)),
        2 => min(a * 2, min(c * 2, b)),
        _ => min(a, b + c),
    };
    println!("{}", ans);
}

fn main() {
    const DEFAULT_STACK: usize = 16 * 1024 * 1024;
    let builder = thread::Builder::new();
    let th = builder.stack_size(DEFAULT_STACK);
    let handle = th.spawn(|| { exec(); }).unwrap();
    let _ = handle.join();
}

#[allow(dead_code)]
struct Scanner {
    stdin: Stdin,
    id: usize,
    buf: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            id: 0,
            buf: Vec::new(),
        }
    }
    fn next_line(&mut self) -> Option<String> {
        let mut res = String::new();
        match self.stdin.read_line(&mut res) {
            Ok(0) => return None,
            Ok(_) => Some(res),
            Err(why) => panic!("error in read_line: {}", why.description()),
        }
    }
    fn next<T: FromStr>(&mut self) -> Option<T> {
        while self.buf.len() == 0 {
            self.buf = match self.next_line() {
                Some(r) => {
                    self.id = 0;
                    r.trim().as_bytes().to_owned()
                }
                None => return None,
            };
        }
        let l = self.id;
        assert!(self.buf[l] != b' ');
        let n = self.buf.len();
        let mut r = l;
        while r < n && self.buf[r] != b' ' {
            r += 1;
        }
        let res = match str::from_utf8(&self.buf[l..r]).ok().unwrap().parse::<T>() {
            Ok(s) => Some(s),
            Err(_) => panic!("parse error"),
        };
        while r < n && self.buf[r] == b' ' {
            r += 1;
        }
        if r == n {
            self.buf.clear();
        } else {
            self.id = r;
        }
        res
    }
    fn ne<T: FromStr>(&mut self) -> T {
        self.next::<T>().unwrap()
    }
}


macro_rules! scanln {
    () => ({
        let mut buffer = String::new();
        ::std::io::stdin().read_line(&mut buffer).expect("Unable to read line");
        buffer
    });
    ($($t: ty),+) => ({
        scanln!($($t),+, |c: char| c.is_whitespace())
    });
    ($($t: ty),+, $sp: expr) => ({
        let mut buffer = scanln!();
        let mut iter = buffer.split($sp);
        ($(iter.next().unwrap().parse::<$t>().expect("Unable to parse token")),+)
    });
}

fn main() {
    const MOD: u64 = 1000000009;
    let mut dp = vec![[[[[0u64; 2]; 32]; 32]; 32]; 1001].into_boxed_slice();
    let (n, h) = scanln!(usize, usize);
    dp[0][0][0][0][0] = 1;

    for i in 1..=n {
        for a in 0..=(h + 1) {
            for b in a..=(h + 1) {
                for c in b..=(h + 1) {
                    for y in 0..2 {
                        let val = dp[(i - 1) as usize][a][b][c][y];
                        let ta = if a + 1 > h { h + 1 } else { a + 1 };
                        let tb = if b + 1 > h { h + 1 } else { b + 1 };
                        let tc = if c + 1 > h { h + 1 } else { c + 1 };
                        dp[i][ta][tb][tc][y] += val;
                        if y == 0 {
                            dp[i][1][tb][tc][(ta > h) as usize] += val;
                            dp[i][1][ta][tc][(tb > h) as usize] += val;
                            dp[i][1][ta][tb][(tc > h) as usize] += val;
                        } else {
                            dp[i][tb][tc][h + 1][(ta > h) as usize] += val;
                            dp[i][ta][tc][h + 1][(tb > h) as usize] += val;
                            dp[i][ta][tb][h + 1][(tc > h) as usize] += val;
                        }
                    }
                }
            }
        }
    }

    let mut res = 0;

    for a in 0..=(h + 1) {
        for b in a..=(h + 1) {
            for c in b..=(h + 1) {
                for y in 0..2 {
                    if (a < h) || (b < h) || (c < h) || (y == 0) {
                        res += dp[n][a][b][c][y];
                    }
                }
            }
        }
    }

    println!("{}", res % MOD);
}


#![allow(dead_code, unused_imports)]

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 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> {
    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;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    for _ in 0..read_usize() {
        let (a1, a2, a3) = read_3::<u64, u64, u64>();
        let (b1, b2, b3) = read_3::<u64, u64, u64>();
        let not_wins = [(0, 0), (1, 1), (2, 2), (0, 2), (1, 0), (2, 1)];
        let mut min_wins = None;
        for perm in Permutations::new(not_wins.to_vec()) {
            let mut tmpa = [a1, a2, a3];
            let mut tmpb = [b1, b2, b3];
            for (a, b) in perm {
                let m = min(tmpa[a], tmpb[b]);
                tmpa[a] -= m;
                tmpb[b] -= m;
            }
            if let Some(m) = min_wins {
                min_wins = Some(min(m, tmpa.iter().sum::<u64>()))
            } else {
                min_wins = Some(tmpa.iter().sum::<u64>())
            }
        }
        let max_wins = min(a1, b2) + min(a2, b3) + min(a3, b1);
        println!("{} {}", min_wins.unwrap(), max_wins);
    }
    Ok(())
}


//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).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
}

const M: i64 = 1_000_000_007;

// fn mul(a: i64, b: i64) -> i64 { a * b % M }
fn add(a: i64, b: i64) -> i64 {
    let x = (a + b) % M;
    x
}

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

    let n = input.u();
    let tt = input.i();
    let mut t = vec![0; n];
    let mut g = vec![0; n];
    let mut z = vec![0; 4];
    for i in 0..n {
        t[i] = input.i();
        g[i] = input.i();
        z[g[i] as usize] += 1;
    }
    let sumt: i32 = t.iter().sum();

    let dp2 = {
        let mut dp2 = HashMap::<(i32,i32,i32),i64>::new();
        let mut dp = HashMap::<(i32,i32,i32,i32,i32),i64>::new();
        for g in 1..4 {
            dp.insert((0,0,0,0,g), 1);
        }
        for _i in 0..n {
            let mut d = HashMap::<(i32,i32,i32,i32,i32),i64>::new();
            for ((h,a,b,c,l), y) in dp.into_iter() {
                let mut p = [0,a,b,c];
                for g in 1..4 {
                    if (h == 0 && g != l) || (h > 0 && g == l) {
                        continue;
                    }
                    p[g as usize] += 1;
                    if (1..4).all(|i| p[i] <= z[i]) {
                        let key = (h + 1, p[1], p[2], p[3], g);
                        let res = add(y * p[g as usize] as i64, *d.get(&key).unwrap_or(&0));
                        d.insert(key, res);
                    }
                    p[g as usize] -= 1;
                }
            }

            for (&(_,a,b,c,_),&x) in d.iter() {
                let key = (a,b,c);
                let res = *dp2.get(&key).unwrap_or(&0);
                dp2.insert(key, add(res, x));
            }
            dp = d;
            // println!("\n-----------------------: {}", _i);
            // for ((h,a,b,c,g),x) in dp.iter() {
            // println!("{} {} {} {} {}: {}", h,a,b,c,g,x);
            // }
        }
        dp2
    };
    // eprintln!("DP2");
    //  for ((a,b,c),x) in dp2.iter() {
        //  println!("dp2    {} {} {} : {}", a,b,c,x);
    //  }

    let dp1 = {
        let mut st = [0; 4];
        st[3] = 1;
        st[2] = st[3] * (z[3] + 1);
        st[1] = st[2] * (z[2] + 1);
        st[0] = st[1] * (z[1] + 1);
        let st = st;
        let sz = (st[0] * (sumt + 1)) as usize;

        // println!("st {} {} {} {}", st[0], st[1], st[2], st[3]);
        // println!("z  {} {} {} {}", z[0], z[1], z[2], z[3]);

        let mut aa = vec![0; sz];
        // println!("{}", aa.len());
        let mut dp = HashSet::<i32>::new();
        dp.insert(0);
        aa[0] = 1;
        for i in 0..n {
            let mut d = HashSet::<i32>::new();
            let mut a = vec![0; sz];
            let x = t[i];
            let g = g[i] as usize;
            for &s in dp.iter() {
                let s = s as usize;
                let key = s + (x * st[0]) as usize + st[g] as usize;
                d.insert(key as i32);
                a[key] += aa[s];
            }
            for key in d.into_iter() {
                let s = key as usize;
                aa[s] += a[s];
                dp.insert(key);
            }
        }
        let mut dp1 = HashMap::<(i32,i32,i32),i64>::new();
        let min = st[0] * tt;
        let max = st[0] * (tt + 1);
        for s in dp.into_iter() {
            if min <= s && s < max {
                let a = s % st[0] / st[1];
                let b = s % st[1] / st[2];
                let c = s % st[2] / st[3];
                dp1.insert((a,b,c),aa[s as usize]);
            }
        }
        dp1
    };
    // eprintln!("DP1");
    // for ((a,b,c),&x) in dp1.iter() {
        // println!("dp1    {} {} {} : {}", a,b,c,x);
    // }

    let mut sol: i64 = 0;
    for a in 0..z[1]+1 {
        let a = a as i32;
        for b in 0..z[2]+1 {
            let b = b as i32;
            for c in 0..z[3]+1 {
                let c = c as i32;
                let x = dp1.get(&(a,b,c)).unwrap_or(&0);
                let y = dp2.get(&(a,b,c)).unwrap_or(&0);
                sol = add(sol, x * y);
            }
        }
    }
    sol = (sol % M + M) % M;
    println!("{}", sol);
}


//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
}

const P5: i32 = 1_000_000_007;
const P6: i64 = P5 as i64;
#[derive(Debug,Clone,Copy)]
struct Field(i32);
#[allow(dead_code)]
impl Field {
    fn new<T: Into<i64>>(a: T) -> Self { Self(Self::cv(a)) }
    fn new_unchecked(a: i32) -> Self { Self(a) }
    fn hi(mut a: i32) -> i32 { if a >= P5 { a -= P5; } a }
    fn lo(mut a: i32) -> i32 { if a < 0 { a += P5; } a }
    fn cv<T: Into<i64>>(a: T) -> i32 { Self::lo((a.into() % P6) as i32) }
}
impl Add for Field { type Output = Self; fn add(self, a: Self) -> Self::Output { Self(Self::hi(self.0 + a.0)) }}
impl Sub for Field { type Output = Self; fn sub(self, a: Self) -> Self::Output { Self(Self::lo(self.0 - a.0)) }}
impl Mul for Field { type Output = Self; fn mul(self, a: Self) -> Self::Output { Self(Self::cv(self.0 as i64 * a.0 as i64)) }}
impl Neg for Field { type Output = Self; fn neg(self) -> Self::Output { Self(Self::lo(-self.0)) }}
impl AddAssign for Field { fn add_assign(&mut self, a: Self) { *self = *self + a; } }
impl SubAssign for Field { fn sub_assign(&mut self, a: Self) { *self = *self - a; } }
impl MulAssign for Field { fn mul_assign(&mut self, a: Self) { *self = *self * a; } }
use std::fmt::{Display, Formatter, Result};
impl Display for Field { fn fmt(&self, f: &mut Formatter) -> Result { write!(f, "{}", self.0) } }
// impl Default for Field { fn default() -> Self { Field(0) }}
impl Default for &Field { fn default() -> Self { &Field(0) }}
impl PartialEq for Field { fn eq(&self, a: &Self) -> bool { self.0 == a.0 } }
impl PartialOrd for Field { fn partial_cmp(&self, a: &Self) -> Option<Ordering> { Some(self.0.cmp(&a.0)) } }
impl Eq for Field {}
impl Ord for Field { fn cmp(&self, a: &Self) -> Ordering { self.0.cmp(&a.0) } }

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

    let n = input.u();
    let tt = input.i();
    let mut t = vec![0; n];
    let mut g = vec![0; n];
    let mut z = vec![0; 4];
    for i in 0..n {
        t[i] = input.i();
        g[i] = input.i();
        z[g[i] as usize] += 1;
    }
    let sumt: i32 = t.iter().sum();

    let dp2 = {
        let mut dp2 = HashMap::<(i32,i32,i32),Field>::new();
        let mut dp = HashMap::<(i32,i32,i32,i32,i32),Field>::new();
        for g in 1..4 {
            dp.insert((0,0,0,0,g), Field(1));
        }
        for _i in 0..n {
            let mut d = HashMap::<(i32,i32,i32,i32,i32),Field>::new();
            for ((h,a,b,c,l), y) in dp.into_iter() {
                let mut p = [0,a,b,c];
                let mut pf = [Field(0),Field(a),Field(b),Field(c)];
                for g in 1..4 {
                    let gu = g as usize;
                    if (h == 0 && g != l) || (h > 0 && g == l) {
                        continue;
                    }
                    p[gu] += 1;
                    pf[gu] += Field(1);
                    if (1..4).all(|i| p[i] <= z[i]) {
                        let key = (h + 1, p[1], p[2], p[3], g);
                        let res = y * pf[g as usize] + *d.get(&key).unwrap_or_default();
                        d.insert(key, res);
                    }
                    p[gu] -= 1;
                    pf[gu] -= Field(1);
                }
            }

            for (&(_,a,b,c,_),&x) in d.iter() {
                let key = (a,b,c);
                let res = *dp2.get(&key).unwrap_or_default();
                dp2.insert(key, res + x);
            }
            dp = d;
            // println!("\n-----------------------: {}", _i);
            // for ((h,a,b,c,g),x) in dp.iter() {
            // println!("{} {} {} {} {}: {}", h,a,b,c,g,x);
            // }
        }
        dp2
    };
    // eprintln!("DP2");
    // for ((a,b,c),x) in dp2.iter() {
        // println!("dp2    {} {} {} : {}", a,b,c,x);
    // }

    let dp1 = {
        let mut st = [0; 3];
        st[2] = 1;
        st[1] = st[2] * (z[2] + 1);
        st[0] = st[1] * (z[1] + 1);
        let st = st;
        let sz = (st[0] * (sumt + 1)) as usize;

        let mut aa = vec![Field(0); sz];
        let mut dp = HashSet::<i32>::new();
        dp.insert(0);
        aa[0] = Field(1);
        for i in 0..n {
            if g[i] == 3 { continue; }

            let mut d = HashSet::<i32>::new();
            let mut a = vec![Field(0); sz];
            let x = t[i];
            let g = g[i] as usize;
            for &s in dp.iter() {
                let key = s + (x * st[0]) + st[g];
                d.insert(key);
                a[key as usize] += aa[s as usize];
            }
            for key in d.into_iter() {
                let s = key as usize;
                aa[s] += a[s];
                dp.insert(key);
            }
        }
        let mut dp1 = HashMap::<(i32,i32,i32),Field>::new();
        for s in dp.into_iter() {
            let t = s / st[0];
            let a = s % st[0] / st[1];
            let b = s % st[1] / st[2];
            dp1.insert((t,a,b),aa[s as usize]);
        }
        dp1
    };
    // eprintln!("DP1");
    // for ((a,b,c),x) in dp1.iter() {
        // println!("dp1    {} {} {} : {}", a,b,c,x);
    // }

    let dp3 = {
        let mut st = [0; 4];
        st[3] = 1;
        st[0] = st[3] * (z[3] + 1);
        let st = st;
        let sz = (st[0] * (sumt + 1)) as usize;

        let mut aa = vec![Field(0); sz];
        let mut dp = HashSet::<i32>::new();
        dp.insert(0);
        aa[0] = Field(1);
        for i in 0..n {
            if g[i] != 3 { continue; }

            let mut d = HashSet::<i32>::new();
            let mut a = vec![Field(0); sz];
            let x = t[i];
            let g = g[i] as usize;
            for &s in dp.iter() {
                let key = s + (x * st[0]) + st[g];
                d.insert(key);
                a[key as usize] += aa[s as usize];
            }
            for key in d.into_iter() {
                let s = key as usize;
                aa[s] += a[s];
                dp.insert(key);
            }
        }
        let mut dp3 = HashMap::<(i32,i32),Field>::new();
        for s in dp.into_iter() {
            let t = s / st[0];
            let c = s % st[0] / st[3];
            dp3.insert((t,c),aa[s as usize]);
        }
        dp3
    };
    // eprintln!("DP3");
    // for ((a,b),x) in dp3.iter() {
        // println!("dp3    {} {} : {}", a,b,x);
    // }

    let dp1 = {
        let mut dp = HashMap::<(i32,i32,i32),Field>::new();
        for (&(tab,a,b),&res1) in &dp1 {
            let tc = tt - tab;
            if tc < 0 { continue; }
            for c in 0..=z[3] {
                if let Some(&res2) = dp3.get(&(c,tc)) {
                    let res3 = *dp.get(&(a,b,c)).unwrap_or_default();
                    dp.insert((a,b,c), res3 + res1*res2);
                }
            }
        }
        dp
    };
    // println!("DP1");
    // println!("DP1");
    // for ((a,b,c),&x) in dp1.iter() {
        // println!("dpX    {} {} {} : {}", a,b,c,x);
    // }

    let mut sol = Field::new_unchecked(0);
    for a in 0..=z[1] as i32 {
        for b in 0..=z[2] as i32 {
            for c in 0..=z[3] as i32 {
                let x = *dp1.get(&(a,b,c)).unwrap_or_default();
                let y = *dp2.get(&(a,b,c)).unwrap_or_default();
                sol += x * y;
            }
        }
    }
    println!("{}", sol);
}


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() {
    let (al, ar) = parse_line!(i32, i32);
    let (bl, br) = parse_line!(i32, i32);
    let mut ok = false;
    ok |= br >= al - 1 && br < (al + 1) * 2;
    ok |= bl >= ar - 1 && bl < (ar + 1) * 2;
    println!("{}", if ok {"YES"} else {"NO"})
}

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


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

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

macro_rules! debug {($($a:expr),*) => {println!(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 }
}

use std::hash::Hash;
fn inc<T: Hash+Ord>(map:&mut BTreeMap<T,i64>, key:T) {
    let count = map.entry(key).or_insert(0);
    *count += 1;
}

fn digit(ch: char) -> i64 {
    return (ch as u8 - b'0') as i64
}

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

fn gcd(x:i64, y:i64) -> i64 {
    if y==0 { return x; }
    gcd(y, x%y)
}

fn divisor(n:usize) -> Vec<usize> {
    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 s:Vec<char> = read::<String>().chars().collect();
        let t:Vec<char> = read::<String>().chars().collect();

        let mut ans = 0;
        for i in 0..s.len() {
            for j in i+1..s.len() {
                // remain string
                let mut ss = vec![];
                for k in 0..i { ss.push(s[k]); }
                for k in j+1..s.len() { ss.push(s[k]); }
                let m = ss.len();
                let mut idx = 0;
                for k in 0..m {
                    if idx >= t.len() { break; }
                    if ss[k] == t[idx] {
                        idx += 1;
                    }
                }
                if idx >= t.len() {
                    //debug!(i,j,ss);
                    ans = max(ans, j-i+1);
                }
            }
        }
        println!("{}", ans);

    //}
}

/*

*/


#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::fs::File;
#[allow(unused_imports)]
use std::io::prelude::*;
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufReader, BufWriter, Stdin, Stdout, Write};
#[allow(unused_imports)]
use std::mem::swap;
#[allow(unused_imports)]
use std::str::FromStr;

type BoxResult<T> = Result<T, Box<std::error::Error>>;

fn main() {
    let mut scanner = Scanner::new(stdin());
    let s = scanner.read_chars().unwrap();
    let t = scanner.read_chars().unwrap();
    let mut maximum = 0;
    for i in 0..(s.len() - 1) {
        for j in i..s.len() {
            if judge(&s, &t, i, j) {
                maximum = max(j - i + 1, maximum);
            }
        }
    }
    println!("{}", maximum);
}

fn judge(s: &[char], t: &[char], start: usize, end: usize) -> bool {
    let mut index = 0;
    for i in 0..s.len() {
        if i >= start && i <= end {
            continue;
        }
        if s[i] == t[index] {
            index += 1;
        }
        if index == t.len() {
            break;
        }
    }
    index == t.len()
}

#[allow(dead_code)]
struct Scanner<R> {
    reader: BufReader<R>,
    buffer: String,
}

impl<R> Scanner<R>
where
    R: Read,
{
    #[allow(dead_code)]
    fn new(inner: R) -> Scanner<R> {
        let reader = BufReader::new(inner);
        let buffer = String::new();
        Scanner {
            reader: reader,
            buffer: buffer,
        }
    }

    #[allow(dead_code)]
    fn with_capacity(capacity: usize, inner: R) -> Scanner<R> {
        let reader = BufReader::with_capacity(capacity, inner);
        let buffer = String::new();
        Scanner {
            reader: reader,
            buffer: buffer,
        }
    }

    #[allow(dead_code)]
    fn read<T>(&mut self) -> BoxResult<T>
    where
        T: FromStr,
        T::Err: std::fmt::Debug,
        T::Err: std::error::Error,
        T::Err: 'static,
    {
        self.reader.read_line(&mut self.buffer)?;
        let parsed = self.buffer.trim().parse()?;
        self.buffer.clear();
        Ok(parsed)
    }

    #[allow(dead_code)]
    fn read_vector<T>(&mut self) -> BoxResult<Vec<T>>
    where
        T: FromStr,
        T::Err: std::fmt::Debug,
        T::Err: std::error::Error,
        T::Err: 'static,
    {
        self.reader.read_line(&mut self.buffer)?;
        let parsed_vec = self
            .buffer
            .trim()
            .split_whitespace()
            .map(|s| s.parse())
            .collect::<Result<Vec<_>, _>>()?;
        self.buffer.clear();
        Ok(parsed_vec)
    }

    #[allow(dead_code)]
    fn read_matrix<T>(&mut self, lines: usize) -> BoxResult<Vec<Vec<T>>>
    where
        T: FromStr,
        T::Err: std::fmt::Debug,
        T::Err: std::error::Error,
        T::Err: 'static,
    {
        let mut parsed_matrix = vec![];
        for _ in 0..lines {
            self.reader.read_line(&mut self.buffer)?;
            parsed_matrix.push(
                self.buffer
                    .trim()
                    .split_whitespace()
                    .map(|s| s.parse())
                    .collect::<Result<Vec<_>, _>>()?,
            );
            self.buffer.clear();
        }
        Ok(parsed_matrix)
    }

    #[allow(dead_code)]
    fn read_chars(&mut self) -> BoxResult<Vec<char>> {
        self.reader.read_line(&mut self.buffer)?;
        let chars = self.buffer.trim().chars().collect::<Vec<_>>();
        self.buffer.clear();
        Ok(chars)
    }
}


// use rand::Rng;
use std::collections::HashMap;
use std::io;
macro_rules! parse_input {
    ($x:expr, $t:ident) => {
        $x.trim().parse::<$t>().unwrap()
    };
}

macro_rules! split_line {
    ($y:expr, $t:ident) => {
        $y.split(" ")
            .map(|z| parse_input!(z, $t))
            .collect::<Vec<$t>>();
    };
}

struct xorrand {
    state: u64,
}
#[allow(dead_code)]
impl xorrand {
    fn rand(&mut self) -> u64 {
        let mut x = self.state;
        x ^= x << 13;
        x ^= x >> 7;
        x ^= x << 17;
        self.state = x;
        self.state.wrapping_mul(0x2545F4914F6CDD1Du64)
    }

    fn randint(&mut self, start: u64, end: u64) -> u64 {
        return (self.rand() % (end - start)) + start;
    }

    fn randfloat(&mut self) -> f64 {
        1.0 / (self.rand() as f64)
    }

    fn new(seed: u64) -> xorrand {
        xorrand { state: seed }
    }

    fn newtime() -> xorrand {
        let start = std::time::SystemTime::now();
        let ms = start
            .duration_since(std::time::UNIX_EPOCH)
            .unwrap()
            .as_secs();
        xorrand { state: ms }
    }

    fn shuffle<T: Clone>(&mut self, tgt: &mut Vec<T>) {
        for i in 0..tgt.len() - 1 {
            let j = self.randint(i as u64, tgt.len() as u64) as usize;
            let c = tgt[j].clone();
            tgt[j] = tgt[i].clone();
            tgt[i] = c;
        }
    }
}

#[derive(Debug, Clone)]
struct segment {
    start_0: i64,
    start_1: i64,
    end_0: i64,
    end_1: i64,
}

impl segment {}

fn solve(a: String, b: String) {
    let mut counters = vec![Vec::<i64>::new(); b.len() + 2];
    let mut start = 1;
    for i in 0..a.len() {
        for j in 0..start {
            if a.as_bytes()[i] == b.as_bytes()[j] {
                counters[j + 1].push(i as i64);
            }
            start = std::cmp::min(b.len(), std::cmp::max(start, j + 2));
        }
    }
    let mut end = a.len() as i64;
    for i in (0..b.len()).rev() {
        counters[i + 1].retain(|&x| x < end);
        end = *counters[i + 1].iter().max().unwrap();
    }
    counters[0].push(-1);
    counters[b.len() + 1].push(a.len() as i64);
    let mut best = 0;
    for i in 0..counters.len() - 1 {
        best = std::cmp::max(
            best,
            counters[i + 1].iter().max().unwrap() - counters[i].iter().min().unwrap() - 1,
        );
    }
    println!("{}", best);
}

fn main() {
    let mut input_line = String::new();
    io::stdin().read_line(&mut input_line).unwrap();
    let mut ss = String::new();
    io::stdin().read_line(&mut ss).unwrap();
    let ss = parse_input!(ss, String);
    let input_line = parse_input!(input_line, String);
    solve(input_line, ss);
    // let numTests = parse_input!(input_line, String);
    // solve(numTests as usize, &tgt);
    // // // let numTests = 1;
    // // let mut rng = rand::thread_rng();
    // for _ in 0..numTests {
    //     let mut input_line = String::new();
    //     io::stdin().read_line(&mut input_line).unwrap();
    //     let s = split_line!(input_line, i64);
    //     let mut input_line = String::new();
    //     io::stdin().read_line(&mut input_line).unwrap();
    //     let v = split_line!(input_line, i64);
    //     // let v: Vec<i64> = (0..10).map(|_| rng.gen_range(0, 10000)).collect();

    //     solve(s, v);
    // }
}


use std::cmp::Ordering::*;

fn input_split() -> Vec<u16> {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|elem| elem.parse().unwrap())
        .collect()
}

fn main() {
    let input = input_split();
    let first = input[0] * input[1] + 2 * input[3];
    let second = input[0] * input[2] + 2 * input[4];
    print!(
        "{}",
        match first.cmp(&second) {
            Less => "First",
            Greater => "Second",
            Equal => "Friendship",
        }
    );
}


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

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input)
        .expect("Failed to read line");
    let input = input.trim().split(" ").collect::<Vec<&str>>();

    let s = str_to_int(input[0]);
    let v1 = str_to_int(input[1]);
    let v2 = str_to_int(input[2]);
    let t1 = str_to_int(input[3]);
    let t2 = str_to_int(input[4]);

    let cli1 = s*v1 + 2*t1;
    let cli2 = s*v2 + 2*t2;

    if cli1 < cli2 {
        println!("First");
    } else if cli1 > cli2 {
        println!("second");
    } else {
        println!("Friendship");
    }
}

fn str_to_int(a:&str) -> i32 {
    a.parse::<i32>().unwrap()
}


fn main() {
    let n = read_line().parse::<isize>().unwrap();
    let mut s: isize = 0;

    for i in 1..=n {
        if i % 2 == 0 {
            s += i
        } else {
            s -= i
        }
    }
    println!("{}", s);
}


fn main() {
    let n = read_line().parse::<isize>().unwrap();
    let mut s: isize = 0;

    for i in 1..=n {
        if i % 2 == 0 {
            s += i
        } else {
            s -= i
        }
    }
    println!("{}", s);
}

fn read_line() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).expect("Ошибка чтения");

    buffer.trim().to_string()
}


use std::io;
use std::io::{Write};
use std::str;

/// Reads white-space separated tokens one at a time.
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![],
        }
    }

    /// Use "turbofish" syntax token::<T>() to select data type of next token.
    ///
    /// # Panics
    ///
    /// Panics if there's an I/O error or if the token cannot be parsed as T.
    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();
        }
    }
}

/// Same API as Scanner but nearly twice as fast, using horribly unsafe dark arts
/// **REQUIRES** Rust 1.34 or higher
pub struct UnsafeScanner<R> {
    reader: R,
    buf_str: Vec<u8>,
    buf_iter: str::SplitAsciiWhitespace<'static>,
}

impl<R: io::BufRead> UnsafeScanner<R> {
    pub fn new(reader: R) -> Self {
        Self {
            reader,
            buf_str: vec![],
            buf_iter: "".split_ascii_whitespace(),
        }
    }

    /// This function should be marked unsafe, but noone has time for that in a
    /// programming contest. Use at your own risk!
    pub fn token<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_ascii_whitespace())
            }
        }
    }
}

pub fn scanner_from_file(filename: &str) -> Scanner<io::BufReader<std::fs::File>> {
    let file = std::fs::File::open(filename).expect("Input file not found");
    Scanner::new(io::BufReader::new(file))
}

pub fn writer_to_file(filename: &str) -> io::BufWriter<std::fs::File> {
    let file = std::fs::File::create(filename).expect("Output file not found");
    io::BufWriter::new(file)
}

fn solve() {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let mut scan = Scanner::new(stdin.lock());
    let mut out = io::BufWriter::new(stdout.lock());
    let  n = scan.token::<i32>();
    let mut ans = n / 2;
    if n % 2 == 1 {
        ans = -ans-1;
    }
    out.write(format!("{}", ans).as_bytes()).unwrap();
    // let k = scan.token::<i32>();
    // let mut arr = scan.token::<String>().chars().collect::<Vec<char>>();
}

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


use std::mem;
use std::io;
use std::string;
use std::cmp::*;
use std::collections::*;

fn load() -> Vec<i32> {
    let mut line = String::new();
    io::stdin().read_line(&mut line).expect("Failed to read line");
    let vec: Vec<&str> = line.split(" ").collect();
    let mut data : Vec<i32> = Vec::new();
    for i in vec {
        let el : i32 = i.trim().parse().unwrap();
        data.push(el);
    }
    data
}

fn main() {
    let s = load()[0];
    println!("{}", ((s+1)/2)*(1-2*(s%2)));
}
// min, max
// HashSet, insert, contains
// Vec, len, sort


use std::io;

fn main() {
	let mut n = String::new();
	io::stdin().read_line(&mut n).unwrap();
	let n: i32 = n.trim().parse().unwrap();

	let mut ans = 0;
	for num in 1..=n {
		if num % 2 == 0 {
			ans += num;
		} else {
			ans -= num;
		}
	}
	println!("{}", ans);
}


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 read_line_val() -> i32 {
    return read_line().parse().unwrap();
}

fn main() {
    let n = read_line_val();

    let mut res = 0;

    for i in 1..n + 1 {
        if i % 2 == 0 {
            res += i;
        } else {
            res -= i;
        }
    }

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


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 read_line_val() -> i64 {
    return read_line().parse().unwrap();
}

fn main() {
    let n = read_line_val();

    let mut res = 0;

    for i in 1..n + 1 {
        if i % 2 == 0 {
            res += i;
        } else {
            res -= i;
        }
    }

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


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

    let res = children.iter().enumerate().max_by(|x, y| x.1.cmp(y.1)).unwrap().0 + 1;

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

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::stdin;

fn get_input(input: &mut String) {
    input.clear();
    stdin().read_line(input).expect("error");
}

fn main() {
    let mut input = String::new();
    get_input(&mut input);
    let mut numbers = input.trim().split_whitespace().filter_map(|n| n.parse::<u32>().ok());
    let n = numbers.next().unwrap();
    let k = numbers.next().unwrap();

    let mut local_n = 1;
    let mut local_k = k;
    while local_k % 2 != 1 {
        local_k >>= 1;
        local_n += 1;
    }

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


use std::io;
use std::cmp::Ordering;

fn sequence_position(level: u32, idx: u32) -> u32 {
    match level {
        1 => 1,
        _ => {
            let half_length = 2_u32.pow(level - 1);
            match idx.cmp(&half_length) {
                Ordering::Less => sequence_position(level - 1, idx),
                Ordering::Equal => level,
                Ordering::Greater => sequence_position(level - 1, idx - half_length)
            }
        }
    }
}

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

    let mut iter = input_str.trim().split_whitespace();
    let level: u32 = iter.next().unwrap().parse().unwrap();
    let position: u32 = iter.next().unwrap().parse().unwrap();

    println!("{}", sequence_position(level, position));
}


//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 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()
    }
}

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

    let s = input.bs();
    let mut p = 0;
    for i in 1.. {
        print!("{}", s[p] as char);
        p += i;
        if p >= s.len() {
            break;
        }
    }
}


#[allow(unused)] use std::io::*;
#[allow(unused)] use std::collections::*;
#[allow(unused)] use std::mem::*;
#[allow(unused)] use std::num::*;
#[allow(unused)] fn strarr() -> Vec<String> {
    let mut inp = String::new();
    stdin().read_line(&mut inp).ok();
    inp.split(' ').map(|x| x.trim()).filter(|x| x.len() != 0).map(|x| x.to_string()).collect() }
#[allow(unused)] macro_rules! scan { ($($x:ty), +) => {{
    let s = strarr(); let mut cnt : usize = 0;
    fn next<T>(cnt: &mut usize, p: &Vec<String>) -> T  where T:std::str::FromStr { *cnt += 1; p[*cnt-1].parse().ok().unwrap() }
    ($(next::<$x>(&mut cnt, &s)), +)
    }}; }
#[allow(unused)] macro_rules! arr { ($n:expr, $T:ty) => {{
    let mut s = strarr(); let mut v = Vec::new();
    for i in 0..$n { v.push(s[i as usize].parse::<$T>().unwrap()); } v
    }}; }

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

    'mainloop:
    for i in -2..=2
    {
        let c = arr!(5, i32);
        for j in -2..=2
        {
            let t = c[(j as usize) + 2];
            if t == 1
            {
                ans = i32::abs(i + j);
                break 'mainloop;
            }
        }
    }

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


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

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

#[inline(always)]
fn manhattan_distance(xa: i8, xb: i8, ya: i8, yb: i8) -> i8 {
	i8::abs(xb - xa) + i8::abs(yb - ya)
}

fn main() -> Result<(), Box<dyn Error>> {
	let mut matrix = vec![];
	let mut x = 0;
	let mut y = 0;
	for i in 0..5 {
		let rows: Vec<u8> = get_lines()?
			.split_whitespace()
			.map(|s| s.parse::<u8>().unwrap())
			.collect();
		for j in 0..5 {
			if rows[j] == 1 {
				x = j;
				y = i;
			}
		}
		matrix.push(rows);
	}
	print!("{}", manhattan_distance(x as i8, y as i8, 2, 2));
	Ok(())
}


use std::io::*;

fn reads_n<T: std::str::FromStr>(i: &mut StdinLock, n: u32) -> Vec<Vec<T>> {
    let mut v2 = Vec::new();
    for _ in 0..n {
        let mut s = String::new();
        i.by_ref().read_line(&mut s).ok();
        let v = s.trim()
            .split_whitespace()
            .map(|e| e.parse().ok().unwrap())
            .collect();
        v2.push(v);
    }
    v2
}

fn search_coord(matrix: Vec<Vec<u8>>) -> (u8, u8) {
    let mut x = 0;
    let mut y = 0;

    for item in matrix.into_iter() {
        x = 0;

        for i in item.into_iter() {
            if i == 1 {
                return (x, y);
            }
            x += 1;
        }
        y += 1
    }

    (0, 0)
}

fn distance(a: &(u8, u8), b: &(u8, u8)) -> u8 {
    let ax = a.0 as i64;
    let ay = a.1 as i64;
    let bx = b.0 as i64;
    let by = b.1 as i64;

    let diffx = if 0 < (bx - ax) { bx - ax } else { ax - bx };
    let diffy = if 0 < (by - ay) { by - ay } else { ay - by };

    diffx as u8 + diffy as u8
}

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

    let matrix: Vec<Vec<u8>> = reads_n(sin, 5);
    let coord = search_coord(matrix);

    let mut least: u8 = 255;
    let target: (u8, u8) = (2, 2);

    let dist = distance(&target, &coord);

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


use std::io;

fn main() {
    let mut guess = String::new();
    let mut i_2:i32 = 0;
    for i in 0_i32..5 {
        io::stdin()
        .read_line(&mut guess)
        .expect("Failed to read line");

        for elem in guess.chars() {
            if elem == '1'{
                i_2 +=1;

                let aux_i = if (i_2 % 5) == 0 {i_2 + 1} else {i_2};
                let line = aux_i/5;
                let col = i_2%5;
                let mut mv = col-2;
                mv = mv.abs() + (line - 3).abs();
                print!("{}",mv);
                std::process::exit(0);
            }
            else if elem == '0'{
                i_2 +=1;
            }
        }
        guess = String::new();
    }
}


use std::io;

fn get_vec_of_numbers() -> Vec<u8> {
    let mut buffer = String::new();
    io::stdin().read_line(&mut buffer).expect("Failed to read from stdin");
    let numbers: Vec<u8> = buffer.trim().split(" ").map(|x| x.trim().parse::<u8>().expect("Not an integer")).collect();
    numbers
}

fn main(){
    let mut matrix: Vec<Vec<u8>> = Vec::new();
    let mut index_of_one: u32 = 27;
    for i in 0..5 {
        let row = get_vec_of_numbers();
        match row.iter().position(|&x| x == 1) {
            Some(x) => {
                index_of_one = ((i*5)+1+x) as u32
            },
            None => {},
        }
        matrix.push(row);
    }
    let column_gap =  (13 - index_of_one) / 5;
    let minimum_number_of_moves = 13 - ((column_gap * 5) + index_of_one);
    println!("{}",minimum_number_of_moves);
}


use std::io::stdin;
fn main() {
    //let mut matrix: [[bool; 5]; 5 as usize] = [[false; 5 as usize]; 5 as usize];
    println!("{}", nearest_middle(parse_matrix()));
}
fn parse_matrix() -> Vec<bool> {
    let mut result: Vec<bool> = vec![];
    for _ in 0..5 {
        let mut row = String::new();
        stdin().read_line(&mut row).expect("");
        let rw: Vec<bool> = row
            .trim()
            .split_whitespace()
            .map(|e| {
                return match e.parse::<u8>() {
                    Ok(a) => {
                        if a == 1 {
                            return true;
                        } else {
                            return false;
                        }
                    }
                    _ => false,
                };
            })
            .collect();
        result.extend(rw);
    }
    result
}
fn nearest_middle(v: Vec<bool>) -> usize {
    if let Some(a) = v.iter().position(|val| *val) {
        return ((v.len() - 1) / 2) - a;
    } else {
        0
    }
}


use std::io::{self, Read};
use std::collections::BTreeSet;

fn main() -> () {
    let mut buffer = String::new();
    let stdin = io::stdin();
    let mut handle = stdin.lock();

    handle.read_to_string(&mut buffer).unwrap();

    let mut arr = buffer.split_whitespace().take(1).map(|x| x.parse::<i32>().unwrap() ).collect::<Vec<_>>();
    let n = arr[0] as usize;
    let mut num = buffer.split_whitespace().skip(1).take(1).next().unwrap();
    let mut b = vec![];
    for i in num.chars() {
        let digit = i as u32 - '0' as u32;
        b.push(digit);
    }
    let s : u32 = b.iter().sum();

    'outer: for i in 1..s+1 {
        if s % i == 0 {
            let ss = s / i;
            let mut segsum = 0;
            let mut count_seg = 0;
            for j in 0..n {
                segsum += b[j];
                if segsum == ss {
                    segsum = 0;
                    count_seg += 1;
                } else if segsum > ss {
                    continue 'outer;
                }
            }
            if count_seg > 1 {
                println!("YES");
                return
            }
        }
    }

    println!("NO");
}


use std::io;

fn main() {
    let mut input_text = String::new();
    io::stdin()
        .read_line(&mut input_text)
        .expect("failed to read from stdin");

    let trimmed = input_text.trim();
    let mut no_of_digits: u32 = 0;
    match trimmed.parse::<u32>() {
        Ok(i) => no_of_digits = i,
        Err(..) => println!("this was not an integer: {}", trimmed),
    };

    let mut input_digits = String::new();
 	io::stdin()
        .read_line(&mut input_digits)
        .expect("failed to read from stdin");
    let digits = input_digits.trim();

   	let mut answer : bool = false;
   	let total_sum: u32 = digits.chars().map(|x| x.to_digit(10).unwrap()).sum();
    for i in 1..total_sum {
        let mut sum: u32 = 0;
    	for c in digits.chars() {
			let current_digit = c.to_digit(10).unwrap();
			sum += current_digit;
			if sum == i {
				sum = 0;
			}
    	}
    	if sum == 0 {
    		answer = true;
    	}
    }
    if answer {
    	println!("YES");
    } else {
    	println!("NO");
    }
}


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

    let l: i32 = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line);
        line.trim().parse().unwrap()
    };

    let m: i32 = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line);
        line.trim().parse().unwrap()
    };

    let n: i32 = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line);
        line.trim().parse().unwrap()
    };

    let d: i32 = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line);
        line.trim().parse().unwrap()
    };

    let x = vec![k, l, m, n];
    let ret = (0..d).fold(0, |total, i| if x.iter().any(|&k| i % k == 0) {
        total + 1
    } else {
        total
    });
    println!("{:?}", ret);
}


use std::str::FromStr;

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

fn read_int<T: FromStr>() -> T{
    read_str().parse::<T>().ok().expect("Error")
}

fn main() {
    let (k, l, m, n, d): (u32, u32, u32, u32, u32) = (
        read_int(), read_int(), read_int(), read_int(), read_int());

    let mut total: u32 = 0;
    for index in 1..d {
        if index % k == 0 { total += 1; }
        else if index % l == 0 { total += 1; }
        else if index % m == 0 { total += 1; }
        else if index % n == 0 { total += 1; }
    }
    print!("{}", total);
}


//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_macros)]
macro_rules! m {
    ($c:tt, $x:expr, $y:expr) => {{
        let b = $y; let a = &mut $x;
        if b $c *a { *a = b; true } else { false }
    }};
}
#[allow(unused_macros)]
macro_rules! l {
    ($($v:ident),* = $i:ident.$f:ident $a:tt) => {
        $( let $v = $i.$f$a; )*
    };
    ($($v:ident),*:$t:ty = $i:ident.$f:ident $a:tt) => {
        $( let $v:$t = $i.$f$a; )*
    };
}
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 f(&mut self) ->    f64 { self.p()                }
    fn u(&mut self) ->  usize { self.p()                }
    fn sk(&mut self, n: usize) { self.it.nth(n - 1); }
    fn ii(&mut self, n: usize) -> impl Iterator<Item=i32> {
        self.ip(n).into_iter()
    }
    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 ip<T: FromStr>(&mut self, n: usize) -> impl Iterator<Item=T> where T::Err: Debug {
        self.vp(n).into_iter()
    }
    fn vp<T: FromStr>(&mut self, n: usize) -> Vec<T> where T::Err: Debug {
        (0..n).map(|_| self.p()).collect()
    }
}
//------------------- End rusT

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

    l!(r,c,rr,cc = input.u());
    let mut g = Vec::with_capacity(r * c);
    {
        l!(g0,x,y,z: i64 = input.p());
        g.push(g0);
        for _ in 1..r*c {
            let a = *g.last().unwrap();
            g.push((a * x + y) % z);
        }
    }

    let mut b = vec![vec![0; c]; r];
    let mut gi = g.into_iter();
    for i in 0..r {
        for j in 0..c {
            b[i][j] = gi.next().unwrap();
        }
    }
    let b = b;

    let mut x = vec![vec![0; c]; r];
    for i in 0..r {
        let b = &b[i];
        let mut q = VecDeque::new();
        for j in 0..c {
            if !q.is_empty() && *q.front().unwrap() + cc <= j {
                q.pop_front();
            }
            while !q.is_empty() && b[*q.back().unwrap()] >= b[j] {
                q.pop_back();
            }
            q.push_back(j);
            if j + 1 >= cc {
                x[i][j] = b[*q.front().unwrap()];
            }
        }
    }

    let mut sol = 0;
    for j in cc - 1..c {
        let mut q = VecDeque::new();
        for i in 0..r {
            if !q.is_empty() && *q.front().unwrap() + rr <= i {
                q.pop_front();
            }
            while !q.is_empty() && b[*q.back().unwrap() as usize][j] >= b[i][j] {
                q.pop_back();
            }
            q.push_back(i);
            if i + 1 >= rr {
                sol += b[*q.front().unwrap()][j];
            }
        }
    }
    println!("{}", sol);
}


#[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::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (writeln!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      m: usize,
      a: usize,
      b: usize,
      g0: u64,
      x: u64,
      y: u64,
      z: u64,
    }

    let mut hs = vec![];
    let mut g = g0;
    for _ in 0..n*m {
        hs.push(g);
        g = (g * x  + y) % z;
    }

    use std::collections::BTreeMap;

    let mut ans = 0;
    for i in 0..n-a+1 {
        let mut bs = BTreeMap::new();
        for i in i..i+a {
            for j in 0..b {
                let idx = i*m + j;
                *bs.entry(hs[idx]).or_insert(0) += 1;
            }
        }

        for j in 0..m-b+1 {
            if j > 0 {
                // Update map
                for i in i..i+a {
                    let idx = i*m + j-1;
                    let cnt = bs[&hs[idx]];
                    if cnt == 1 {
                        bs.remove(&hs[idx]);
                    } else {
                        *bs.entry(hs[idx]).or_insert(0) -= 1;
                    }

                    let idx = i*m + j+b-1;
                    *bs.entry(hs[idx]).or_insert(0) += 1;
                }
            }
            let (&v, _) = bs.iter().next().unwrap();
            ans += v;
        }
    }
    puts!("{}", ans);
}


#[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::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (writeln!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      m: usize,
      a: usize,
      b: usize,
      g0: u64,
      x: u64,
      y: u64,
      z: u64,
    }

    let mut hs = vec![];
    let mut g = g0;
    for _ in 0..n*m {
        hs.push(g);
        g = (g * x  + y) % z;
    }

    use std::collections::BTreeMap;

    const INF: u64 = 1 << 32;
    let mut mins = vec![vec![INF; m]; n];

    for i in 0..n-a+1 {
        let mut bs = BTreeMap::new();
        for j in 0..b {
            let idx = i*m + j;
            *bs.entry(hs[idx]).or_insert(0) += 1;
        }

        for j in 0..m-b+1 {
            if j > 0 {
                // Update map
                let idx = i*m + j-1;
                let cnt = bs[&hs[idx]];
                if cnt == 1 {
                    bs.remove(&hs[idx]);
                } else {
                    *bs.entry(hs[idx]).or_insert(0) -= 1;
                }

                let idx = i*m + j+b-1;
                *bs.entry(hs[idx]).or_insert(0) += 1;
            }
            let (&v, _) = bs.iter().next().unwrap();
            mins[i][j] = v;
        }
    }

    debug!(hs);
    debug!(mins);

    let mut ans = 0;
    for j in 0..m-b+1 {
        let mut bs = BTreeMap::new();
        for i in 0..a {
            *bs.entry(mins[i][j]).or_insert(0) += 1;
        }

        for i in 0..n-a+1 {
            if i > 0 {
                // Update map
                let prev = mins[i-1][j];
                let cnt = bs[&prev];
                if cnt == 1 {
                    bs.remove(&prev);
                } else {
                    *bs.entry(prev).or_insert(0) -= 1;
                }

                *bs.entry(mins[i][j]).or_insert(0) += 1;
            }

            let (&v, _) = bs.iter().next().unwrap();
            ans += v;
        }
    }
    puts!("{}", ans);
}


// ---------- begin Foldable Deque ----------
struct FoldableDeque<T, F> {
    front: Vec<(T, T)>,
    back: Vec<(T, T)>,
    op: F,
}

#[allow(dead_code)]
impl<T, F> FoldableDeque<T, F>
where T: Clone,
      F: Fn(&T, &T) -> T,
{
    fn new(op: F) -> Self {
        FoldableDeque {
            front: Vec::new(),
            back: Vec::new(),
            op: op,
        }
    }
    fn find(&self) -> Option<T> {
        match (self.front.last(), self.back.last()) {
            (Some(a), Some(b)) => Some((self.op)(&a.1, &b.1)),
            (Some(a), None) => Some(a.1.clone()),
            (None, Some(b)) => Some(b.1.clone()),
            (None, None) => None,
        }
    }
    fn clear(&mut self) {
        self.front.clear();
        self.back.clear();
    }
    fn len(&self) -> usize {
        self.front.len() + self.back.len()
    }
    fn push_back(&mut self, val: T) {
        let sum = if let Some(p) = self.back.last() {
            (self.op)(&p.1, &val)
        } else {
            val.clone()
        };
        self.back.push((val, sum));
    }
    fn push_front(&mut self, val: T) {
        let sum = if let Some(p) = self.front.last() {
            (self.op)(&val, &p.1)
        } else {
            val.clone()
        };
        self.front.push((val, sum));
    }
    fn pop_front(&mut self) -> Option<T> {
        if self.len() == 0 {
            return None;
        }
        if self.front.is_empty() {
            let a = self.back.clone();
            let m = (self.back.len() + 1) / 2;
            self.back.clear();
            let (f, b) = a.split_at(m);
            for v in f.iter().rev() {
                self.push_front(v.0.clone());
            }
            for v in b.iter() {
                self.push_back(v.0.clone());
            }
        }
        self.front.pop().map(|p| p.0)
    }
    fn pop_back(&mut self) -> Option<T> {
        if self.len() == 0 {
            return None;
        }
        if self.back.is_empty() {
            let a = self.front.clone();
            let m = self.front.len() / 2;
            self.front.clear();
            let (f, b) = a.split_at(m);
            for v in f.iter().rev() {
                self.push_front(v.0.clone());
            }
            for v in b.iter() {
                self.push_back(v.0.clone());
            }
        }
        self.back.pop().map(|p| p.0)
    }
}
// ---------- end Foldable Deque ----------

use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let h: usize = it.next().unwrap().parse().unwrap();
    let w: usize = it.next().unwrap().parse().unwrap();
    let r: usize = it.next().unwrap().parse().unwrap();
    let c: usize = it.next().unwrap().parse().unwrap();
    let mut g: u64 = it.next().unwrap().parse().unwrap();
    let x: u64 = it.next().unwrap().parse().unwrap();
    let y: u64 = it.next().unwrap().parse().unwrap();
    let z: u64 = it.next().unwrap().parse().unwrap();
    let mut a = vec![0u32; h * w];
    for a in a.iter_mut() {
        *a = g as u32;
        g = (g * x + y) % z;
    }
    let mut b = vec![0u32; h * (w - c + 1)];
    let op = |a: &u32, b: &u32| std::cmp::min(*a, *b);
    let mut q = FoldableDeque::new(op);
    for (i, a) in a.chunks(w).enumerate() {
        for a in a.iter().take(c - 1) {
            q.push_back(*a);
        }
        for (b, a) in b[i..].iter_mut().step_by(w - c + 1).zip(a.iter().skip(c - 1)) {
            q.push_back(*a);
            *b = q.find().unwrap();
            q.pop_front();
        }
    }
    let mut ans = 0u64;
    for b in b.chunks(h) {
        q.clear();
        for b in b.iter().take(r - 1) {
            q.push_back(*b);
        }
        for b in b.iter().skip(r - 1) {
            q.push_back(*b);
            ans += q.find().unwrap() as u64;
            q.pop_front();
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


use std:: io;

fn read_ints() -> Vec<u8> {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.split_whitespace().filter_map(|ss| ss.parse().ok()).collect()
}

fn main() {
    let k: u8;
    if let [_, _k] = read_ints()[..] { k = _k; } else { panic!("x"); }

    let a: Vec<u8> = read_ints();

    let mut ans: u8 = 0;
    let mut flag: usize = 0;
    for (i, aa) in a.iter().enumerate() {
        if aa <= &k {
            ans += 1;
        } else {
            flag = i;
            break;
        }
    }
    flag = a.len() - flag;
    for (i, aa) in a.iter().rev().enumerate() {
        if i <= flag && aa <= &k {
            ans += 1;
        } else {
            break;
        }
    }

    println!("{}", ans);

    return;
}


fn main() {
    let stdin = std::io::stdin();
    let lock = stdin.lock();
    let mut r = io::Reader::new(lock);
    let mut w = io::Writer::new();

    let l = ['c', 'o', 'd', 'e', 'f', 'o', 'r', 'c', 'e', 's'];
    let mut v = vec![1usize; 10];
    let mut max_comb = 1;
    let mut selection = 0;
    let n: usize = r.read()[0];

    while max_comb <= n {
        for i in 0..v.len() {
            let comb = compute(&v, i);
            if comb > max_comb {
                selection = i;
                max_comb = comb;
            }
        }
        v[selection] += 1;
    }

    for i in 0..v.len() {
        for _ in 0..v[i] {
            w.push(l[i]);
        }
    }
    w.push('\n');

    w.write();
}

fn compute(v: &Vec<usize>, i: usize) -> usize {
    let mut comb = 1;
    for j in 0..v.len() {
        comb *= if j == i { v[j] + 1 } else { v[j] }
    }

    comb
}

pub mod io {
    use std::fmt::{Debug, Display};
    use std::io::{BufRead, StdinLock};
    use std::str::FromStr;

    pub struct Reader<'a> {
        buffer: String,
        lock: StdinLock<'a>,
    }

    impl<'a> Reader<'a> {
        pub fn new(lock: StdinLock<'a>) -> Self {
            Reader {
                buffer: String::with_capacity(4 * 1024 * 1024),
                lock,
            }
        }

        pub fn read<T>(&mut self) -> Vec<T>
        where
            T: Copy + FromStr + Display,
            <T as FromStr>::Err: Debug,
        {
            self.buffer.clear();

            self.lock
                .read_line(&mut self.buffer)
                .expect("Failed to get input");

            self.buffer
                .trim()
                .split_whitespace()
                .map(|x| x.parse().expect("Failed to parse value"))
                .collect()
        }
    }

    pub struct Writer {
        buffer: String,
    }

    impl Writer {
        pub fn new() -> Self {
            Writer {
                buffer: String::with_capacity(4 * 1024 * 1024),
            }
        }

        pub fn push<T: Display>(&mut self, data: T) {
            self.buffer.push_str(&format!("{}", data));
        }

        pub fn pushw<T: Display>(&mut self, data: T) {
            self.buffer.push_str(&format!("{} ", data));
        }

        pub fn pushln<T: Display>(&mut self, data: T) {
            self.buffer.push_str(&format!("{}\n", data));
        }

        pub fn write(&self) {
            print!("{}", self.buffer);
        }
    }
}


#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    assert_eq!(!0usize, std::usize::MAX); //🙊
    assert!(0 == 0); //😇
    let k = io.read::<i64>();
    io.write("codeforce");
    for _ in 0..k {
        io.write("s");
    }
}

static MX: usize = 1010101;
static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


fn solve() {
    let mut n: i32 = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().parse().unwrap()
    };

    let mut v = Vec::new();
    let mut i = 0;
    for i in 0..10 {
        v.push((i, 1));
    }
    while n > 0 {
        v[i].1 += 1;
        i += 1;
        i %= 10;
        n /= 2;
    }

    let s = "codeforces";
    for a in v {
        print!("{}", (s.chars().nth(a.0).unwrap()).to_string().repeat(a.1));
    }
}

fn main() {
    // let t: u32 = {
    //     let mut buf = String::new();
    //     std::io::stdin().read_line(&mut buf).unwrap();
    //     buf.trim_end().parse().unwrap()
    // };

    // for _ in 0..t {}
    solve();
}


fn solve() {
    let mut n: i32 = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().parse().unwrap()
    };

    let mut v = vec![1; 10];

    let mut i = 0;
    loop {
        let mut m = v.iter().fold(1, |mul, a| mul * a);
        if m >= n {
            break;
        }
        v[i] += 1;
        i += 1;
        i %= 10;
    }

    for (i, a) in v.iter().enumerate() {
        print!(
            "{}",
            "codeforces"
                .chars()
                .nth(i)
                .unwrap()
                .to_string()
                .repeat(*a as usize)
        );
    }
}

fn main() {
    // let t: u32 = {
    //     let mut buf = String::new();
    //     std::io::stdin().read_line(&mut buf).unwrap();
    //     buf.trim_end().parse().unwrap()
    // };

    // for _ in 0..t {}
    solve();
}


use std::io;
fn main(){
    let mut s=String::new();
    io::stdin().read_line(&mut s).expect("Something is wrong");
    let n=&s[0..s.find(' ').unwrap()];
    let mut n:i64=n.trim().parse().unwrap();
    let k=&s[s.find(' ').unwrap()+1..s.len()];
    let mut k:i64=k.trim().parse().unwrap();
    let mut a:i64=n;
    let mut p:i64=0;
    while a%10==0{
        p+=1;
        a/=10;
    }
    if p>=k{println!("{} {}",n,a)}
    else{k=k-p;
    match a%10{
        1|3|7|9=>{for c in 0..k{n*=10}println!("{}",n)},
        5=>{while a%5==0{p+=1;a/=5;}if k>=p{for c in 0..p{n*=2}for c in 0..k-p{n*=10}}else{for c in 0..k{n*=2}}println!("{}",n);},
        _=>{while a%2==0{p+=1;a/=2;}if k>=p{for c in 0..p{n*=5}for c in 0..k-p{n*=10}}else{for c in 0..k{n*=5}}println!("{}",n);},
    }
}
}


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 mut res = 0usize;
    let n: usize = scan.next();
    let m: usize = scan.next();
    let limit: usize = n.max(m);
    for i in 0..limit {
        for j in 0..limit {
            if i * i + j == n && i + j * j == m {
                res += 1;
            }
        }
    }
    println!("{}", res);
}

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


fn read_line() -> Option<String> {
    let stdin = std::io::stdin();
    let mut line = String::new();
    if stdin.read_line(&mut line).unwrap_or(0) > 0 {
        Some(line.trim().into())
    } else {
        None
    }
}

fn main() {
    fn should_flip(c: char) -> bool {
        (
            (c.is_digit(10) && (c as u8 - '0' as u8) % 2 == 0) ||
            (['a', 'e', 'i', 'o', 'u'].iter().find(|&&a| a == c).is_some())
        )
    }
    let flips = read_line()
        .expect("should have line")
        .chars()
        .fold(0, |acc, c| if should_flip(c) { acc + 1 } else { acc });
    println!("{}", flips);
}