// -*- outline-regexp: "[ ]*//[*]+"; eval: (outline-minor-mode 1) eval: (outline-hide-body) -*-
//* Imports
#![allow(unused_imports)]
#![allow(dead_code)]
#![allow(unused_variables)]
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::LinkedList;
use std::collections::VecDeque;
use std::io::Cursor;
use std::io::{self, prelude::*};
use std::str;
use std::num::Wrapping;
macro_rules! S {
    ($i:ident $sel:ident $e:block) => (
struct $i<'a> {
    rw: RWE<'a>,
}

impl<'a> $i<'a> {
    fn new(rw: RWE<'a>) -> Self {
        Self { rw }
    }
}

impl<'a> Solution<'a> for $i<'a> {
    fn rw(&mut $sel) -> &mut RWE<'a> {
        &mut $sel.rw
    }

    fn solve(&mut $sel) $e
}
    )
}
//* Solution
struct Ring {
    p: Wrapping<i64>,
    f: Option<Vec<i64>>
}

impl Ring {
    fn new() -> Self { Self { p: Wrapping(998244353), f: None } }

    fn mult(&self, a:i64, b: i64) -> i64 {
        (((Wrapping(a) * Wrapping(b)) % self.p + self.p) % self.p).0
    }

    fn precompute_factorial(&mut self, v: i64) {
        let mut r = 1;
        let mut tmp = vec![1; v as usize + 1];
        for j in 2..=v {
            r = self.mult(r, j);
            tmp[j as usize] = r;
        }
        self.f = Some(tmp);
    }

    fn factorial(&mut self, v: i64) -> i64 {
        if let None = self.f {
            self.precompute_factorial(v);
        }
        self.precompute_factorial(v);
        *self.f.as_ref().unwrap().get(v as usize).unwrap()
    }

    fn bin_pow(&self, mut n:i64, mut k: i64) -> i64 {
        let mut res = 1;
        while k > 0 {
            if k & 1 == 1 {
                res = self.mult(res, n);
            }
            n = self.mult(n, n);
            k >>= 1;
        }
        res
    }

    fn inverse(&self, n:i64) -> i64 {
        self.bin_pow(n, self.p.0-2)
    }
}

S!(SolutionA self {
    let n: i64 = self.rw().scan();
    let m: i64 = self.rw().scan();
    let mut ans;
    if m <= 2 {
        ans = 0;
    } else {
        let mut r = Ring::new();
        let a = r.factorial(m);
        let bp = r.factorial(n-1);
        let bz = r.factorial(m-(n-1));
        let br = r.inverse(bz);
        let b = r.inverse(bp);
        ans  = r.mult(a, b);
        ans = r.mult(ans, br);
        ans = r.mult(ans, n-2);
        ans = r.mult(ans, r.bin_pow(2, n-3));
    }
    writeln!(self.rw(), "{}", ans).unwrap();
});

fn main() {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let scan = Scanner::new(stdin.lock());
    let out = io::BufWriter::new(stdout.lock());
    let r = RWE::Stdio(scan, out);
    //* Main
    let mut s = SolutionA::new(r);
    s.solve();
}

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

    #[test]
    fn test_fermat() {
        let r = Ring::new();
        for i in 3..1000 {
            assert_eq!(r.bin_pow(i, 998244352), 1);
        }
    }

    #[test]
    fn test_inverse() {
        let r = Ring::new();
        for i in 1..1000 {
            assert_eq!(r.mult(r.inverse(i), i), 1, "testing {}", i);
        }
    }

    #[test]
    fn test_case_a() {
        fn tc(input: &'static str, expected: &'static str) {
            tcc(&|rwe| Box::new(SolutionA::new(rwe)), input, expected);
        }
        tc("2 5", "0\n");
        tc("3 4", "6\n");
        tc("3 3", "3\n");
        tc("4 4", "16\n");
        tc("5 5", "60\n");
        tc("3 5", "10\n");
        tc("42 1337", "806066790\n");
        tc("100000 200000", "707899035\n");
    }

    //** Test Utils
    fn tcc<'a>(f: &dyn Fn(RWE<'a>) -> Box<dyn Solution<'a>>, input: &'a str, expected: &str) {
        let s = Scanner::new(Cursor::new(input));
        let w = vec![];
        let r = RWE::InMemory(s, w);

        let mut sol = f(r);
        sol.solve();
        if let RWE::InMemory(r, w) = sol.rw() {
            let output = std::str::from_utf8(w.as_mut_slice()).unwrap();
            assert_eq!(expected, output);
        } else {
            unreachable!("Huh, how'd we manage to pass stdio?");
        }
    }
}

//*** IO
struct Scanner<R> {
    reader: R,
    buf_str: Vec<u8>,
    buf_iter: str::SplitAsciiWhitespace<'static>,
}

impl<R: io::BufRead> Scanner<R> {
    fn new(reader: R) -> Self {
        Self {
            reader,
            buf_str: Vec::new(),
            buf_iter: "".split_ascii_whitespace(),
        }
    }

    fn t<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())
            }
        }
    }
}

trait RW<B: BufRead, W: Write> {
    fn reader(&mut self) -> &mut Scanner<B>;
    fn writer(&mut self) -> &mut W;
}

enum RWE<'a> {
    InMemory(Scanner<Cursor<&'a str>>, Vec<u8>),
    Stdio(
        Scanner<std::io::StdinLock<'a>>,
        std::io::BufWriter<std::io::StdoutLock<'a>>,
    ),
}

impl<'a> RWE<'a> {
    fn scan<T: str::FromStr>(&mut self) -> T {
        match self {
            RWE::InMemory(r, _) => r.t(),
            RWE::Stdio(r, _) => r.t(),
        }
    }
}

impl<'a> std::io::Write for RWE<'a> {
    fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
        match self {
            RWE::InMemory(_, w) => w.write(buf),
            RWE::Stdio(_, w) => w.write(buf),
        }
    }
    fn flush(&mut self) -> io::Result<()> {
        match self {
            RWE::InMemory(_, w) => w.flush(),
            RWE::Stdio(_, w) => w.flush(),
        }
    }
}

trait Solution<'a> {
    fn rw(&mut self) -> &mut RWE<'a>;
    fn solve(&mut self);
}


mod scanner {
    use std::io::{Read, Stdin, stdin};
    use std::str::FromStr;

    pub struct Scanner<T: Read> {
        source: T,
        buffer: Vec<u8>,
        available: usize,
        ptr: usize
    }

    impl<T: Read> Scanner<T> {
        pub fn new(source: T) -> Scanner<T> {
            const BUFFER_SIZE: usize = 32 * 1024 * 1024; // 32 MB of buffer size
            Scanner {
                source,
                buffer: vec![0u8; BUFFER_SIZE],
                available: 0,
                ptr: 0
            }
        }

        fn read_block(&mut self) {
            self.available = self.source.read(self.buffer.as_mut()).unwrap();
            self.ptr = 0;
        }

        fn read_byte(&mut self) -> Option<u8> {
            if self.ptr >= self.available {
                self.read_block();
                if self.available == 0 {
                    // Hit EOF.
                    return None;
                }
            }

            let value = self.buffer[self.ptr];
            self.ptr += 1;

            Some(value)
        }

        pub fn read_token(&mut self) -> Option<String> {
            // Skip any leading whitespace characters.
            let mut b;
            loop {
                b = match self.read_byte() {
                    Some(b) => b,
                    None => return None
                };
                if !(b as char).is_ascii_whitespace() {
                    break;
                }
            }

            let mut buffer = String::new();
            loop {
                if (b as char).is_ascii_whitespace() {
                    break;
                }

                buffer.push(b as char);
                b = match self.read_byte() {
                    Some(b) => b,
                    None => break
                };
            }

            Some(buffer)
        }

        pub fn read<U: FromStr>(&mut self) -> Option<U> {
            let token = self.read_token()?;
            <U as FromStr>::from_str(token.as_str()).ok()
        }
    }

    impl Scanner<Stdin> {
        pub fn from_stdin() -> Scanner<Stdin> {
            Scanner::new(stdin())
        }
    }
}

use scanner::Scanner;

const MOD: i64 = 998244353i64;

struct Binom {
    fact: Vec<i64>,
    inv: Vec<i64>,
    factinv: Vec<i64>,
}

impl Binom {
    fn new(max_n: usize) -> Self {
        let mut b = Binom {
            fact: vec![0i64; max_n + 1],
            inv: vec![0i64; max_n + 1],
            factinv: vec![0i64; max_n + 1],
        };

        b.fact[0] = 1;
        for i in 1..=max_n {
            b.fact[i] = b.fact[i - 1] * i as i64 % MOD;
        }

        b.inv[1] = 1;
        for i in 2..=max_n {
            b.inv[i] = (-MOD / i as i64 * b.inv[(MOD % i as i64) as usize] % MOD + MOD) % MOD;
        }

        b.factinv[0] = 1;
        for i in 1..=max_n {
            b.factinv[i] = b.factinv[i - 1] * b.inv[i] % MOD;
        }

        b
    }

    fn binom(&self, n: i64, m: i64) -> i64 {
        let n = n as usize;
        let m = m as usize;
        self.fact[n] * self.factinv[m] % MOD * self.factinv[n - m] % MOD
    }
}

fn fast_pow(mut base: i64, mut e: i64) -> i64 {
    let mut res = 1i64;
    while e > 0 {
        if e & 1 == 1 {
            res = res * base % MOD;
        }
        base = base * base % MOD;
        e >>= 1;
    }

    res
}

fn main() {
    let mut reader = Scanner::from_stdin();
    let binom = Binom::new(200000);

    let n: i64 = reader.read().unwrap();
    let m: i64 = reader.read().unwrap();
    if n <= 2 {
        println!("0");
        return;
    }

    let ans = binom.binom(m, n - 1) * (n - 2) % MOD * fast_pow(2i64, n - 3) % MOD;
    println!("{}", ans);
}


#![allow(unused)]

use kyoproio::*;
use std::{
    collections::*,
    iter,
    io::{self, prelude::*},
    mem::{replace, swap},
};

fn main() -> io::Result<()> {
    std::thread::Builder::new()
        .stack_size(50 * 1024 * 1024)
        .spawn(solve)?
        .join()
        .unwrap();
    Ok(())
}

fn solve() {
    let stdin = io::stdin();
    let mut kin = Input::new(stdin.lock());
    let stdout = io::stdout();
    let mut out = io::BufWriter::new(stdout.lock());
    macro_rules! output {
        ($($args:expr),+) => { write!(&mut out, $($args),+) };
    }

    const MOD: i64 = 998244353;
    let (n, m): (i64, i64) = kin.input();

    let comb = Combination::new((m + 1) as usize, MOD);
    let mut ans = 0;
    for h in 2..=m {
        ans += comb.comb(h - 1, n - 2) * mod_pow(2, n - 2, MOD) % MOD * (n - 2) % MOD;
        ans %= MOD;
    }
    ans *= mod_inv(2, MOD);
    ans %= MOD;
    output!("{}\n", ans);
}

pub fn mod_pow(mut a: i64, mut b: i64, m: i64) -> i64 {
    let mut y = 1;
    while b > 0 {
        if b & 1 == 1 {
            y = y * a % m;
        }
        a = a * a % m;
        b >>= 1;
    }
    y
}
pub fn mod_inv(x: i64, m: i64) -> i64 {
    mod_pow(x, m - 2, m)
}
pub struct Combination {
    m: i64,
    fact: Vec<i64>,
}
impl Combination {
    pub fn new(size: usize, m: i64) -> Self {
        let mut comb = Self {
            m,
            fact: Vec::new(),
        };
        comb.resize(size);
        comb
    }
    pub fn resize(&mut self, size: usize) {
        let old_len = self.fact.len();
        self.fact.resize(size + 1, 0);
        for i in old_len..size + 1 {
            self.fact[i] = if i == 0 {
                1
            } else {
                i as i64 * self.fact[i - 1] % self.m
            };
        }
    }
    pub fn fact(&self, x: i64) -> i64 {
        self.fact[x as usize]
    }
    pub fn perm(&self, a: i64, b: i64) -> i64 {
        if a >= b {
            self.fact(a) * mod_inv(self.fact(a - b), self.m) % self.m
        } else {
            0
        }
    }
    pub fn comb(&self, a: i64, b: i64) -> i64 {
        if a >= b {
            self.fact(a) * mod_inv(self.fact(b) * self.fact(a - b) % self.m, self.m) % self.m
        } else {
            0
        }
    }
}
// -----------------------------------------------------------------------------
pub mod kyoproio {
    #![warn(unused)]

    pub use std::io::prelude::*;

    pub struct Input<R> {
        src: R,
        buf: String,
        pos: usize,
    }
    impl<R: BufRead> Input<R> {
        pub fn new(src: R) -> Self {
            Self {
                src,
                buf: String::with_capacity(256),
                pos: 0,
            }
        }
        pub fn str(&mut self) -> &str {
            loop {
                if self.pos >= self.buf.len() {
                    self.buf.clear();
                    let len = self.src.read_line(&mut self.buf).expect("io error");
                    self.pos = 0;
                    if len == 0 {
                        return &self.buf
                    }
                }
                let range = self.pos
                    ..self.buf[self.pos..]
                        .find(|c: char| c.is_ascii_whitespace())
                        .map(|i| i + self.pos)
                        .unwrap_or(self.buf.len());
                self.pos = range.end + 1;
                if range.end - range.start > 0 {
                    return &self.buf[range];
                }
            }
        }
        pub fn bytes(&mut self) -> &[u8] {
            self.str().as_ref()
        }
        pub fn input<T: InputParse>(&mut self) -> T {
            self.input_fallible().expect("input error")
        }
        pub fn input_fallible<T: InputParse>(&mut self) -> Result<T> {
            T::input(self)
        }
        pub fn iter<T: InputParse>(&mut self) -> Iter<T, R> {
            Iter {
                input: self,
                _t: std::marker::PhantomData,
            }
        }
    }
    pub struct Iter<'a, T, R> {
        input: &'a mut Input<R>,
        _t: std::marker::PhantomData<T>,
    }
    impl<'a, T: InputParse, R: BufRead> Iterator for Iter<'a, T, R> {
        type Item = T;
        fn next(&mut self) -> Option<Self::Item> {
            Some(self.input.input())
        }
    }
    type Result<T> = std::result::Result<T, Box<dyn std::error::Error + 'static>>;
    pub trait InputParse: Sized {
        fn input<R: BufRead>(input: &mut Input<R>) -> Result<Self>;
    }
    macro_rules! input_from_str_impls {
        { $($T:ty)* } => {
            $(impl InputParse for $T {
                fn input<R: BufRead>(input: &mut Input<R>) -> Result<Self> {
                    input.str().parse::<$T>().map_err(|e| e.into())
                }
            })*
        };
    }
    macro_rules! input_tuple_impls {
        { $(($($T:ident),+))* } => {
            $(impl<$($T:InputParse),+> InputParse for ($($T),+) {
                fn input<R: BufRead>(input: &mut Input<R>) -> Result<Self> {
                    Ok(($($T::input(input)?),+))
                }
            })*
        };
    }
    input_from_str_impls! {
        String char bool f32 f64
        isize i8 i16 i32 i64 i128
        usize u8 u16 u32 u64 u128
    }
    input_tuple_impls! {
        (A, B)
        (A, B, C)
        (A, B, C, D)
        (A, B, C, D, E)
        (A, B, C, D, E, F)
        (A, B, C, D, E, F, G)
    }
}


use std::io::stdin;
use std::cmp::max;

fn my_pow(modulo: i64, a: i64, k: i64) -> i64{
    let mut rule = k;
    let mut power = a;
    let mut res = 1;
    loop {
        if rule < 1 {
            break;
        }
        if rule % 2 == 1{
            res = (res * power) % modulo;
        }
        rule /= 2;
        power = (power * power) % modulo;
    }
    res % modulo
}

fn c_n_k(modulo: i64, n: i64, k: i64) -> i64{
    let mut res = 1;
    for j in 1..(k + 1) {
        res = (res * (n - k + j)) % modulo;
        res = (res * my_pow(modulo, j, modulo - 2)) % modulo;
    }
    res % modulo
}

fn main() {
    let d:i64 = 998244353;
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    let k:i64 = iter.next().unwrap().parse().unwrap();
    let n:i64 = iter.next().unwrap().parse().unwrap();
    let sequence = c_n_k(d, n, k - 1);
    let double_sequence = (sequence * (k - 2)) % d;
    let sequence_with_peak = double_sequence * my_pow(d, 2, k - 3);
    println!("{}", sequence_with_peak % d);
}


#[doc = " https://github.com/hatoo/competitive-rust-snippets"]
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[macro_export]
macro_rules ! chmax { ( $ x : expr , $ ( $ v : expr ) ,+ ) => { $ ( $ x = std :: cmp :: max ( $ x ,$ v ) ; ) + } ; }
#[macro_export]
macro_rules ! chmin { ( $ x : expr , $ ( $ v : expr ) ,+ ) => { $ ( $ x = std :: cmp :: min ( $ x ,$ v ) ; ) + } ; }
#[macro_export]
macro_rules ! max { ( $ x : expr ) => ( $ x ) ; ( $ x : expr , $ ( $ xs : expr ) ,+ ) => { std :: cmp :: max ( $ x , max ! ( $ ( $ xs ) ,+ ) ) } ; }
#[macro_export]
macro_rules ! min { ( $ x : expr ) => ( $ x ) ; ( $ x : expr , $ ( $ xs : expr ) ,+ ) => { std :: cmp :: min ( $ x , min ! ( $ ( $ xs ) ,+ ) ) } ; }
#[macro_export]
macro_rules ! dvec { ( $ t : expr ; $ len : expr ) => { vec ! [ $ t ; $ len ] } ; ( $ t : expr ; $ len : expr , $ ( $ rest : expr ) ,* ) => { vec ! [ dvec ! ( $ t ; $ ( $ rest ) ,* ) ; $ len ] } ; }
#[macro_export]
macro_rules ! cfor { ( ; $ ( $ rest : tt ) * ) => { cfor ! ( ( ) ; $ ( $ rest ) * ) } ; ( $ ( $ init : stmt ) ,+; ; $ ( $ rest : tt ) * ) => { cfor ! ( $ ( $ init ) ,+; ! false ; $ ( $ rest ) * ) } ; ( $ ( $ init : stmt ) ,+; $ cond : expr ; ; $ body : block ) => { cfor ! { $ ( $ init ) ,+; $ cond ; ( ) ; $ body } } ; ( $ ( $ init : stmt ) ,+; $ cond : expr ; $ ( $ step : expr ) ,+; $ body : block ) => { { $ ( $ init ; ) + while $ cond { let mut _first = true ; let mut _continue = false ; loop { if ! _first { _continue = true ; break } _first = false ; $ body } if ! _continue { break } $ ( $ step ; ) + } } } ; }
#[doc = " main"]
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[macro_export]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut parser = Parser :: from_str ( $ s ) ; input_inner ! { parser , $ ( $ r ) * } } ; ( parser = $ parser : ident , $ ( $ r : tt ) * ) => { input_inner ! { $ parser , $ ( $ r ) * } } ; ( new_stdin_parser = $ parser : ident , $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let reader = std :: io :: BufReader :: new ( stdin . lock ( ) ) ; let mut $ parser = Parser :: new ( reader ) ; input_inner ! { $ parser , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { input ! { new_stdin_parser = parser , $ ( $ r ) * } } ; }
#[macro_export]
macro_rules ! input_inner { ( $ parser : ident ) => { } ; ( $ parser : ident , ) => { } ; ( $ parser : ident , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ parser , $ t ) ; input_inner ! { $ parser $ ( $ r ) * } } ; }
#[macro_export]
macro_rules ! read_value { ( $ parser : ident , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ parser , $ t ) ) ,* ) } ; ( $ parser : ident , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ parser , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ parser : ident , chars ) => { read_value ! ( $ parser , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ parser : ident , usize1 ) => { read_value ! ( $ parser , usize ) - 1 } ; ( $ parser : ident , $ t : ty ) => { $ parser . next ::<$ t > ( ) . expect ( "Parse error" ) } ; }
use std::io;
use std::io::BufRead;
use std::str;
pub struct Parser<R> {
    reader: R,
    buf: Vec<u8>,
    pos: usize,
}
impl Parser<io::Empty> {
    pub fn from_str(s: &str) -> Parser<io::Empty> {
        Parser {
            reader: io::empty(),
            buf: s.as_bytes().to_vec(),
            pos: 0,
        }
    }
}
impl<R: BufRead> Parser<R> {
    pub fn new(reader: R) -> Parser<R> {
        Parser {
            reader: reader,
            buf: vec![],
            pos: 0,
        }
    }
    pub fn update_buf(&mut self) {
        self.buf.clear();
        self.pos = 0;
        loop {
            let (len, complete) = {
                let buf2 = self.reader.fill_buf().unwrap();
                self.buf.extend_from_slice(buf2);
                let len = buf2.len();
                if len == 0 {
                    break;
                }
                (len, buf2[len - 1] <= 0x20)
            };
            self.reader.consume(len);
            if complete {
                break;
            }
        }
    }
    pub fn next<T: str::FromStr>(&mut self) -> Result<T, T::Err> {
        loop {
            let mut begin = self.pos;
            while begin < self.buf.len() && (self.buf[begin] <= 0x20) {
                begin += 1;
            }
            let mut end = begin;
            while end < self.buf.len() && (self.buf[end] > 0x20) {
                end += 1;
            }
            if begin != self.buf.len() {
                self.pos = end;
                return str::from_utf8(&self.buf[begin..end]).unwrap().parse::<T>();
            } else {
                self.update_buf();
            }
        }
    }
}
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }
#[doc = " https://github.com/hatoo/competitive-rust-snippets"]
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}
const MO: i64 = 998244353;
fn solve() {
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    input!{
        n:i64,
        m:i64,
    }
    let mut mc = ModComb::new(200200, MO);
    let mut loc = 0;
    for k in n-1..=m {
        loc += (n-2) * mc.nCk(k-1,n-2);
        loc %= MO;
    }
    let mut tot = 0;
    for i in 2..=n-1 {
        let L = i-1;
        let R = n-i;
        tot += loc * mc.nCk(n-3,min(L-1,R-1));
        tot %= MO;
    }
    tot %= MO;
    writeln!(out,"{}",tot);
}
pub mod modular {
    const M: i64 = 998244353;
    #[derive(Debug, Clone, Copy, Default, PartialOrd, Ord, PartialEq, Eq)]
    pub struct Mod(pub i64);
    impl ::std::fmt::Display for Mod {
        fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
            write!(f, "{}", self.0)
        }
    }
    impl Mod {
        pub fn new(v: i64) -> Mod {
            Mod((v + M) % M)
        }
        pub fn pow(self, mut r: i64) -> Mod {
            let mut k = self;
            let mut ret = 1.into();
            while r > 0 {
                if r % 2 != 0 {
                    ret = ret * k;
                }
                r /= 2;
                k = k * k;
            }
            ret
        }
        pub fn recip(self) -> Mod {
            self.pow(M - 2)
        }
    }
    use std::ops::*;
    impl<T: Into<Mod>> Add<T> for Mod {
        type Output = Mod;
        fn add(self, rhs: T) -> Self::Output {
            Mod::new(self.0 + rhs.into().0)
        }
    }
    impl<T: Into<Mod>> AddAssign<T> for Mod {
        fn add_assign(&mut self, rhs: T) {
            *self = *self + rhs;
        }
    }
    impl<T: Into<Mod>> Sub<T> for Mod {
        type Output = Mod;
        fn sub(self, rhs: T) -> Self::Output {
            Mod::new(self.0 - rhs.into().0 + M)
        }
    }
    impl<T: Into<Mod>> SubAssign<T> for Mod {
        fn sub_assign(&mut self, rhs: T) {
            *self = *self - rhs;
        }
    }
    impl<T: Into<Mod>> Mul<T> for Mod {
        type Output = Mod;
        fn mul(self, rhs: T) -> Self::Output {
            Mod::new(self.0 * rhs.into().0)
        }
    }
    impl<T: Into<Mod>> MulAssign<T> for Mod {
        fn mul_assign(&mut self, rhs: T) {
            *self = *self * rhs;
        }
    }
    impl<T: Into<Mod>> Div<T> for Mod {
        type Output = Mod;
        fn div(self, rhs: T) -> Self::Output {
            self * rhs.into().recip()
        }
    }
    impl<T: Into<Mod>> DivAssign<T> for Mod {
        fn div_assign(&mut self, rhs: T) {
            *self = *self / rhs;
        }
    }
    impl Neg for Mod {
        type Output = Mod;
        fn neg(self) -> Self::Output {
            Mod(0) - self
        }
    }
    impl<T: ::std::convert::Into<i64>> ::std::convert::From<T> for Mod {
        fn from(v: T) -> Self {
            Mod::new(v.into())
        }
    }
}
#[doc = "ay=1 (mod m) -> y=a^{-1}"]
pub fn modinv(a: i64, m: i64) -> i64 {
    let (_, x, _) = extgcd(a, m);
    (m + x % m) % m
}
#[doc = "ax+by=gcd(a,b) returns (gcd, x, y)"]
#[allow(dead_code)]
pub fn extgcd(a: i64, b: i64) -> (i64, i64, i64) {
    if b == 0 {
        (a, 1, 0)
    } else {
        let (gcd, x, y) = extgcd(b, a % b);
        (gcd, y, x - (a / b) * y)
    }
}
pub type Mod = modular::Mod;
struct ModComb {
    fact: Vec<i64>,
    fact_inv: Vec<i64>,
    n: usize,
    p: i64,
}
impl ModComb {
    fn initialize(ft: &mut Self) {
        let n = ft.n;
        ft.fact[0] = 1;
        for i in 1..n {
            ft.fact[i] = (ft.fact[i - 1] * i as i64) % ft.p;
        }
        ft.fact_inv[n - 1] = modpow(ft.fact[n - 1], ft.p - 2, ft.p);
        for i in (0..n - 1).rev() {
            ft.fact_inv[i] = (ft.fact_inv[i + 1] * (i + 1) as i64) % ft.p;
        }
    }
    #[doc = "O(N)"]
    fn new(max_n: usize, p: i64) -> ModComb {
        let mut ft = ModComb {
            fact: vec![0; max_n + 1],
            fact_inv: vec![0; max_n + 1],
            n: max_n + 1,
            p: p,
        };
        Self::initialize(&mut ft);
        ft
    }
    fn fact(&self, n: usize) -> i64 {
        self.fact[n]
    }
    #[doc = "choose k numbers from 1..n"]
    fn nCk(&self, n: i64, k: i64) -> i64 {
        if n < k {
            return 0;
        }
        (self.nPk(n, k) * self.fact_inv[k as usize]) % self.p
    }
    fn nPk(&self, n: i64, k: i64) -> i64 {
        if n < k {
            return 0;
        }
        self.fact[n as usize] * self.fact_inv[(n - k) as usize] % self.p
    }
    #[doc = "split k into n number as x1+x2+...xn=k"]
    fn nHk(&self, n: i64, k: i64) -> i64 {
        if n == 0 && k == 0 {
            return 1;
        }
        self.nCk(n + k - 1, k)
    }
    #[doc = "put n balls into k different boxes. In case of n=3,k+2 [[1,2],[3]]==[[3],[1,2]]"]
    fn nSk(&self, n: i64, k: i64) -> i64 {
        if n < k {
            return 0;
        }
        let mut res = 0;
        for i in 0..k + 1 {
            let v = self.nCk(k, i) * modpow(i, n, self.p) % self.p;
            if (k - i) % 2 == 1 {
                res = (res + self.p - v) % self.p;
            } else {
                res = (res + v) % self.p;
            }
        }
        return res * self.fact_inv[k as usize] % self.p;
    }
    fn nBk(&self, n: i64, k: i64) -> i64 {
        0
    }
}
#[allow(dead_code)]
#[doc = " x ^ n % m"]
pub fn modpow(x: i64, n: i64, m: i64) -> i64 {
    let mut res = 1;
    let mut x = x % m;
    let mut n = n;
    while n > 0 {
        if n & 1 == 1 {
            res = (res * x) % m;
        }
        x = (x * x) % m;
        n >>= 1;
    }
    res
}


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

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

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

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

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

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

fn main() {
  scanln!(c: u32, v0: u32, v1: u32, a: u32, l: u32);
  let mut speed = v0;
  let mut pages = 0;
  let mut days = 0;
  loop {
    days += 1;
    pages += speed;
    if pages >= c { break; }
    speed = std::cmp::min(speed + a, v1);
    pages -= l;
  }
  println!("{}", days);
}


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

fn get_num() -> usize {
    let mut input = String::new();

    io::stdin().read_line(&mut input).expect("");

    usize::from_str(input.trim()).unwrap()
}

fn get_string() -> String {
    let mut input = String::new();

    io::stdin().read_line(&mut input).expect("");

    input.trim().to_string()
}

fn main() {
    let n = get_num();
    let s = get_string();

    for c in s.chars() {
        if c != '4' && c != '7' {
            println!("NO");
            return;
        }
    }

    let mut fs = 0;
    let mut ss = 0;
    for (i, c) in s.chars().enumerate() {
        if i == n / 2 {
            break;
        }
        fs += c.to_digit(10).unwrap();
    }

    for (_, c) in s.chars().enumerate().skip(n / 2) {
        ss += c.to_digit(10).unwrap();
    }

    if fs == ss {
        println!("YES");
    } else {
        println!("NO");
    }
}


//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::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 {
    ($i:ident . $e:tt : $t:ty; $($a:ident),*) => {
        $( let $a: $t = $i.$e(); )*
    };
    ($i:ident . $e:tt; $($a:ident),*) => {
        $( let $a = $i.$e(); )*
    };
}
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);

    let n = input.s().into_bytes();
    let sol = (1..).flat_map(|a| iter::repeat(a).take(1<<a).enumerate().map(|(b,a)| {
        let mut v = vec![b'0'; a];
        let mut b = b;
        for x in v.iter_mut().rev() {
            *x = b'4' + (3 * (b % 2)) as u8;
            b /= 2;
        }
        v
    })).position(|x| x == n).unwrap() + 1;
    println!("{}", sol);
}


#![allow(unused_imports)]
use std::io;
use std::io::prelude::*;
use std::io::BufReader;
use std::str;
use std::str::FromStr;
use std::collections::{VecDeque, HashMap};

fn main() {
    let stdin = io::stdin();
    let mut input = stdin.lock();
    let mut line = String::new();
    input.read_line(&mut line).unwrap();
    let lucky: usize = get_numbers(&line)[0];

    let mut cur = 4;
    for i in 1.. {
        if lucky == cur {
            println!("{}", i);
            break;
        }

        cur = next(cur);
    }
}

const C4: u8 = '4' as u8;
const C7: u8 = '7' as u8;

// return next lucky number, assumes n is lucky
fn next(n: usize) -> usize {
    let mut digits = format!("{}", n);
    let mut s = Vec::from(digits);
    let mut i = s.len();
    while i > 0 {
        i -= 1;
        if s[i] == C4 {
            s[i] = C7;
            break;
        }
        s[i] = C4;
    }

    let mut n = str::from_utf8(&s).unwrap().parse().unwrap();
    if i == 0 && s[0] == C4 { // got all fours, need to add new digit
        n += 4 * 10usize.pow(s.len() as u32);
    }

    n
}

/*
 * Utility Functions
 */

// get numbers from line seperated by spaces
fn get_numbers<T>(line: &str) -> Vec<T>
    where T: FromStr,
          <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    line.split_whitespace()
        .map(|chunk| chunk.parse::<T>().expect("failed to parse"))
        .collect()
}


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

#[allow(dead_code)]
const INF: i32 = 1000_000_000;
#[allow(dead_code)]
const INFLL: i64 = 1000_000_000_000_000_000;

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

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

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

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

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let n: i32 = sc.read();
    let r1: f64 = sc.read();
    let r2: f64 = sc.read();
    if n > 1 {
        let theta = std::f64::consts::PI / (n as f64);
        let mr: f64 = r1 * theta.sin() / (1.0 + theta.sin());
        //println!("{} <-> {}", mr, r2);
        match r2 <= mr + 0.0000000001 {
            false => println!("NO"),
            _                 => println!("YES"),
        }
    } else {
        if r2 <= r1 {
            println!("YES");
        } else {
            println!("NO");
        }
    }
}


use std::io::Read;
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let p: u32 = iter.next().unwrap().parse().unwrap();
    let y: u32 = iter.next().unwrap().parse().unwrap();
    for x in (p..(y+1)).rev() {
        if check(x, p) {
            println!("{}", x);
            return
        }
    }
    println!("{}", -1);
}

fn check(x : u32, p : u32) -> bool {
    for i in 2..(p+1) {
        if i*i>x {
            break;
        }
        if x%i==0 {
            return false;
        }
    }
    return !(x%p==0);
}


fn main() {
    let mut input = String::new();
    use std::io;
    use std::io::prelude::*;
    io::stdin().read_to_string(&mut input).unwrap();

    let mut it = input.split_whitespace();

    let p: u64 = it.next().unwrap().parse().unwrap();
    let y: u64 = it.next().unwrap().parse().unwrap();

    let ans = (p + 1..y + 1).rev().find(|&i| {
        let k = std::cmp::min(p, (y as f64).sqrt().floor() as u64);
        (2..k + 1).all(|j| i % j != 0)
    });

    match ans {
        Some(ans) => println!("{}", ans),
        None => println!("-1"),
    }
}


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

use std::collections::*;
use std::io::*;
use std::cmp::{max, min, Ordering};
use std::f64::consts::*;
use std::mem::{swap, size_of_val, size_of};
use std::fs::File;
use std::rc::*;
use std::ascii::*;
use std::ops::*;
use std::num::*;
use std::process::*;
//use std::ptr::*;
use std::iter::{once, repeat};

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

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

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

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

macro_rules! read {
    () => {};
	($inf:ident, $t:ty) => ($inf.read_word().parse::<$t>().expect("Parsing error"));
	($inf:ident, $($t:ty),*) => (($($inf.read_word().parse::<$t>().expect("Parsing error")),*));
}
fn gcd<T>(mut a: T, mut b: T) -> T
	where T: ShrAssign + BitAnd<Output=T> + Ord + From<u8> + Clone + SubAssign + ShlAssign<usize> + Copy
{
	let one = T::from(1);
	let zero = T::from(0);
	let mut ans = 0;
	if a < b {
		swap(&mut a, &mut b);
	}
	while b > zero {
		if (a & one > zero) && (b & one > zero) {
			a -= b;
		} else if a & one > zero {
			b >>= one;
		} else if b & one > zero {
			a >>= one;
		} else {
			ans += 1;
			a >>= one;
			b >>= one;
		}
		if a < b {
			swap(&mut a, &mut b);
		}
	}
	a <<= ans;
	a
}

fn powmod<X, Y>(mut base: X, mut exp: Y, mm: X) -> X
	where X: Copy + Clone + Mul<Output=X> + Rem<Output=X> + From<u8>,
	      Y: ShrAssign + Copy + Clone + BitAnd<Output=Y> + From<u8> + Ord
{
	let mut res = X::from(1);
	while exp > Y::from(0) {
		if exp & Y::from(1) > Y::from(0) {
			res = res * base % mm;
		}
		base = base * base % mm;
		exp >>= Y::from(1);
	}
	res
}

fn main() {
	match std::env::var("home") {
		Ok(_x) => {
			let mut inf = Input { buffer: BufReader::new(File::open("input.txt").expect("File not found")) };
			let stdout = stdout();
			let ostr = stdout.lock();
			let mut ouf = BufWriter::new(ostr);
			solve(&mut inf, &mut ouf);
		}
		Err(_e) => {
			let stdin = stdin();
			let istr = stdin.lock();
			let mut inf = Input { buffer: BufReader::new(istr) };
			let stdout = stdout();
			let ostr = stdout.lock();
			let mut ouf = BufWriter::new(ostr);
			solve(&mut inf, &mut ouf);
		}
	}
}

fn solve<Inner: BufRead, Output: Write>(inf: &mut Input<Inner>, ouf: &mut Output) {
	let (p, mut y) = read!(inf,i32,i32);
	while y > p {
		let mut fl = true;
		let mut i = 2;
		while i * i <= y {
			if y % i == 0 {
				if i <= p {
					fl = false;
				}
				break;
			}
			i += 1;
		}
		if fl {
			writeln!(ouf, "{}", y);
			return;
		}
		y -= 1;
	}
	writeln!(ouf, "-1");
}


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

fn main() {
    let stdin = io::stdin();
    let buf :Box<io::BufRead> = if cfg!(feature = "intxt") {
        eprintln!("file mode");
        let file = File::open("in.txt").unwrap();
        Box::new(io::BufReader::new(file))
    } else {
        eprintln!("stdin mode");
        Box::new(stdin.lock())
    };
    let mut sc = Scanner::new(buf);

    let (p, y) :(i32, i32) = (sc.next(), sc.next());

    for x in (p+1..y+1).rev() {
        let mut prime = true;
        let md = cmp::min(p, (x as f32).sqrt() as i32) + 1;
        for d in 2..md {
            if x % d == 0 {
                prime = false;
                break;
            }
        }
        if prime {
            println!("{}", x);
            return;
        }
    }
    println!("{}", -1);
}

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

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

    fn next<T: std::str::FromStr>(&mut self) -> T
    where
        T::Err: std::fmt::Debug,
    {
        if let Some(s) = self.buffer.pop() {
            T::from_str(&s).unwrap()
        } else {
            let mut s = String::new();
            let r = self.reader.read_line(&mut s).unwrap();
            assert!(r > 0);
            self.buffer = s.split_whitespace().rev().map(String::from).collect();
            return self.next();
        }
    }
}


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

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

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

//

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

fn run() {
    input! {
        n: u64,
        a: u64,
        b: u64,
        p: u64,
        q: u64,
    }
    let z = n / (a / gcd(a, b) * b);
    let x = n / a - z;
    let y = n / b - z;
    let ans = p * x + q * y + std::cmp::max(p, q) * z;
    println!("{}", ans);
}

fn main() {
    run();
}


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

fn get_pos(n: u16, x: u16, y: u16) -> Option<u16> {
    if (x > n) || (y > n) {
        return None;
    }

    if y == 0 {
        if x == 0 {
            return Some(0);
        } else {
            return Some(4 * n - x);
        }
    } else if y == n {
        return Some(n + x);
    } else if x == 0 {
        return Some(y);
    } else if x == n {
        return Some(3 * n - y);
    } else {
        return None;
    }
}

fn get_distance(n: u16, x1: u16, y1: u16, x2: u16, y2: u16) -> Option<u16> {
    let pos1: u16 = get_pos(n, x1, y1)?;
    let pos2: u16 = get_pos(n, x2, y2)?;

    let distance_naive: u16;
    if pos1 > pos2 {
        distance_naive = pos1 - pos2;
    } else {
        distance_naive = pos2 - pos1;
    }

    return Some(min(distance_naive, 4 * n - distance_naive));
}

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

    #[test]
    fn test1() {
        assert_eq!(get_distance(2, 0, 0, 1, 0), Some(1));
    }

    #[test]
    fn test2() {
        assert_eq!(get_distance(2, 0, 1, 2, 1), Some(4));
    }

    #[test]
    fn test3() {
        assert_eq!(get_distance(100, 0, 0, 100, 100), Some(200));
    }
}

fn main() {
    let stdin = stdin();
    let mut input_line: String = String::new();
    stdin.read_line(&mut input_line).unwrap();
    let input_vec: Vec<u16> = input_line
        .trim()
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect();

    let n: u16 = input_vec[0];
    let x1: u16 = input_vec[1];
    let y1: u16 = input_vec[2];
    let x2: u16 = input_vec[3];
    let y2: u16 = input_vec[4];

    let distance: u16 = get_distance(n, x1, y1, x2, y2).unwrap();

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


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

// Mint (mod any) {{{
mod mint {
	use std::ops::*;
	#[derive(Debug,Clone,Copy,PartialEq,Eq,PartialOrd,Ord,Default)] pub struct Mint(i32,i32);
	#[allow(dead_code)] impl Mint {
		pub fn new<T: Copy+Into<i64>>(a: T, m: T) -> Self { Self(Self::cv(a,m),m.into() as i32) }
		pub unsafe fn new_unchecked(a: i32, m: i32) -> Self { Self(a,m) }
		fn hi(mut a: i32, m: i32) -> i32 { if a >= m { a -= m; } a }
		fn lo(mut a: i32, m: i32) -> i32 { if a < 0 { a += m; } a }
		fn cv<T: Copy+Into<i64>>(a: T, m: T) -> i32 { Self::lo((a.into() % m.into()) as i32, m.into() as i32) }
		pub unsafe fn inv(self) -> Self { self.pow(self.1-2) } // ONLY FOR PRIMES!
		pub fn pow<T: Copy+Into<i64>>(self, b: T) -> Self {
			let b = b.into(); if b == 0 { Self(1,self.1) } else {
				let mut res = self.pow(b/2); res *= res; if b % 2 == 1 {res *= self;} res
			}
		}
	}
	impl Add for Mint { type Output = Self; fn add(self, a: Self) -> Self::Output { assert!(self.1==a.1); Self(Self::hi(self.0 + a.0, self.1), self.1) }}
	impl Sub for Mint { type Output = Self; fn sub(self, a: Self) -> Self::Output { assert!(self.1==a.1); Self(Self::lo(self.0 - a.0, self.1), self.1) }}
	impl Mul for Mint { type Output = Self; fn mul(self, a: Self) -> Self::Output { assert!(self.1==a.1); Self(Self::cv(self.0 as i64 * a.0 as i64, self.1 as i64), self.1) }}
	impl Div for Mint { type Output = Self; fn div(self, a: Self) -> Self::Output { self * unsafe {a.inv()} }}
	impl Neg for Mint { type Output = Self; fn neg(self) -> Self::Output { Self(Self::lo(-self.0, self.1), self.1) }}
	impl AddAssign for Mint { fn add_assign(&mut self, a: Self) { *self = *self + a; } }
	impl SubAssign for Mint { fn sub_assign(&mut self, a: Self) { *self = *self - a; } }
	impl MulAssign for Mint { fn mul_assign(&mut self, a: Self) { *self = *self * a; } }
	impl DivAssign for Mint { fn div_assign(&mut self, a: Self) { *self = *self / a; } }
	use std::fmt::{Display, Formatter, Result};
	impl Display for Mint { fn fmt(&self, f: &mut Formatter) -> Result { write!(f, "{}", self.0) } }
}
use mint::Mint;
//}}}
// Square Matrix (any) {{{
type MatT = Mint;
#[derive(Debug,Clone)] struct Mat { n: usize, a: Vec<MatT>, v0: MatT, v1: MatT }
#[allow(dead_code)] impl Mat {
	fn new(n:usize,v0:MatT,v1:MatT)->Self{Self{n,a:vec![v0;n*n],v0,v1}}
	fn diag(n:usize,v0:MatT,v1:MatT,v:MatT)->Self{let mut m=Self::new(n,v0,v1);let mut p=0;for _ in 0..n{m.a[p]=v;p+=n+1;}m}
	fn pow(&self,n:u64)->Self{if n==0{Self::diag(self.n,self.v0,self.v1,self.v1)}else{let mut t=self.pow(n/2);t*=t.clone();if n%2==1{t*=self.clone();}t}}
	fn range(&self,r:Range<usize>,c:Range<usize>)->Vec<Vec<MatT>>{if r.start<r.end||c.start<c.end{Vec::new()}else{let mut res=vec![vec![self.v0;c.end-c.start];r.end-r.start];
		for i in r.start..r.end{let ir=i-r.start;let ii=i*self.n+c.start;for j in 0..c.end-c.start{res[ir][j]=self.a[ii+j];}}res}}
	fn at(&self,r:usize,c:usize)->MatT{self.a[r*self.n+c]}
	fn at_mut<'a>(&'a mut self,r:usize,c:usize)->&'a mut MatT{&mut self.a[r*self.n+c]}//'
}
impl Mul for Mat{type Output=Self;fn mul(self,o:Self)->Self::Output{assert!(self.n==o.n);let n=self.n;let mut res=Self::new(n,self.v0,self.v1);
	for ii in(0..n).map(|i|i*n){for j in 0..n{let mut t=self.v0;let mut kk=j;for k in 0..n{t+=self.a[ii+k]*o.a[kk];kk+=n;}res.a[ii+j]=t;}}res}}
impl Add for Mat{type Output=Self;fn add(mut self,o:Self)->Self{self+=o;self}}
impl Sub for Mat{type Output=Self;fn sub(mut self,o:Self)->Self{self-=o;self}}
impl MulAssign for Mat{fn mul_assign(&mut self,a:Self){*self=self.clone()*a;}}
impl AddAssign for Mat{fn add_assign(&mut self,o:Self){assert!(self.n==o.n);for(x,y)in self.a.iter_mut().zip(o.a.into_iter()){*x+=y;}} }
impl SubAssign for Mat{fn sub_assign(&mut self,o:Self){assert!(self.n==o.n);for(x,y)in self.a.iter_mut().zip(o.a.into_iter()){*x-=y;}} }
impl PartialEq for Mat{fn eq(&self,o:&Self)->bool{self.n==o.n&&self.a==o.a}}impl Eq for Mat{}
// }}}

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

	l!(n,k,l,m = rin.l());
	if l <= 60 && k >= 1 << l {
		writeln!(rout, "0").ok();
		return;
	}
	let m0 = Mint::new(0,m);
	let m1 = Mint::new(1,m);

	let b1 = k.count_ones() as i64;
	let b0 = l - b1;
	let mut f = Mat::new(2,m0,m1);
	*f.at_mut(0,0) = m0;
	*f.at_mut(0,1) = m1;
	*f.at_mut(1,0) = m1;
	*f.at_mut(1,1) = m1;
	let res_f = f.pow(n as u64 + 2).at(0,1);
	let res_b = Mint::new(2,m).pow(n);
	let sol = (res_b - res_f).pow(b1) * res_f.pow(b0);
	writeln!(rout, "{}", sol).ok();
}


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

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

use std::io::Write;

fn solve(writer: &mut std::io::BufWriter<std::io::Stdout>) {
    let n = parse_line!(usize);
    let a = parse_line_to_vec!(u32);
    let mut dp = vec![vec![[n, n]; n + 1]; n + 1];
    dp[0][0][0] = 0;
    dp[0][0][1] = 0;
    for i in 0..n {
        if a[i] != 0 {
            if a[i] % 2 == 0 {
                for i in (1..=n).rev() {
                    for j in 0..=n {
                        dp[i][j][0] = std::cmp::min(dp[i][j][0],
                                    std::cmp::min(dp[i - 1][j][0], dp[i - 1][j][1] + 1));
                    }
                }
            }else{
                for i in 0..=n {
                    for j in (1..=n).rev() {
                        dp[i][j][1] = std::cmp::min(dp[i][j][1],
                                    std::cmp::min(dp[i][j - 1][1], dp[i][j - 1][0] + 1));
                    }
                }
            }
            continue;
        }
        for i in (0..=n).rev() {
            for j in (0..=n).rev() {
                if i > 0 {
                    dp[i][j][0] = std::cmp::min(dp[i][j][0],
                                std::cmp::min(dp[i - 1][j][0], dp[i - 1][j][1] + 1));
                }
                if j > 0 {
                    dp[i][j][1] = std::cmp::min(dp[i][j][1],
                                std::cmp::min(dp[i][j - 1][1], dp[i][j - 1][0] + 1));
                }
            }
        }
    }
    writeln!(writer, "{}", dp[n / 2][n - n / 2].iter().min().unwrap()).unwrap();
}

fn main() {
    let mut writer = std::io::BufWriter::new(std::io::stdout());
    let tests = 1; // parse_line!(usize);
    for _ in 0..tests {
        solve(&mut writer);
    }
}


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

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

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

//

use std::cmp::*;
use std::collections::BTreeMap;

fn run() {
    input! {
        n: usize,
        p: [usize; n],
    }
    let mut cnt = [0; 2];
    for p in p.iter() {
        if *p == 0 {
            continue;
        }
        cnt[*p % 2] += 1;
    }
    let even = n / 2 - cnt[0];
    let odd = (n + 1) / 2 - cnt[1];
    let inf = n;
    let mut dp = BTreeMap::<(usize, usize, usize), usize>::new();
    dp.insert((0, even, odd), 0);
    dp.insert((1, even, odd), 0);
    for p in p.iter().rev() {
        let mut next = BTreeMap::<(usize, usize, usize), usize>::new();
        for ((b, x, y), v) in dp {
            if *p == 0 {
                if x > 0 {
                    let po = next.entry((0, x - 1, y)).or_insert(inf);
                    *po = min(*po, v + (b ^ 0));
                }
                if y > 0 {
                    let po = next.entry((1, x, y - 1)).or_insert(inf);
                    *po = min(*po, v + (b ^ 1));
                }
            } else {
                let po = next.entry((*p % 2, x, y)).or_insert(inf);
                *po = min(*po, v + (b ^ (*p & 1)));
            }
        }
        dp = next;
    }
    let mut ans = inf;
    for (_, v) in dp {
        ans = min(ans, v);
    }
    println!("{}", ans);
}

fn main() {
    run();
}


#![allow(unknown_lints)]
#![allow(unused_imports, unused_macros, non_snake_case, bare_trait_objects)]
#![allow(renamed_and_removed_lints, redundant_field_names)]
use std::cmp::Ordering::{self, Greater, Less};
use std::cmp::{max, min};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::error::Error;
use std::io::{self, BufReader, BufWriter, Read, Write};
use text_scanner::{scan, scan_iter, scanln, scanln_iter};
use utils::adj4_iter;

fn run() {
    let n: usize = scan();
    let p: Vec<usize> = scan_iter().collect();
    let mut zero = 0;
    let mut one = 0;
    for i in 1..n + 1 {
        if !p.contains(&i) {
            if i % 2 == 0 {
                zero += 1;
            } else {
                one += 1;
            }
        }
    }
    let mut dp = vec![vec![vec![vec![i32::max_value(); 2]; one + 1]; zero + 1]; n + 1];
    dp[0][0][0][0] = 0;
    dp[0][0][0][1] = 0;
    for i in 0..n {
        for z in 0..zero + 1 {
            for o in 0..one + 1 {
                for cur in 0..2 {
                    if dp[i][z][o][cur] == i32::max_value() {
                        continue;
                    }
                    for next in 0..2 {
                        if p[i] != 0 && p[i] % 2 != next {
                            continue;
                        }
                        let nz = if p[i] == 0 && next == 0 { z + 1 } else { z };
                        let no = if p[i] == 0 && next == 1 { o + 1 } else { o };
                        if nz > zero || no > one {
                            continue;
                        }
                        let nvalue =
                            dp[i][z][o][cur] + if cur as i32 != next as i32 { 1 } else { 0 };
                        dp[i + 1][nz as usize][no as usize][next as usize].set_min(nvalue);
                    }
                }
            }
        }
    }
    let mut ans = i32::max_value();
    for z in 0..zero + 1 {
        for o in 0..one + 1 {
            for cur in 0..2 {
                ans.set_min(dp[n][z][o][cur]);
            }
        }
    }
    println!("{}", ans);
}

fn main() {
    std::thread::Builder::new()
        .name("run".to_string())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap()
}

//{{{ utils
pub mod utils {
    static DY: [isize; 8] = [0, 1, 0, -1, 1, -1, 1, -1];
    static DX: [isize; 8] = [1, 0, -1, 0, 1, 1, -1, -1];

    fn try_adj(
        y: usize,
        x: usize,
        dy: isize,
        dx: isize,
        h: usize,
        w: usize,
    ) -> Option<(usize, usize)> {
        let ny = y as isize + dy;
        let nx = x as isize + dx;
        if ny >= 0 && nx >= 0 {
            let ny = ny as usize;
            let nx = nx as usize;
            if ny < h && nx < w {
                Some((ny, nx))
            } else {
                None
            }
        } else {
            None
        }
    }

    pub struct Adj4 {
        y: usize,
        x: usize,
        h: usize,
        w: usize,
        r: usize,
    }

    impl Iterator for Adj4 {
        type Item = (usize, usize);

        fn next(&mut self) -> Option<Self::Item> {
            loop {
                if self.r >= 4 {
                    return None;
                }

                let dy = DY[self.r];
                let dx = DX[self.r];
                self.r += 1;

                if let Some((ny, nx)) = try_adj(self.y, self.x, dy, dx, self.h, self.w) {
                    return Some((ny, nx));
                }
            }
        }
    }

    pub fn adj4_iter(y: usize, x: usize, h: usize, w: usize) -> Adj4 {
        Adj4 {
            y: y,
            x: x,
            h: h,
            w: w,
            r: 0,
        }
    }
}
pub mod text_scanner {
    use std;
    #[derive(Debug)]
    pub enum Error {
        IoError(std::io::Error),
        EncodingError(std::string::FromUtf8Error),
        ParseError(String),
        Eof,
    }

    impl std::fmt::Display for Error {
        fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
            match *self {
                Error::IoError(ref e) => writeln!(f, "IO Error: {}", e),
                Error::EncodingError(ref e) => writeln!(f, "Encoding Error: {}", e),
                Error::ParseError(ref e) => writeln!(f, "Parse Error: {}", e),
                Error::Eof => writeln!(f, "EOF"),
            }
        }
    }

    impl std::error::Error for Error {
        // dummy implementation for 1.15.1
        fn description(&self) -> &str {
            "description() is deprecated; use Display"
        }
    }

    pub fn read_line() -> Option<String> {
        let stdin = std::io::stdin();
        let mut stdin = stdin.lock();
        fread_line(&mut stdin).expect("IO error")
    }

    pub fn scan<T: FromTokens>() -> T {
        let stdin = std::io::stdin();
        let mut stdin = stdin.lock();
        fscan(&mut stdin).expect("IO error")
    }

    pub fn scanln<T: FromTokens>() -> T {
        let stdin = std::io::stdin();
        let mut stdin = stdin.lock();
        fscanln(&mut stdin).expect("IO error")
    }

    pub fn scan_iter<T: FromTokens>() -> ScanIter<T> {
        ScanIter {
            item_type: std::marker::PhantomData,
        }
    }

    pub fn scanln_iter<T: FromTokens>() -> ScanlnIter<T> {
        let stdin = std::io::stdin();
        let mut stdin = stdin.lock();
        let s = fread_line(&mut stdin)
            .expect("IO error")
            .unwrap_or_else(String::new);
        ScanlnIter {
            cursor: std::io::Cursor::new(s),
            item_type: std::marker::PhantomData,
        }
    }

    pub fn fread_line<R: std::io::BufRead>(r: &mut R) -> Result<Option<String>, std::io::Error> {
        let mut buf = String::new();
        let length = r.read_line(&mut buf)?;
        if let Some('\n') = buf.chars().last() {
            buf.pop();
        }
        if let Some('\r') = buf.chars().last() {
            buf.pop();
        }
        if length == 0 {
            Ok(None)
        } else {
            Ok(Some(buf))
        }
    }

    pub fn fscan<R: std::io::Read, T: FromTokens>(reader: &mut R) -> Result<T, Error> {
        let mut tokenizer = Tokenizer::new(reader);
        FromTokens::from_tokens(&mut tokenizer)
    }

    pub fn fscanln<R: std::io::BufRead, T: FromTokens>(reader: &mut R) -> Result<T, Error> {
        let s = match fread_line(reader) {
            Ok(Some(s)) => s,
            Ok(None) => return Err(Error::Eof),
            Err(e) => return Err(Error::IoError(e)),
        };
        let mut bytes = s.as_bytes();
        let mut tokenizer = Tokenizer::new(&mut bytes);
        FromTokens::from_tokens(&mut tokenizer)
    }

    pub fn fscan_iter<R: std::io::Read, T: FromTokens>(reader: &mut R) -> FscanIter<R, T> {
        FscanIter {
            tokenizer: Tokenizer::new(reader),
            item_type: std::marker::PhantomData,
        }
    }

    pub fn fscanln_iter<R: std::io::BufRead, T: FromTokens>(
        reader: &mut R,
    ) -> Result<ScanlnIter<T>, Error> {
        let s = match fread_line(reader) {
            Ok(Some(s)) => s,
            Ok(None) => "".to_string(),
            Err(e) => return Err(Error::IoError(e)),
        };
        Ok(ScanlnIter {
            cursor: std::io::Cursor::new(s),
            item_type: std::marker::PhantomData,
        })
    }

    pub struct ScanIter<T>
    where
        T: FromTokens,
    {
        item_type: std::marker::PhantomData<T>,
    }

    impl<T: FromTokens> Iterator for ScanIter<T> {
        type Item = T;

        fn next(&mut self) -> Option<Self::Item> {
            let stdin = std::io::stdin();
            let mut stdin = stdin.lock();
            let mut tokenizer = Tokenizer::new(&mut stdin);
            match FromTokens::from_tokens(&mut tokenizer) {
                Err(Error::Eof) => None,
                r => Some(r.expect("IO error")),
            }
        }
    }

    pub struct FscanIter<'a, R, T>
    where
        R: std::io::Read + 'a,
        T: FromTokens,
    {
        tokenizer: Tokenizer<'a, R>,
        item_type: std::marker::PhantomData<T>,
    }

    impl<'a, R: std::io::Read, T: FromTokens> Iterator for FscanIter<'a, R, T> {
        type Item = Result<T, Error>;

        fn next(&mut self) -> Option<Self::Item> {
            match FromTokens::from_tokens(&mut self.tokenizer) {
                Err(Error::Eof) => None,
                r => Some(r),
            }
        }
    }

    pub struct ScanlnIter<T>
    where
        T: FromTokens,
    {
        cursor: std::io::Cursor<String>,
        item_type: std::marker::PhantomData<T>,
    }

    impl<'a, T: FromTokens> Iterator for ScanlnIter<T> {
        type Item = T;

        fn next(&mut self) -> Option<Self::Item> {
            let mut tokenizer = Tokenizer::new(&mut self.cursor);
            match FromTokens::from_tokens(&mut tokenizer) {
                Err(Error::Eof) => None,
                r => Some(r.expect("IO error")),
            }
        }
    }

    pub trait FromTokens
    where
        Self: Sized,
    {
        fn from_tokens(
            tokenizer: &mut Iterator<Item = Result<String, Error>>,
        ) -> Result<Self, Error>;
    }

    macro_rules! from_tokens_primitives {
    ($($t:ty),*) => { $(
        impl FromTokens for $t {
            fn from_tokens(tokenizer: &mut Iterator<Item = Result<String, Error>>) -> Result<Self, Error> {
                let token = tokenizer.next();
                match token {
                    Some(s) => s?
                        .parse::<$t>()
                        .map_err(|e| Error::ParseError(format!("{}", e))),
                    None => Err(Error::Eof),
                }
            }
        }
    )* }
}

    from_tokens_primitives! {
        String,
        bool,
        f32,
        f64,
        isize,
        i8,
        i16,
        i32,
        i64,
        usize,
        u8,
        u16,
        u32,
        u64
    }

    impl FromTokens for Vec<char> {
        fn from_tokens(
            tokenizer: &mut Iterator<Item = Result<String, Error>>,
        ) -> Result<Self, Error> {
            Ok(String::from_tokens(tokenizer)?.chars().collect())
        }
    }

    impl<T1, T2> FromTokens for (T1, T2)
    where
        T1: FromTokens,
        T2: FromTokens,
    {
        fn from_tokens(
            tokenizer: &mut Iterator<Item = Result<String, Error>>,
        ) -> Result<Self, Error> {
            Ok((T1::from_tokens(tokenizer)?, T2::from_tokens(tokenizer)?))
        }
    }

    impl<T1, T2, T3> FromTokens for (T1, T2, T3)
    where
        T1: FromTokens,
        T2: FromTokens,
        T3: FromTokens,
    {
        fn from_tokens(
            tokenizer: &mut Iterator<Item = Result<String, Error>>,
        ) -> Result<Self, Error> {
            Ok((
                T1::from_tokens(tokenizer)?,
                T2::from_tokens(tokenizer)?,
                T3::from_tokens(tokenizer)?,
            ))
        }
    }

    impl<T1, T2, T3, T4> FromTokens for (T1, T2, T3, T4)
    where
        T1: FromTokens,
        T2: FromTokens,
        T3: FromTokens,
        T4: FromTokens,
    {
        fn from_tokens(
            tokenizer: &mut Iterator<Item = Result<String, Error>>,
        ) -> Result<Self, Error> {
            Ok((
                T1::from_tokens(tokenizer)?,
                T2::from_tokens(tokenizer)?,
                T3::from_tokens(tokenizer)?,
                T4::from_tokens(tokenizer)?,
            ))
        }
    }

    impl<T1, T2, T3, T4, T5> FromTokens for (T1, T2, T3, T4, T5)
    where
        T1: FromTokens,
        T2: FromTokens,
        T3: FromTokens,
        T4: FromTokens,
        T5: FromTokens,
    {
        fn from_tokens(
            tokenizer: &mut Iterator<Item = Result<String, Error>>,
        ) -> Result<Self, Error> {
            Ok((
                T1::from_tokens(tokenizer)?,
                T2::from_tokens(tokenizer)?,
                T3::from_tokens(tokenizer)?,
                T4::from_tokens(tokenizer)?,
                T5::from_tokens(tokenizer)?,
            ))
        }
    }

    impl<T1, T2, T3, T4, T5, T6> FromTokens for (T1, T2, T3, T4, T5, T6)
    where
        T1: FromTokens,
        T2: FromTokens,
        T3: FromTokens,
        T4: FromTokens,
        T5: FromTokens,
        T6: FromTokens,
    {
        fn from_tokens(
            tokenizer: &mut Iterator<Item = Result<String, Error>>,
        ) -> Result<Self, Error> {
            Ok((
                T1::from_tokens(tokenizer)?,
                T2::from_tokens(tokenizer)?,
                T3::from_tokens(tokenizer)?,
                T4::from_tokens(tokenizer)?,
                T5::from_tokens(tokenizer)?,
                T6::from_tokens(tokenizer)?,
            ))
        }
    }

    struct Tokenizer<'a, R: std::io::Read + 'a> {
        reader: &'a mut R,
    }

    impl<'a, R: std::io::Read> Tokenizer<'a, R> {
        pub fn new(reader: &'a mut R) -> Self {
            Tokenizer { reader: reader }
        }

        pub fn next_token(&mut self) -> Result<Option<String>, Error> {
            use std::io::Read;
            let mut token = Vec::new();
            for b in self.reader.by_ref().bytes() {
                let b = b.map_err(Error::IoError)?;
                match (is_ascii_whitespace(b), token.is_empty()) {
                    (false, _) => token.push(b),
                    (true, false) => break,
                    (true, true) => {}
                }
            }
            if token.is_empty() {
                return Ok(None);
            }
            String::from_utf8(token)
                .map(Some)
                .map_err(Error::EncodingError)
        }
    }

    impl<'a, R: std::io::Read> Iterator for Tokenizer<'a, R> {
        type Item = Result<String, Error>;
        fn next(&mut self) -> Option<Self::Item> {
            match self.next_token() {
                Ok(Some(s)) => Some(Ok(s)),
                Ok(None) => None,
                Err(e) => Some(Err(e)),
            }
        }
    }

    fn is_ascii_whitespace(b: u8) -> bool {
        // Can use u8::is_ascii_whitespace once removing support of 1.15.1
        match b {
            b'\t' | b'\n' | b'\x0C' | b'\r' | b' ' => true,
            _ => false,
        }
    }
}

pub trait SetMinMax {
    fn set_min(&mut self, v: Self) -> bool;
    fn set_max(&mut self, v: Self) -> bool;
}

impl<T> SetMinMax for T
where
    T: PartialOrd,
{
    fn set_min(&mut self, v: T) -> bool {
        *self > v && {
            *self = v;
            true
        }
    }
    fn set_max(&mut self, v: T) -> bool {
        *self < v && {
            *self = v;
            true
        }
    }
}

#[derive(PartialEq, Eq, Debug, Copy, Clone, Default, Hash)]
pub struct Reverse<T>(pub T);

impl<T: PartialOrd> PartialOrd for Reverse<T> {
    #[inline]
    fn partial_cmp(&self, other: &Reverse<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }

    #[inline]
    fn lt(&self, other: &Self) -> bool {
        other.0 < self.0
    }
    #[inline]
    fn le(&self, other: &Self) -> bool {
        other.0 <= self.0
    }
    #[inline]
    fn ge(&self, other: &Self) -> bool {
        other.0 >= self.0
    }
    #[inline]
    fn gt(&self, other: &Self) -> bool {
        other.0 > self.0
    }
}

impl<T: Ord> Ord for Reverse<T> {
    #[inline]
    fn cmp(&self, other: &Reverse<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

#[derive(PartialEq, PartialOrd, Debug, Copy, Clone, Default)]
pub struct Num(pub f64);

impl Eq for Num {}

impl Ord for Num {
    fn cmp(&self, other: &Num) -> Ordering {
        self.0
            .partial_cmp(&other.0)
            .expect("unexpected NaN when compare")
    }
}

// See https://docs.rs/superslice/1.0.0/superslice/trait.Ext.html
pub trait SliceExt {
    type Item;

    fn lower_bound(&self, x: &Self::Item) -> usize
    where
        Self::Item: Ord;

    fn lower_bound_by<'a, F>(&'a self, f: F) -> usize
    where
        F: FnMut(&'a Self::Item) -> Ordering;

    fn lower_bound_by_key<'a, K, F>(&'a self, k: &K, f: F) -> usize
    where
        F: FnMut(&'a Self::Item) -> K,
        K: Ord;

    fn upper_bound(&self, x: &Self::Item) -> usize
    where
        Self::Item: Ord;

    fn upper_bound_by<'a, F>(&'a self, f: F) -> usize
    where
        F: FnMut(&'a Self::Item) -> Ordering;

    fn upper_bound_by_key<'a, K, F>(&'a self, k: &K, f: F) -> usize
    where
        F: FnMut(&'a Self::Item) -> K,
        K: Ord;
}

impl<T> SliceExt for [T] {
    type Item = T;

    fn lower_bound(&self, x: &Self::Item) -> usize
    where
        T: Ord,
    {
        self.lower_bound_by(|y| y.cmp(x))
    }

    fn lower_bound_by<'a, F>(&'a self, mut f: F) -> usize
    where
        F: FnMut(&'a Self::Item) -> Ordering,
    {
        let s = self;
        let mut size = s.len();
        if size == 0 {
            return 0;
        }
        let mut base = 0usize;
        while size > 1 {
            let half = size / 2;
            let mid = base + half;
            let cmp = f(unsafe { s.get_unchecked(mid) });
            base = if cmp == Less { mid } else { base };
            size -= half;
        }
        let cmp = f(unsafe { s.get_unchecked(base) });
        base + (cmp == Less) as usize
    }

    fn lower_bound_by_key<'a, K, F>(&'a self, k: &K, mut f: F) -> usize
    where
        F: FnMut(&'a Self::Item) -> K,
        K: Ord,
    {
        self.lower_bound_by(|e| f(e).cmp(k))
    }

    fn upper_bound(&self, x: &Self::Item) -> usize
    where
        T: Ord,
    {
        self.upper_bound_by(|y| y.cmp(x))
    }

    fn upper_bound_by<'a, F>(&'a self, mut f: F) -> usize
    where
        F: FnMut(&'a Self::Item) -> Ordering,
    {
        let s = self;
        let mut size = s.len();
        if size == 0 {
            return 0;
        }
        let mut base = 0usize;
        while size > 1 {
            let half = size / 2;
            let mid = base + half;
            let cmp = f(unsafe { s.get_unchecked(mid) });
            base = if cmp == Greater { base } else { mid };
            size -= half;
        }
        let cmp = f(unsafe { s.get_unchecked(base) });
        base + (cmp != Greater) as usize
    }

    fn upper_bound_by_key<'a, K, F>(&'a self, k: &K, mut f: F) -> usize
    where
        F: FnMut(&'a Self::Item) -> K,
        K: Ord,
    {
        self.upper_bound_by(|e| f(e).cmp(k))
    }
}

//}}}


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

macro_rules! scan_line {
    ($($ty: ty),*) => {{
        let line = read_line();
        let mut iter = line.split_whitespace();
        ($(iter.next().unwrap().parse::<$ty>().unwrap()),*)
    }}
}

fn main() {
    let (n, a, b) = scan_line!(i32, i32, i32);
    let mut lo = 1;
    let mut hi = n;
    let mut max_min = 0;
    while lo < hi {
        let mid = lo + (hi - lo) / 2;
        let ap = a / mid;
        let bp = b / (n - mid);
        max_min = std::cmp::max(max_min, std::cmp::min(ap, bp));
        if ap == bp {
            break;
        } else if ap < bp {
            hi = mid;
        } else {
            lo = mid + 1;
        }
    }
    println!("{}", max_min);
}


use std::io;
pub struct Scanner<B> {
    reader: B,
    buffer: Vec<String>,
}

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

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

fn main() {
    try_main().unwrap();
}

fn try_main() -> Result<(), Box<std::error::Error>> {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock());
    let n : usize = sc.next();
    let a : usize = sc.next();
    let b : usize = sc.next();
    let mut mc : usize = 0;
    for to_a in 1..n {
        let to_b = n.checked_sub(to_a).unwrap();
        let num_a = a / to_a;
        let num_b = b / to_b;
        mc = std::cmp::max(std::cmp::min(num_a, num_b), mc);
    }
    println!("{}", mc);
    Ok(())
}


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

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

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

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

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

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

fn main() {
    let (n, a, b) = get!(usize, usize, usize);

    let mut ans = 1;
    for i in 1..n {
        let k = n - i;

        if a >= i && b >= k {
            ans = max(ans, min(a / i, b / k));
        }
    }

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


use std::io;

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

	let mut iter = input.split_whitespace();
	let n: u16 = iter.next().unwrap().parse().unwrap();
	let a: u16 = iter.next().unwrap().parse().unwrap();
	let b: u16 = iter.next().unwrap().parse().unwrap();
	let lower: u16 = if a < b { a } else { b };

	let mut max: u16 = if a > b { a } else { b };
	let mut min: u16 = 1;
	let mut x: u16 = 1;

	while min <= max {
		let cur = (max + min) / 2;

		if cur <= lower && a / cur + b / cur >= n {
			x = cur;
			min = cur + 1;
		} else {
			max = cur - 1;
		}
	}

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


use std::io;

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

	let mut iter = input.split_whitespace();
	let n: u16 = iter.next().unwrap().parse().unwrap();
	let a: u16 = iter.next().unwrap().parse().unwrap();
	let b: u16 = iter.next().unwrap().parse().unwrap();

	let mut max: u16 = if a > b { a } else { b };
	let mut min: u16 = 1;
	let mut x: u16 = 1;

	while min <= max {
		let cur = (max + min) / 2;
		let max_a = a / cur;
		let max_b = b / cur;

		if max_a >= 1 && max_b >= 1 && max_a + max_b >= n {
			x = cur;
			min = cur + 1;
		} else {
			max = cur - 1;
		}
	}

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


use std::io::{self, Write};
use std::str;
use std::cmp::min;

struct Scanner<R> {
    reader: R,
    buf_str: Vec<u8>,
    buf_iter: str::SplitAsciiWhitespace<'static>
}

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

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

    fn next_vec<T: str::FromStr>(&mut self) -> Vec<T> {
        let mut res: Vec<T> = Vec::new();
        loop {
            loop {
                match self.buf_iter.next() {
                    Some(token) => res.push(token.parse().ok().expect("Failed parse")),
                    None => break,
                }
            }
            if res.len() > 0 {
                return res;
            }
            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())
            }
        }
    }

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

fn main() {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let mut cin = Scanner::new(stdin.lock());
    let mut cout = io::BufWriter::new(stdout.lock());

    let n = cin.next::<u32>();
    let m = cin.next::<u32>();
    let t = cin.next_vec_n::<u32>(n);
    let mut count = [0 as u32; 101];
    let mut sum: u32 = 0;

    for v in t {
        sum += v;
        let mut ret = 0;
        let mut tsum = sum;
        for i in 1..101 {
            if count[(101 - i) as usize] == 0 {
                continue;
            }
            if tsum <= m {
                break;
            }
            let x: u32 = min((tsum - m + 101 - i - 1) / (101 - i), count[(101 - i) as usize]);
            tsum -= x * (101 - i) as u32;
            ret += x;
        }
        count[v as usize] += 1;
        write!(cout, "{} ", ret).ok();
    }
}


#[allow(unused_imports)]
use std::io::{BufReader, BufWriter, stdin, stdout, Write};
use std::cmp::{min, max};
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet, BinaryHeap};

fn main() {
	let mut inp = my_input::default();
	let out = &mut BufWriter::new(stdout());
	let n = inp.scan::<usize>();
	let m = inp.scan::<usize>();
	let T:Vec<usize> = (0..n).map(|_| inp.scan::<usize>()).collect();
	let mut acnt = vec![0 as usize; 101];
	let mut ans:Vec<usize> = Vec::new();
	for i in T {
		let mut cnt = 0 as usize;
		let mut sum = i as usize;
		for j in 1..101 {
			let mut C = min(acnt[j], (m - sum) / j);
			sum += j * C;
			cnt += acnt[j] - C;
		}
		ans.push(cnt);
		acnt[i] += 1;
	}
	for i in ans {
		write!(out, "{} ", i);
	}
}

#[derive(Default)]
struct my_input {
	buffer: Vec<String>
}

impl my_input {
	fn scan<T: std::str::FromStr>(&mut self) -> T {
		loop {
			if let Some(token) = self.buffer.pop() {
				return token.parse().ok().expect("Parsing Error");
			}
			let mut s = String::new();
			stdin().read_line(&mut s).expect("Reading Error");
			self.buffer = s.split_whitespace().rev().map(String::from).collect();
		}
	}
}


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

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

    let n = input.u();
    let m = input.i();
    let mut c = vec![0; 101];
    let mut sum = 0;
    for _ in 0..n {
        let t = input.i();
        sum += t;
        let mut s = sum - m;
        let mut res = 0;
        if s > 0 {
            for i in (1..101).rev() {
                let x = c[i as usize];
                if x * i <= s {
                    s -= x * i;
                    res += x;
                } else {
                    res += (s + i - 1) / i;
                    break;
                }
            }
        }
        c[t as usize] += 1;
        write!(bout, "{} ", res).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
}

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

    let sol = input.i().min(input.i()/2).min(input.i()/4) * 7;
    println!("{}", sol);
}


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

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

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

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

fn main() {
  let a = readln!(i32);
  let b = readln!(i32);
  let c = readln!(i32);
  let t = min(a,min(b/2,c/4));
  println!("{}",t*7);
}


use std::io::stdin;
use std::cmp::*;

fn main() {
    let (n, _) = {
        let mut input = String::new();
        stdin().read_line(&mut input).unwrap();
        let mut it = input.split_whitespace().map(|k| k.parse::<usize>().unwrap());
        (it.next().unwrap(), it.next().unwrap())
    };

    let mut a = String::new();
    stdin().read_line(&mut a).unwrap();
    let a = a.split_whitespace().map(|k| k.parse::<usize>().unwrap());
    let (mut a1, mut a2, mut a4) = a.fold((0, 0, 0), |(a1, a2, a4), ai| (a1 + ai % 2, a2 + ai % 4 - ai % 2, a4 + ai - ai % 4));

    let mut s4 = 4 * n;
    let mut s2 = 4 * n;

    let tmp = min(a2, s2);
    a2 -= tmp;
    s2 -= tmp;
    let tmp = min(a2, s4 / 2);
    a2 -= tmp;
    s4 -= tmp;
    let tmp = min(2 * a2, s4);
    a2 -= tmp / 2;
    s4 -= tmp;
    let tmp = min(a4, s4);
    a4 -= tmp;
    s4 -= tmp;
    let tmp = min(a4, s2);
    a4 -= tmp;
    s2 -= tmp;
    let tmp = min(a1, s4 / 2);
    a1 -= tmp;
    let tmp = min(a1, s2 / 2);
    a1 -= tmp;

    if a1 + a2 + a4 > 0 {
        println!("NO");
    } else {
        println!("YES");
    }
}


//jdoodle.com:rustc 1.10.0--codeforces.com:1.19
fn main(){
    let mut z=String::new();std::io::stdin().read_line(&mut z);let mut a:i32=z.trim().parse().expect("");a*=2;let mut b=false;
    for i in 1..(a as f32).sqrt()as i32{
        let c=a-i*i-i;let d=(c as f32).sqrt()as i32;
        if d*(d+1)==c{b=true}
    }
    print!("{}",if b{"YES"}else{"NO"})
}


// 991B
use std::io;

fn main() {
    let n: u32 = read_one(&io::stdin());
    let mut v: Vec<u32> = read_vector(&io::stdin());

    v.sort();
    let target_score = (4.5 * (n as f32)).ceil() as u32;
    let mut current_score: u32 = v.iter().sum();
    let mut labs = 0;
    for e in v {
        if current_score < target_score {
            current_score += (5 - e);
            labs += 1;
        } else {
            break;
        }
    }
    println!("{}", labs);
}

fn read_vector<T>(stdin: &io::Stdin) -> Vec<T>
where
    T: std::str::FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut s = String::new();
    stdin.read_line(&mut s).unwrap();
    s = s.trim().to_string();
    let mut v: Vec<T> = Vec::new();
    for n in s.split_whitespace() {
        let i: T = n.parse().unwrap();
        v.push(i);
    }
    v
}

fn read_one<T>(stdin: &io::Stdin) -> T
where
    T: std::str::FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut s = String::new();
    stdin.read_line(&mut s).unwrap();
    s.trim().split_whitespace().next().unwrap().parse().unwrap()
}


use std::io;

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

    let mut s: String = String::new();
    io::stdin().read_line(&mut s).unwrap();
    io::stdin().read_line(&mut s).unwrap();
    let v: Vec<usize> = s.trim()
        .split(' ')
        .map(|n| n.parse().unwrap())
        .collect();

    let mut g = vec![0.0; 4];

    for a in v.iter() {
        g[a - 2] += 1.0;
    }

    let cg = ((g[0]*2.0 + g[1]*3.0 + g[2]*4.0 + g[3]*5.0) / n as f32) + 0.5;

    let agg = vec![
        3.0/n as f32,
        2.0/n as f32,
        1.0/n as f32,
    ];

    // println!("{}", cg);
    // println!("{:?}", agg);

    let mut sol = 5.0 - cg;
    if sol <= 0.0 {
        println!("0");
        return;
    } else {
        let mut nn = (sol / agg[0] - 0.0001).ceil();
        // println!("{} {} {}", sol, agg[0], sol / agg[0]);
        if nn <= g[0] {
            println!("{}", nn);
            return;
        }
        sol -= g[0] * agg[0];

        nn = (sol / agg[1] - 0.0001).ceil();
        if nn <= g[1] {
            println!("{}", nn + g[0]);
            return;
        }
        sol -= g[1] * agg[1];

        nn = (sol / agg[2] - 0.0001).ceil();
        if nn <= g[2] {
            println!("{}", nn + g[0] + g[1]);
            return;
        }

        println!("{}", g[0] + g[1] + g[2]);
    }
}


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

use std::io::prelude::*;
use std::io::BufReader;
use std::cmp::{max, min};

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

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

const N: i64 = 998_244_353;

fn extended_euclid(a: i64, b: i64) -> (i64, i64, i64) {
    if b == 0 {
        (a, 1, 0)
    } else {
        let (d0, x0, y0) = extended_euclid(b, a % b);
        (d0, y0, x0 - a / b * y0)
    }
}

fn main() {
    let (n, m) = {
        let input = get_line();
        let mut it = input.split_whitespace().map(|k| k.parse::<usize>().unwrap());
        (
            it.next().unwrap(),
            it.next().unwrap(),
            )
    };

    let f_v: Vec<usize> = get_vec();
    let s_v: Vec<usize> = get_vec();

    let first_list = f_v.into_iter()
        .fold(vec![false; 9], |mut acc, d| {
            acc[d - 1] = true;
            acc
        });

    let second_list = s_v.into_iter()
        .fold(vec![false; 9], |mut acc, d| {
            acc[d - 1] = true;
            acc
        });

    if let Some(i) = (0..first_list.len()).filter(|&i| first_list[i] && second_list[i]).min() {
        println!("{}", i + 1);
    } else {
        let f = first_list.into_iter().position(|p| p).unwrap() + 1;
        let s = second_list.into_iter().position(|p| p).unwrap() + 1;
        print!("{}", min(f, s));
        println!("{}", max(f, s));
    }
}