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

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

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

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

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

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

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

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

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

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

#[allow(dead_code)]
impl ModInt {
    pub fn new(n: u32) -> ModInt {
        ModInt(n % MOD)
    }
    pub fn zero() -> ModInt {
        ModInt(0)
    }
    pub fn one() -> ModInt {
        ModInt(1)
    }
    pub fn pow(self, mut n: u32) -> ModInt {
        let mut t = ModInt::one();
        let mut s = self;
        while n > 0 {
            if n & 1 == 1 {
                t *= s;
            }
            s *= s;
            n >>= 1;
        }
        t
    }
    pub fn inv(self) -> ModInt {
        self.pow(MOD - 2)
    }
    pub fn comb(n: u32, k: u32) -> ModInt {
        if k > n {
            return ModInt::zero();
        }
        let k = std::cmp::min(k, n - k);
        let mut nu = ModInt::one();
        let mut de = ModInt::one();
        for i in 0..k {
            nu *= ModInt(n - i);
            de *= ModInt(i + 1);
        }
        nu * de.inv()
    }
}

#[allow(dead_code)]
struct Precalc {
    inv: Vec<ModInt>,
    fact: Vec<ModInt>,
    ifact: Vec<ModInt>,
}

#[allow(dead_code)]
impl Precalc {
    pub fn new(n: usize) -> Precalc {
        let mut inv = vec![ModInt::one(); n + 1];
        let mut fact = vec![ModInt::one(); n + 1];
        let mut ifact = vec![ModInt::one(); n + 1];
        for i in 2..(n + 1) {
            inv[i] = -inv[MOD as usize % i] * ModInt(MOD / i as u32);
            fact[i] = fact[i - 1] * ModInt(i as u32);
            ifact[i] = ifact[i - 1] * inv[i];
        }
        Precalc {
            inv: inv,
            fact: fact,
            ifact: ifact,
        }
    }
    pub fn inv(&self, n: usize) -> ModInt {
        self.inv[n]
    }
    pub fn fact(&self, n: usize) -> ModInt {
        self.fact[n]
    }
    pub fn ifact(&self, n: usize) -> ModInt {
        self.ifact[n]
    }
    pub fn comb(&self, n: usize, k: usize) -> ModInt {
        if k > n {
            return ModInt::zero();
        }
        self.fact[n] * self.ifact[k] * self.ifact[n - k]
    }
}
// ---------- end ModInt ----------
//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 run() {
    input! {
        n: u32,
        m: u32,
    }
    let ans = (ModInt(2).pow(m) - ModInt(1)).pow(n);
    println!("{}", ans.0);
}

fn main() {
    run();
}


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

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

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

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

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

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

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

fn main() {
  scanln!(n: u64, m: u64);
  let (nt, nb) = (n / 5, n % 5);
  let (mt, mb) = (m / 5, m % 5);
  let mut add_to_five = 0;
  for i in 1..6 {
    let nf = nt + if i <= nb { 1 } else { 0 };
    let mf = mt + if i != 5 && 5 - i <= mb { 1 } else { 0 };
    add_to_five += nf * mf;
  }
  println!("{}", add_to_five);
}


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

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

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

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

fn solve<R: io::BufRead, W: io::Write>(scan: &mut Scanner<R>, out: &mut W) {
    let n: i64 = scan.token();
    let m: i64 = scan.token();
    let mut ans: i64 = 0;
    for x in 1..=n {
        // How many multiples of 5 minus x are there in [1, m]?
        ans += (m + x) / 5 - (x + 5) / 5 + 1;
    }
    writeln!(out, "{}", ans).ok();
}

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


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

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

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

//

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

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

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

fn main() {
    run();
}


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

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

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

//

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

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

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

fn main() {
    run();
}


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

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

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

//

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

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

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

fn main() {
    run();
}


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

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

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

//

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

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

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

fn main() {
    run();
}


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

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

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

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

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

#[derive(Copy, Clone, Eq, PartialEq, Debug)]
struct ReverseInt(i64);

impl Ord for ReverseInt {
    fn cmp(&self, other: &ReverseInt) -> Ordering {
        other.0.cmp(&self.0)
    }
}

impl PartialOrd for ReverseInt {
    fn partial_cmp(&self, other: &ReverseInt) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}

fn main1() {
    let stdin = io::stdin();
    let mut input = Scanner::new(stdin.lock());
    let n: usize = input.next();
    let mut v: Vec<i64> = input.next_vec(n);
    v.sort();
    println!("{}", v[n / 2]);
}

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


use std::io;
use std::io::Read;
// use std::collections::VecDeque;

fn main() {
    let mut input_text = String::new();
    io::stdin().read_to_string(&mut input_text).unwrap();
    let mut iter = input_text.split_whitespace().map(|x| x.parse::<i64>().unwrap());
    let n = iter.next().unwrap();
    let k = iter.next().unwrap();
    let mut ans = n / k * k;
    while ans <= n {
        ans += k
    }
    println!("{}", ans);
}


fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: u64 = it.next().unwrap().parse().unwrap();
    let k: u64 = it.next().unwrap().parse().unwrap();
    let ans = n / k * k + k;
    println!("{}", ans);
}

fn main() {
    run();
}


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

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

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

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

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

fn solve<R: io::BufRead, W: io::Write>(scan: &mut Scanner<R>, out: &mut W) {
    let n: u64 = scan.token();
    let mut ans: u64;
    if n == 1 {
        ans = 1;
    } else if n == 2 {
        ans = 2;
    } else if n == 3 {
        ans = 6;
    } else {
        // pick n and n - 1, find another number coprime to both
        ans = n * (n - 1);
        for p in (1..(n - 1)).rev() {
            if gcd(n, p) == 1 && gcd(n - 1, p) == 1 {
                ans *= p;
                break;
            }
        }
    }
    writeln!(out, "{}", ans).ok();
}

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


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

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

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

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

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

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


use std::io::stdin;

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

fn main() {
    let a = {
        let mut input = String::new();
        stdin().read_line(&mut input).unwrap();
        input.trim().chars().map(|k| k.to_digit(10).unwrap()).collect::<Vec<_>>()
    };

    let la: Vec<_> = a.iter().cloned().take(3).collect();
    let ra: Vec<_> = a.iter().cloned().skip(3).collect();

    let l: u32 = a.iter().cloned().take(3).sum();
    let r: u32 = a.iter().cloned().skip(3).sum();

    let diff = r as i32 - l as i32;

    if diff == 0 {
        println!("0");
        std::process::exit(0);
    }

    let (mut up, mut down) = if diff > 0 {
        (ra, la)
    } else {
        (la, ra)
    };

    let mut v = Vec::new();
    v.append(&mut up);
    v.append(&mut down);

    for a in v.iter_mut().skip(3) {
        *a = 9 - *a;
    }

    let diff = diff.abs();

    let mut sum = 0u32;

    for (i, k) in v.into_iter().rev().enumerate() {
        if sum >= diff as u32 {
            println!("{}", i);
            std::process::exit(0);
        }
        sum += k;
    }
}


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

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

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($format:expr) => (write!(out,$format).unwrap());
        ($format:expr, $($args:expr),+) => (write!(out,$format,$($args),*).unwrap())
    }
    let s: Vec<i32> = get_word().bytes().map(|x| x as i32 - 48).collect();
    let mut mi = 144;
    for mut v in 0 .. 1000000 {
        let mut t = [0; 6];
        for j in 0 .. 6 {
            t[5 - j] = v % 10;
            v /= 10;
        }
        let mut delta = 0;
        for j in 0 .. 3 { delta += t[j]; }
        for j in 3 .. 6 { delta -= t[j]; }
        let mut diff = 0;
        for j in 0 .. 6 {
            diff += if s[j] != t[j] { 1 } else { 0 };
        }
        if delta == 0 {
            mi = min(mi, diff);
        }
    }
    puts!("{}\n", mi);
}

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


use std::io::stdin;

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

fn main() {
    let a = {
        let mut input = String::new();
        stdin().read_line(&mut input).unwrap();
        input.trim().chars().map(|k| k.to_digit(10).unwrap()).collect::<Vec<_>>()
    };

    let la: Vec<_> = a.iter().cloned().take(3).collect();
    let ra: Vec<_> = a.iter().cloned().skip(3).collect();

    let l: u32 = a.iter().cloned().take(3).sum();
    let r: u32 = a.iter().cloned().skip(3).sum();

    let diff = r as i32 - l as i32;

    if diff == 0 {
        println!("0");
        std::process::exit(0);
    }

    let (mut up, mut down) = if diff > 0 {
        (ra, la)
    } else {
        (la, ra)
    };

    let mut v = Vec::new();
    v.append(&mut up);
    v.append(&mut down);

    for a in v.iter_mut().skip(3) {
        *a = 9 - *a;
    }

    v.sort();

    let diff = diff.abs();

    let mut sum = 0u32;

    for (i, k) in v.into_iter().rev().enumerate() {
        if sum >= diff as u32 {
            println!("{}", i);
            std::process::exit(0);
        }
        sum += k;
    }
}


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

fn main() -> () {

    let mut buffer = String::new();
    let stdin = io::stdin();
    let mut handle = stdin.lock();

    handle.read_to_string(&mut buffer).expect("stdin");

    let mut arr : Vec<_> = buffer.split_whitespace().map(|x| x.parse::<i64>().unwrap() ).collect();

    let n = arr[0] as usize;
    let m = arr[1];

    let max_seats = arr.iter().skip(2).max().unwrap();
    let min_seats = arr.iter().skip(2).min().unwrap();

    println!("{} {}", min_seats, max_seats + m );
}


//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 run() {
    input! {
        n: usize,
        m: usize,
        a: [usize; n],
    }
    let max = *a.iter().max().unwrap() + m;
    let mut a = a;
    for _ in 0..m {
        let mut min = (1000000, 0);
        for (i, a) in a.iter().enumerate() {
            min = std::cmp::min(min, (*a, i));
        }
        a[min.1] += 1;
    }
    let min = *a.iter().max().unwrap();
    println!("{} {}", min, max);
}

fn main() {
    run();
}


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

fn main() -> () {

    let mut buffer = String::new();
    let stdin = io::stdin();
    let mut handle = stdin.lock();

    handle.read_to_string(&mut buffer).expect("stdin");

    let mut arr : Vec<_> = buffer.split_whitespace().map(|x| x.parse::<i64>().unwrap() ).collect();

    let n = arr[0];
    let m = arr[1];

    let max_seats = arr.iter().skip(2).max().unwrap();
    let s = arr.iter().skip(2).sum::<i64>();
    let b = (s + m)/n + if (s+m) % n != 0 { 1 } else { 0 };

    use std::cmp;

    println!("{} {}", cmp::max( max_seats, &b ), max_seats + m );
}


// Try Codeforces
// author: Leonardone @ NEETSDKASU

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

    let n = get!() + 1;
    let ans;
    if n == 1 {
        ans = 0;
    } else if n % 2 == 0 {
        ans = n / 2;
    } else {
        ans = n;
    }

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


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

struct Prng {
    a: i32,
    b: i32,
    m: i32,
}

impl Prng {
    pub fn new(a: i32, b: i32, m: i32) -> Self {
        Self { a: a, b: b, m: m }
    }

    pub fn next(&self, r: i32) -> i32 {
        (self.a * r + self.b) % self.m
    }
}

fn solve<R: io::BufRead, W: io::Write>(scan: &mut Scanner<R>, out: &mut W) {
    let a: i32 = scan.token();
    let b: i32 = scan.token();
    let m: i32 = scan.token();
    let r0: i32 = scan.token();

    let gen = Prng::new(a, b, m);
    let mut slow = r0;
    let mut fast = r0;
    loop {
        slow = gen.next(slow);
        fast = gen.next(gen.next(fast));
        if slow == fast {
            break;
        }
    }
    slow = r0;
    while slow != fast {
        slow = gen.next(slow);
        fast = gen.next(fast);
    }
    let mut period = 0;
    loop {
        slow = gen.next(slow);
        period += 1;
        if slow == fast {
            break;
        }
    }
    writeln!(out, "{}", period).ok();
}

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

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

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

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

    pub fn tokens<T: str::FromStr>(&mut self) -> Vec<T> {
        assert!(self.buffer.is_empty());
        let mut input = String::new();
        self.reader.read_line(&mut input).expect("Failed read");
        input
            .split_whitespace()
            .map(|x| x.parse().ok().expect("Failed parse"))
            .collect()
    }
}


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

trait Substring {
    fn substring(&self, start: i32, len: i32) -> String;
}

impl Substring for String {

    fn substring(&self, start: i32, len: i32) -> String {
        self.chars().skip(start as usize).take(len as usize).collect()
    }
}

fn main() {

    let mut n: String = String::new();
    let mut inp: String = String::new();

    io::stdin().read_line(&mut n).unwrap();
    io::stdin().read_line(&mut inp).unwrap();

    let n: i32 = n.trim().parse().unwrap();

    let mut ans: Vec<_> = (0..n/2+1).filter(|&i: &i32| -> bool {
        inp.substring(0, i) == inp.substring(i, i)
    }).collect();

    let ans: i32 = ans.pop().unwrap();
    let display: i32 = n - max(ans-1, 0);

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


use std::io::Write;

pub struct Scanner {
  buffer: Vec<String>
}

impl Scanner {
  pub fn new() -> Scanner {
    Scanner { buffer: Vec::new() }
  }

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

fn calculate(n: usize, g: &Vec<Vec<usize>>, p: &Vec<usize>) -> i32 {
  let mut found: [[bool; 6]; 6] = [[false; 6]; 6];
  let mut ans: i32 = 0;
  for u in 0..n {
    for &v in g[u].iter() {
      let u = p[u];
      let v = p[v];
      if !found[u][v] {
        found[u][v] = true;
        found[v][u] = true;
        ans += 1;
      }
    }
  }
  return ans;
}

fn gen(d: usize, n: usize, g: &Vec<Vec<usize>>, p: &mut Vec<usize>) -> i32 {
  if d == n {
    return calculate(n, g, p);
  }
  let mut ans: i32 = 0;
  for x in 0..6 {
    p[d] = x;
    ans = std::cmp::max(ans, gen(d + 1, n, g, p));
  }
  return ans;
}

fn main() {
  let stdout = std::io::stdout();
  let mut out = std::io::BufWriter::new(stdout.lock());
  let mut scan = Scanner::new();

  let n: usize = scan.next();
  let m: usize = scan.next();
  let mut g: Vec<Vec<usize>> = vec![vec![]; n];
  for _ in 0..m {
    let u: usize = scan.next();
    let v: usize = scan.next();
    g[u - 1].push(v - 1);
    g[v - 1].push(u - 1);
  }
  let mut p: Vec<usize> = vec![0; n];
  let ans = gen(0, n, &g, &mut p);
  writeln!(out, "{}", ans).unwrap();
}


use std::io::{self, Read};
use std::str::FromStr;
use std::fmt::Debug;
use std::vec::IntoIter;
use std::cmp::{max, min};

struct InputReader {
    tokens: IntoIter<String>
}

impl InputReader {
    fn new() -> InputReader {
        let mut input = String::new();
        io::stdin().read_to_string(&mut input).unwrap();
        let tokens: Vec<String> = input.split_whitespace().map(|a| a.to_string()).collect();
        InputReader {
            tokens: tokens.into_iter()
        }
    }

    fn next(&mut self) -> String {
        self.tokens.next().unwrap()
    }

    fn next_val<V: FromStr + Debug>(&mut self) -> V {
        self.next().parse::<V>().ok().unwrap()
    }

    fn next_val_array<V: FromStr + Debug>(&mut self, n: usize) -> Vec<V> {
        let mut vec = Vec::with_capacity(n);
        for _ in 0..n {
            vec.push(self.next_val::<V>());
        }
        vec
    }
}

fn main() {
    let mut reader = InputReader::new();
    let n: i64 = reader.next_val();
    let mut answer = (0i64, 0i64);
    let mut diff = i64::max_value();
    for a in 1..(n+1) {
        if n % a == 0 {
            let b = n / a;
            if b >= a && b - a < diff {
                diff = b - a;
                answer = (a, b);
            }
        }
    }
    println!("{} {}", answer.0, answer.1);
}


//spnauti-rusT
use std::io::*;
use std::str::{self,*};
use std::fmt::Debug;
#[allow(unused_imports)] use std::cmp::Ordering::{self,*};
#[allow(unused_imports)] use std::ops::{self,*};
#[allow(unused_imports)] use std::iter::{self,*};
#[allow(unused_imports)] use std::collections::*;
#[allow(unused_macros)]
macro_rules! m {
    ($c:tt, $x:expr, $y:expr) => {{
        let b = $y; let a = &mut $x;
        if b $c *a { *a = b; true } else { false }
    }};
}
#[allow(unused_macros)]
macro_rules! l {
    ($($v:ident),* = $i:ident.$f:ident $a:tt) => {
        $( let $v = $i.$f$a; )*
    };
    ($($v:ident),*:$t:ty = $i:ident.$f:ident $a:tt) => {
        $( let $v:$t = $i.$f$a; )*
    };
}
struct WordReader<'a> { it : SplitAsciiWhitespace<'a> }
#[allow(dead_code)]
impl<'a> WordReader<'a> {
    fn new<T: Read>(b: &mut String, mut r: T) -> WordReader {
        b.clear();
        r.read_to_string(b).ok();
        WordReader { it: b.split_ascii_whitespace() }
    }
    fn from_stdin(b: &mut String) -> WordReader {
        WordReader::new(b, stdin())
    }
    fn sl(&mut self) ->  &str { self.it.next().unwrap() }
    fn bs(&mut self) -> &[u8] { self.sl().as_bytes()    }
    fn s(&mut self) -> String { String::from(self.sl()) }
    fn i(&mut self) ->    i32 { self.p()                }
    fn f(&mut self) ->    f64 { self.p()                }
    fn u(&mut self) ->  usize { self.p()                }
    fn sk(&mut self, n: usize) { self.it.nth(n - 1); }
    fn ii(&mut self, n: usize) -> impl Iterator<Item=i32> {
        self.ip(n).into_iter()
    }
    fn vi(&mut self, n: usize) -> Vec<i32> {
        self.vp::<i32>(n)
    }
    fn p<T: FromStr>(&mut self) -> T where T::Err: Debug {
        self.sl().parse::<T>().unwrap()
    }
    fn ip<T: FromStr>(&mut self, n: usize) -> impl Iterator<Item=T> where T::Err: Debug {
        self.vp(n).into_iter()
    }
    fn vp<T: FromStr>(&mut self, n: usize) -> Vec<T> where T::Err: Debug {
        (0..n).map(|_| self.p()).collect()
    }
}
//------------------- End rusT

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

    let n = input.i();
    let is_prime_o = |a: i32| -> bool {
        if a < 3 || a % 2 == 0 {
            return false;
        }
        let sq = ((a as f64).sqrt() + 1.0e-6) as i32;
        for i in 3..=sq {
            if a % i == 0 {
                return false;
            }
        }
        return true;
    };
    let print_exit = |sol: &[i32]| -> ! {
        println!("{}", sol.len());
        for &a in sol {
            print!("{} ", a);
        }
        std::process::exit(0);
    };

    if is_prime_o(n) {
        print_exit(&[n]);
    } else {
        const X: usize = 100;
        let mut pairs = vec![None; X];
        for i in 3..X/2 {
            if is_prime_o(i as i32) {
                for j in i..X/2 {
                    if is_prime_o(j as i32) {
                        pairs[i + j] = Some((i as i32, j as i32));
                    }
                }
            }
        }
        let pairs = pairs;
        for i in 6.. {
            assert!(i < X as i32);
            if let Some((a, b)) = pairs[i as usize] {
                if i < n && is_prime_o(n - i) {
                    print_exit(&[a, b, n - i]);
                }
            }
        }
    }
}


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


// {{{ by shik

use std::io;

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

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

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

macro_rules! debug {
    ( $x:expr ) => {{
        println!("{} = {:?}", stringify!($x), $x);
    }};
    ( $x:expr, $($xs:expr),* ) => {{
        print!("{} = {:?}, ", stringify!($x), $x);
        debug!($($xs),*);
    }}
}

// }}}

fn main() {
    let (n, h) = R!(usize, usize);
    let mut dp = vec![vec![0i64; n + 1]; n + 1];
    dp[0][0] = 1;
    for i in 1..n + 1 {
        for j in 1..i + 1 {
            let mut s = 0i64;
            for k in 1..i + 1 {
                let l = k - 1;
                let r = i - k;
                for jl in 0..j {
                    for jr in 0..j {
                        if jl == j - 1 || jr == j - 1 {
                            s += dp[l][jl] * dp[r][jr];
                        }
                    }
                }
            }
            dp[i][j] = s;
        }
    }
    let ans = (h..n + 1).fold(0i64, |s, i| s + dp[n][i]);
    W!(ans);
}


//spnauti-rusT
use std::io::*;
use std::str::{self,*};
use std::fmt::Debug;
#[allow(unused_imports)] use std::cmp::Ordering::{self,*};
#[allow(unused_imports)] use std::ops::{self,*};
#[allow(unused_imports)] use std::iter::{self,*};
#[allow(unused_imports)] use std::collections::*;
#[allow(unused_macros)]
macro_rules! m {
    ($c:tt, $x:expr, $y:expr) => {{
        let b = $y; let a = &mut $x;
        if b $c *a { *a = b; true } else { false }
    }};
}
#[allow(unused_macros)]
macro_rules! l {
    ($($v:ident),* = $i:ident.$f:ident $a:tt) => {
        $( let $v = $i.$f$a; )*
    };
    ($($v:ident),*:$t:ty = $i:ident.$f:ident $a:tt) => {
        $( let $v:$t = $i.$f$a; )*
    };
}
struct WordReader<'a> { it : SplitAsciiWhitespace<'a> }
#[allow(dead_code)]
impl<'a> WordReader<'a> {
    fn new<T: Read>(b: &mut String, mut r: T) -> WordReader {
        b.clear();
        r.read_to_string(b).ok();
        WordReader { it: b.split_ascii_whitespace() }
    }
    fn from_stdin(b: &mut String) -> WordReader {
        WordReader::new(b, stdin())
    }
    fn sl(&mut self) ->  &str { self.it.next().unwrap() }
    fn bs(&mut self) -> &[u8] { self.sl().as_bytes()    }
    fn s(&mut self) -> String { String::from(self.sl()) }
    fn i(&mut self) ->    i32 { self.p()                }
    fn f(&mut self) ->    f64 { self.p()                }
    fn u(&mut self) ->  usize { self.p()                }
    fn sk(&mut self, n: usize) { self.it.nth(n - 1); }
    fn ii(&mut self, n: usize) -> impl Iterator<Item=i32> {
        self.ip(n).into_iter()
    }
    fn vi(&mut self, n: usize) -> Vec<i32> {
        self.vp::<i32>(n)
    }
    fn p<T: FromStr>(&mut self) -> T where T::Err: Debug {
        self.sl().parse::<T>().unwrap()
    }
    fn ip<T: FromStr>(&mut self, n: usize) -> impl Iterator<Item=T> where T::Err: Debug {
        self.vp(n).into_iter()
    }
    fn vp<T: FromStr>(&mut self, n: usize) -> Vec<T> where T::Err: Debug {
        (0..n).map(|_| self.p()).collect()
    }
}
//------------------- End rusT

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

    let mut n = input.i();
    let mut sol = Vec::new();
    while n > 0 {
        let mut t = n;
        let mut res = 0;
        for d in (0..=6).rev().map(|a| 10_i32.pow(a)) {
            let p = t / d;
            if p > 0 {
                t %= d;
                res += d;
            }
        }
        sol.push(res);
        n -= res;
    }
    println!("{}", sol.len());
    for a in sol {
        print!("{} ", a);
    }
}


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

fn not_all_zero(vec: &[u32]) -> bool {
    vec.iter().any(|n| *n != 0)
}

fn take_row(vec: &mut [u32]) -> u32 {
    let mut n = 0;

    for (i, item) in vec.iter_mut().enumerate() {
        if *item > 0 {
            n += 10_u32.pow(i as u32);
            *item -= 1;
        }
    }

    n
}

fn main() {
    let mut n: u32 = read();
    let mut digits = Vec::new();

    while n > 0 {
        digits.push(n % 10);
        n /= 10;
    }

    let mut nums = Vec::new();

    while not_all_zero(&digits) {
        nums.push(take_row(&mut digits));
    }

    println!("{}", nums.len());
    println!("{}",
        nums
            .iter()
            .map(|n| n.to_string())
            .collect::<Vec<_>>()
            .join(" ")
    );
}

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

fn read<T: FromStr>() -> T
    where <T as FromStr>::Err: fmt::Debug
{
    read_line().trim().parse().unwrap()
}


fn read()->Vec<i32>{
    let mut line=String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.split_whitespace().map(|x|x.parse::<i32>().unwrap()).collect()
}
use std::i32;
fn main(){
    let vec=read();
    let stairs=i32::abs(vec[0]-vec[1])*vec[3];
    let lift=i32::abs(vec[0]-vec[1])*vec[4]+3*vec[5]+i32::abs(vec[0]-vec[2])*vec[4];
    if lift<=stairs{
        println!("YES");
    }
    else{
        println!("NO");
    }
}


use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    let mut s = s.split_whitespace();
    let x: i32 = s.next().unwrap().parse().unwrap();
    let y: i32 = s.next().unwrap().parse().unwrap();
    let z: i32 = s.next().unwrap().parse().unwrap();
    let t1: i32 = s.next().unwrap().parse().unwrap();
    let t2: i32 = s.next().unwrap().parse().unwrap();
    let t3: i32 = s.next().unwrap().parse().unwrap();
    if (x - y).abs() * t1 < ((x - z).abs() + (x - y).abs()) * t2 + 3 * t3 {
        println!("NO");
    } else {
        println!("YES");
    }
}


use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    let mut s = s.split_whitespace();
    let x: i32 = s.next().unwrap().parse().unwrap();
    let y: i32 = s.next().unwrap().parse().unwrap();
    let z: i32 = s.next().unwrap().parse().unwrap();
    let t1: i32 = s.next().unwrap().parse().unwrap();
    let t2: i32 = s.next().unwrap().parse().unwrap();
    let t3: i32 = s.next().unwrap().parse().unwrap();
    if (x - y).abs() * t1 < ((x - z).abs() + (x - y).abs()) * t2 + 2 * t3 {
        println!("NO");
    } else {
        println!("YES");
    }
}


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

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

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

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

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

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

fn main() {
    let (n, k) = get!(u64, u64);

    let mut ans = 1;

    if k > 1 {
        for i in 2..k + 1 {
            let u = (n - i + 1..n + 1).fold(1, |a, b| a * b);
            let d = (1..i + 1).fold(1, |a, b| a * b);

            let c = u / d;

            ans += c * [1, 2, 9][(i - 2) as usize];
        }
    }

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


fn main() {
    let v: Vec<i64> = vec![1,0,1,2,9];
    let mut ri = ReadIn::new();
    let tp = ri.int2();
    let mut ans:i64 = 1;
    for kk in 2..tp.1+1 {
        ans += cal(tp.0 as i64, kk as i64) * v[(kk as usize)] ;
    }
    println!("{}", ans)
}

fn cal(n: i64, k: i64) -> i64{
    let mut up: i64 = 1;
    let mut down: i64 = 1;
    for kk in 0..k {
        up = up * (n - kk);
        down = down * (1 + kk);
    }
    up / down
}

use std::iter::Map;
use std::str::SplitWhitespace;
use std::io::stdin;
use std::mem::forget;

pub struct ReadIn(pub String);

impl ReadIn {
    pub fn new() -> ReadIn {
        ReadIn(String::new())
    }
    fn read_i32(s: &str) -> i32 {
        s.parse().unwrap()
    }
    pub fn read_line(&mut self) {
        self.0.clear();
        forget(stdin().read_line(&mut self.0));
    }
    pub fn ints(&mut self) -> Map<SplitWhitespace, fn(&str) -> i32> {
        self.read_line();
        self.0.split_whitespace().map(ReadIn::read_i32)
    }
    pub fn int(&mut self) -> i32 {
        self.ints().next().unwrap()
    }
    pub fn int2(&mut self) -> (i32, i32) {
        let mut it = self.ints();
        (it.next().unwrap(), it.next().unwrap())
    }
}


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

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

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

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

fn egcd(a: i64, b: i64) -> (i64, i64, i64) {
    if b == 0 {
        return (a, 1, 0);
    }
    let (g, x1, y1) = egcd(b, a % b);
    (g, y1, x1 - (a / b) * y1)
}

fn ceil_div(num: i64, denom: i64) -> i64 {
    (num + denom - 1).div_euclid(denom)
}

// Check if the diophantine equation a * x + b * y = c has non-negative solutions.
fn solve<R: io::BufRead, W: io::Write>(scan: &mut Scanner<R>, out: &mut W) {
    let a: i64 = scan.token();
    let b: i64 = scan.token();
    let c: i64 = scan.token();
    let (g, xg, yg) = egcd(a, b);
    if c % g == 0 {
        let x0 = xg * c / g;
        let y0 = yg * c / g;
        // xk = x0 + k * b / g
        // yk = y0 - k * a / g
        // xk >= 0 and yk >= 0
        // After solving for k:
        let ans = (y0 * g).div_euclid(a) - ceil_div(-x0 * g, b) + 1;
        if ans > 0 {
            writeln!(out, "Yes").ok();
        } else {
            writeln!(out, "No").ok();
        }
    } else {
        writeln!(out, "No").ok();
    }
}

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


//! https://codeforces.com/contest/633/problem/A

use std::io;

#[derive(Clone, Copy)]
struct Solution(i32, i32);

fn main() {
    let mut inp = String::new();
    io::stdin().read_line(&mut inp).unwrap();
    let mut iter = inp.trim().split_whitespace();
    let a: i32 = iter.next().unwrap().parse().unwrap();
    let b: i32 = iter.next().unwrap().parse().unwrap();
    let c: i32 = iter.next().unwrap().parse().unwrap();

    println!("{}", match find_if_poss(a, b, c) {
        true => "Yes",
        false => "No"
    })
}

fn gcd(a: i32, b: i32) -> (Solution, i32) {
    if a == 0 {
        (Solution(0, 1), b)
    } else {
        let (Solution(x1, y1), g) = gcd(b % a, a);
        (Solution(y1 - (b / a) * x1, x1), g)
    }
}

fn find_one(a: i32, b: i32, c: i32) -> Option<(Solution, i32)> {
    let (Solution(x, y), g) = gcd(a.abs(), b.abs());
    if c % g != 0 {
        None
    } else {
        let mult = c / g;

        let x = get_sign(a) * mult * x;
        let y = get_sign(b) * mult * y;

        Some((Solution(x, y), g))
    }
}

fn get_sign(i: i32) -> i32 {
    if i < 0 { -1 } else { 1 }
}

fn shift_solution(sol: Solution, ag: i32, bg: i32, offset: i32) -> Solution {
    Solution(sol.0 + bg * offset, sol.1 - ag * offset)
}

fn find_if_poss(a: i32, b: i32, c: i32) -> bool {
    match find_one(a, b, c) {
        Some((mut sol, g)) => {
            let sign_a = get_sign(a);
            let sign_b = get_sign(b);

            let maxx = c/a;
            let maxy = c/b;

            let a = a / g;
            let b = b / g;

            let minx_offset = -sol.0/b;
            sol = shift_solution(sol, a, b, minx_offset);
            if sol.0 < 0 {
                sol = shift_solution(sol, a, b, sign_b);
            }
            if sol.0 > maxx {
                return false;
            }
            let lx1 = sol.0;

            let maxx_offset = (maxx - sol.0)/b;
            sol = shift_solution(sol, a, b, maxx_offset);
            if sol.0 > maxx {
                sol = shift_solution(sol, a, b, -sign_b);
            }
            let rx1 = sol.0;

            let miny_offset = sol.1/a;
            sol = shift_solution(sol, a, b, miny_offset);
            if sol.1 < 0 {
                sol = shift_solution(sol, a, b, -sign_a);
            }
            if sol.1 > maxy {
                return false;
            }
            let mut lx2 = sol.0;

            let maxy_offset = (sol.1 - maxy) / a;
            sol = shift_solution(sol, a, b, maxy_offset);
            if sol.1 > maxy {
                sol = shift_solution(sol, a, b, sign_a);
            }
            let mut rx2 = sol.0;

            if lx2 > rx2 {
                let temp = lx2;
                lx2 = rx2;
                rx2 = temp;
            }

            let lx = if lx1 > lx2 { lx1 } else { lx2 };
            let rx = if rx1 < rx2 { rx1 } else { rx2 };

            if lx > rx {
                return false;
            }

            let count = (rx - lx)/b.abs() + 1;

            count > 0
        },
        None => false
    }
}


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

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

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

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

fn egcd(a: i64, b: i64) -> (i64, i64, i64) {
    if b == 0 {
        return (a, 1, 0);
    }
    let (g, x1, y1) = egcd(b, a % b);
    (g, y1, x1 - (a / b) * y1)
}

fn ceil_div(num: i64, denom: i64) -> i64 {
    (num + denom - 1).div_euclid(denom)
}

// Check if the diophantine equation a * x + b * y = c has non-negative solutions.
fn solve<R: io::BufRead, W: io::Write>(scan: &mut Scanner<R>, out: &mut W) {
    let a: i64 = scan.token();
    let b: i64 = scan.token();
    let c: i64 = scan.token();
    let (g, xg, yg) = egcd(a, b);
    if c % g == 0 {
        let x0 = xg * c / g;
        let y0 = yg * c / g;
        // xk = x0 + k * b / g
        // yk = y0 - k * a / g
        // xk >= 0 and yk >= 0
        // After solving for k:
        let ans = y0 * g / a - ceil_div(-x0 * g, b) + 1;
        if ans >= 0 {
            writeln!(out, "Yes").ok();
        } else {
            writeln!(out, "No").ok();
        }
    } else {
        writeln!(out, "No").ok();
    }
}

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


use std::collections::BinaryHeap;
use std::io;

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

fn main() -> io::Result<()> {
    get_line()?;
    let buf = get_line()?;
    let mut iter = buf.split_ascii_whitespace().map(|x| x.parse().unwrap());

    let init = iter.next().unwrap();
    let a: Vec<u32> = iter.collect();

    let mut heap = BinaryHeap::from(a);
    let mut ans = 0;

    while *heap.peek().unwrap() >= init + ans {
        let top = heap.pop().unwrap();
        heap.push(top - 1);
        ans += 1;
    }

    println!("{}", ans);

    Ok(())
}


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

fn get_nums() -> (i32, i32, i32, i32, i32, i32, i32, i32) {
	let mut input = String::new();

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

	let v = input.trim()
			.split_whitespace()
			.map(|d| i32::from_str(d).unwrap())
			.collect::<Vec<_>>();

	(v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7])
}

fn main() {
	let (n, k, l, c, d, p, nl, np) = get_nums();

	println!("{}", min((k*l)/nl, c*d, p/np)/n);

	fn min(x: i32, y: i32, z: i32) -> i32 {
		if x < y {
			if x < z {
				x
			} else {
				z
			}
		} else if y < z {
			y
		} else {
			z
		}
	}
}


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

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

    let a = input.vp::<i32>(8);
    let sol = (a[1] * a[2] / a[6]).min(a[3] * a[4]).min(a[5] / a[7]) / a[0];
    println!("{}", sol);
}


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

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

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

}

fn _main() {
    let mut scan = Scan::new();
    let n: usize = scan.next();
    let k: usize = scan.next();
    let l: usize = scan.next();
    let c: usize = scan.next();
    let d: usize = scan.next();
    let p: usize = scan.next();
    let nl: usize = scan.next();
    let np: usize = scan.next();
    let l_person = l*k/nl;
    let c_person = c*d;
    let p_person = p/np;
    let result = l_person.min(c_person).min(p_person)/n;
    println!("{}", result);
}

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


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

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

fn is_leap(y: i64) -> bool {
    y % 400 == 0 || y % 4 == 0 && y % 100 != 0
}

fn parse_date() -> i64 {
    let s = parse_line!(String);
    let mut it = s.split(':');
    let y: i64 = it.next().unwrap().parse().unwrap();
    let m: i64 = it.next().unwrap().parse().unwrap();
    let d: i64 = it.next().unwrap().parse().unwrap();
    let mut result = d;
    for i in 0..y {
        result += 365;
        if is_leap(i) {
            result += 1;
        }
    }
    let days = [31, 28 + if is_leap(y) {1} else {0}, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
    for i in 0..m - 1 {
        result += days[i as usize];
    }
    return result;
}

fn solve() {
    let from = parse_date();
    let to = parse_date();
    println!("{}", (from - to).abs());
}

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


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

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

const INF: i64 = 1 << 60;

fn calc(a: &[i64], h: i64, w: i64) -> i64 {
    // at most 34 = 2 * 17
    let n = a.len();
    let mut cur = HashSet::new();
    cur.insert((1, 1));
    for i in 0 .. n + 1 {
        let mut nxt = HashSet::new();
        for (x, y) in cur {
            if x >= h && y >= w {
                return i as i64;
            }
            if i < n {
                if x < h {
                    nxt.insert((x * a[i], y));
                }
                if y < w {
                    nxt.insert((x, a[i] * y));
                }
            }
        }
        cur = nxt;
    }
    return INF;
}

fn solve() {
    let a: i64 = get();
    let b: i64 = get();
    let h: i64 = get();
    let w: i64 = get();
    let n = get();
    let mut ary: Vec<i64> = (0 .. n).map(|_| get()).collect();
    ary.sort();
    ary.reverse();
    let mut mi = calc(&ary, (a + h - 1) / h, (b + w - 1) / w);
    mi = min(mi, calc(&ary, (b + h - 1) / h, (a + w - 1) / w));
    println!("{}", if mi == INF { -1 } else { mi });
}

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


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

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

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

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

    if t <= k {
        println!("{}", t);
    } else if t <= n {
        println!("{}", k);
    } else {
        let d = k - (t - n);
        println!("{}", d);
    }
}


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

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


#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

const INF: i64 = 1 << 60;

fn dist((a, b): (i64, i64), (c, d): (i64, i64)) -> i64 {
    (a - c).abs() + (b - d).abs()
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($format:expr) => (write!(out,$format).unwrap());
        ($format:expr, $($args:expr),+) => (write!(out,$format,$($args),*).unwrap())
    }
    input! {
        n: usize,
        xy: [(i64, i64); n],
    }
    let mut s = Vec::new();
    for &(x, y) in xy.iter() {
        s.push(max(x, y));
    }
    s.sort();
    s.dedup();
    let m = s.len();
    let mut aa = vec![Vec::new(); m + 1];
    for &(x, y) in xy.iter() {
        let idx = s.binary_search(&max(x, y)).unwrap();
        aa[idx + 1].push((x, y));
    }
    aa[0].push((0, 0));
    for i in 0 .. m + 1 {
        for u in aa[i].iter_mut() { u.1 *= -1; }
        aa[i].sort();
        for u in aa[i].iter_mut() { u.1 *= -1; }
        if aa[i].len() == 1 {
            let v = aa[i][0];
            aa[i].push(v);
        }
        if aa[i].len() >= 2 {
            let v = aa[i].pop().unwrap();
            while aa[i].len() > 1 {
                aa[i].pop();
            }
            aa[i].push(v);
        }
    }
    let mut dp = vec![[INF; 2]; m + 1];
    dp[0][0] = 0;
    dp[0][1] = 0;
    for i in 0 .. m {
        for j in 0 .. 2 {
            for k in 0 .. 2 {
                dp[i + 1][1 - k] = min(dp[i + 1][1 - k], dp[i][j] + dist(aa[i][j], aa[i + 1][k]) + dist(aa[i + 1][k], aa[i + 1][1 - k]));
            }
        }
    }
    puts!("{}\n", min(dp[m][0], dp[m][1]));
}

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


// use wyf_lib::*;

fn main() {
    let n: usize = read();
    let m: usize = read();

    if n == 1 {
        println!("1");
        return;
    }

    let mut k = 0;
    while 1 << k < n {
        k += 1;
    }
    let mut dp = vec![false; k * m + 1];
    let mut cnts = vec![0];
    for i in 1..=k {
        let mut cnt = 0;
        for j in 1..=m {
            let cur = i * j;
            if !dp[cur] {
                dp[cur] = true;
                cnt += 1;
            }
        }
        cnts.push(cnt);
    }
    let mut counted = vec![false; n + 1];

    let mut res: i64 = 1;
    'i: for i in 2..=n {
        let mut c = 1;
        let mut curr = i;

        while curr <= n {
            if counted[curr] {
                continue 'i;
            }
            counted[curr] = true;
            res += cnts[c];
            curr *= i;
            c += 1;
        }
    }

    res.println();
}

use std::error;
use std::fmt;
use std::str::FromStr;

#[non_exhaustive]
#[derive(Debug, PartialEq)]
pub enum Error {
    MissingMatch,
    MissingClosingBrace,
    UnexpectedValue(u8, Option<u8>),
    InvalidUtf8(Vec<u8>),
    PartialUtf8(usize, Vec<u8>),
    Parse(String, &'static str),
}

impl error::Error for Error {}

impl fmt::Display for Error {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        use crate::Error::*;
        use std::str::from_utf8;

        match *self {
            InvalidUtf8(ref raw) => write!(f, "input was not valid utf8: {:?}", raw),
            Parse(ref s, arg) => write!(f, "could not parse {} as target type of {}", s, arg),
            UnexpectedValue(exp, act) => write!(
                f,
                "found value {:?} not matching the pattern value {}",
                act.map(|b| b as char),
                exp as char
            ),
            PartialUtf8(n, ref raw) => write!(
                f,
                "input was only partially valid utf8: \"{}\" followed by {:?}",
                from_utf8(&raw[..n]).unwrap(),
                &raw[n..]
            ),
            MissingMatch => write!(f, "Bad read! format string: did not contain {{}}"),
            MissingClosingBrace => write!(
                f,
                "found single open curly brace at the end of the format string"
            ),
        }
    }
}

pub fn match_next(expected: u8, iter: &mut dyn Iterator<Item = u8>) -> Result<(), Error> {
    let next = iter.next();
    if next != Some(expected) {
        return Err(Error::UnexpectedValue(expected, next));
    }
    Ok(())
}

pub fn parse_capture<T>(
    name: &'static str,
    next: Option<u8>,
    iter: &mut dyn Iterator<Item = u8>,
) -> Result<T, Error>
where
    T: FromStr,
    <T as FromStr>::Err: ::std::fmt::Debug,
{
    static WHITESPACES: &[u8] = b"\t\r\n ";
    let raw: Vec<u8> = match next {
        Some(c) => iter.take_while(|&ch| ch != c).collect(),
        None => iter
            .skip_while(|ch| WHITESPACES.contains(ch))
            .take_while(|ch| !WHITESPACES.contains(ch))
            .collect(),
    };
    match String::from_utf8(raw) {
        Ok(s) => FromStr::from_str(&s).map_err(|_| Error::Parse(s, name)),
        Err(e) => {
            let n = e.utf8_error().valid_up_to();
            let raw = e.into_bytes();
            if n == 0 {
                Err(Error::InvalidUtf8(raw))
            } else {
                Err(Error::PartialUtf8(n, raw))
            }
        }
    }
}

#[macro_export]
macro_rules! try_read(
    () => { $crate::try_read!("{}") };
    ($text:expr) => {{
        (|| -> std::result::Result<_, $crate::Error> {
            let __try_read_var__;
            $crate::try_scan!($text, __try_read_var__);
            Ok(__try_read_var__)
        })()
    }};
    ($text:expr, $input:expr) => {{
        (|| -> std::result::Result<_, $crate::Error> {
            let __try_read_var__;
            $crate::try_scan!($input => $text, __try_read_var__);
            Ok(__try_read_var__)
        })()
    }};
);

#[macro_export]
macro_rules! try_scan(
    ($pattern:expr, $($arg:expr),*) => {
        use ::std::io::Read;
        $crate::try_scan!(::std::io::stdin().bytes().map(std::result::Result::unwrap) => $pattern, $($arg),*);
    };
    ($input:expr => $pattern:expr, $($arg:expr),*) => {{
        $crate::try_scan!(@impl question_mark; $input => $pattern, $($arg),*)
    }};
    (@question_mark: $($e:tt)+) => {{
        ($($e)+)?
    }};
    (@unwrap: $($e:tt)+) => {{
        ($($e)+).unwrap()
    }};
    (@impl $action:tt; $input:expr => $pattern:expr, $($arg:expr),*) => {{
        #![allow(clippy::try_err)]
        use $crate::{Error, match_next, parse_capture};

        // typesafe macros :)
        let pattern: &'static str = $pattern;
        let stdin: &mut dyn Iterator<Item = u8> = &mut ($input);

        let mut pattern = pattern.bytes();

        $(
            $arg = loop {
                match $crate::try_scan!(@$action: pattern.next().ok_or(Error::MissingMatch)) {
                    b'{' => match $crate::try_scan!(@$action: pattern.next().ok_or(Error::MissingClosingBrace)) {
                        b'{' => $crate::try_scan!(@$action: match_next(b'{', stdin)),
                        b'}' => break $crate::try_scan!(@$action: parse_capture(stringify!($arg), pattern.next(), stdin)),
                        _ => return $crate::try_scan!(@$action: Err(Error::MissingClosingBrace)),
                    },
                    c => $crate::try_scan!(@$action: match_next(c, stdin)),
                }
            };
        )*

        for c in pattern {
            $crate::try_scan!(@$action: match_next(c, stdin))
        }

        format_args!($pattern, $($arg),*);
    }};
);

#[macro_export]
macro_rules! read(
    ($($arg:tt)*) => {
        $crate::try_read!($($arg)*).unwrap()
    };
);

#[macro_export]
macro_rules! scan(
    ($text:expr, $($arg:expr),*) => {
        {
            use ::std::io::Read;
            $crate::scan!(::std::io::stdin().bytes().map(std::result::Result::unwrap) => $text, $($arg),*);
        }
    };
    ($input:expr => $pattern:expr, $($arg:expr),*) => {{
        $crate::try_scan!(@impl unwrap; $input => $pattern, $($arg),*)
    }};
);
use std::marker::PhantomData;
use std::ops;

// use text_io::read;

/*** READ and WRITE ***/

pub trait Readable {
    fn read() -> Self;
}

pub trait Printable {
    fn print(self: &Self);
    fn println(self: &Self) {
        self.print();
        println!();
    }
}

macro_rules! impl_rp_simple {
    ($($t:ident), +) => {
        $(
            impl Readable for $t {
                fn read() -> Self {
                    read!()
                }
            }

            impl Printable for $t {
                fn print(self: &Self) {
                    print!("{self} ");
                }
            }
        )+
    };
}

impl_rp_simple!(
    String, i8, i16, i32, i64, i128, isize, u8, u16, u32, u64, u128, usize, f32, f64, char
);

macro_rules! impl_rp_tuple {
    () => {};
    ($t0:ident, $($t:ident,) *) => {
        impl<$t0: Readable, $($t: Readable), *> Readable for ($t0, $($t,)*) {
            fn read() -> Self {
                (read(), $(read::<$t>(),)*)
            }
        }

        impl<$t0: Printable, $($t: Printable), *> Printable for ($t0, $($t,)*) {
            fn print(self: &Self) {
                #[allow(non_snake_case)]
                let (ref $t0, $(ref $t,)*) = &self;
                $t0.print();
                $(
                    $t.print();
                )*
            }
        }

        impl_rp_tuple!{$($t,) *}
    };
}

impl<T: Printable> Printable for Vec<T> {
    fn print(self: &Self) {
        for x in self {
            x.print();
        }
    }
}

impl<T: Printable> Printable for [T] {
    fn print(self: &Self) {
        for x in self {
            x.print();
        }
    }
}

impl_rp_tuple! {T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,}

pub fn read<T: Readable>() -> T {
    T::read()
}

pub fn readv<T: Readable>(size: usize) -> Vec<T> {
    let mut res = Vec::with_capacity(size);
    for _ in 0..size {
        res.push(read());
    }
    res
}

pub fn readb() -> Vec<u8> {
    let s: String = read!();
    s.as_bytes().into_iter().cloned().collect()
}

/*** RECURSIVE LAMBDA ***/

macro_rules! recursive_fn {
    () => {};
    ($name0:ident $trait0:ident $_:ident $__:ident, $($name:ident $trait:ident $Arg:ident $arg:ident,)*) => {
        pub trait $trait0<$($Arg,)* Output> {
            fn call(&mut self, $($arg: $Arg,)*) -> Output;
        }

        pub struct $name0<F, $($Arg,)* Output>
        where
            F: FnMut(&mut dyn $trait0<$($Arg,)* Output>, $($Arg,)*) -> Output,
        {
            f: std::cell::UnsafeCell<F>,
            $(
                $arg: PhantomData<$Arg>,
            )*
            phantom_output: PhantomData<Output>,
        }

        impl<F, $($Arg,)* Output> $name0<F, $($Arg,)* Output>
        where
            F: FnMut(&mut dyn $trait0<$($Arg,)* Output>, $($Arg,)*) -> Output,
        {
            pub fn new(f: F) -> Self {
                Self {
                    f: std::cell::UnsafeCell::new(f),
                    $(
                        $arg: PhantomData,
                    )*
                    phantom_output: PhantomData,
                }
            }
        }

        impl<F, $($Arg,)* Output> $trait0<$($Arg,)* Output> for $name0<F, $($Arg,)* Output>
        where
            F: FnMut(&mut dyn $trait0<$($Arg,)* Output>, $($Arg,)*) -> Output,
        {
            fn call(&mut self, $($arg: $Arg,)*) -> Output {
                unsafe { (&mut *self.f.get())(self, $($arg,)*) }
            }
        }

        recursive_fn!{$($name $trait $Arg $arg,)*}
    };
}

recursive_fn! {
    RecursiveFn11 Callable11 Arg11 arg11,
    RecursiveFn10 Callable10 Arg10 arg10,
    RecursiveFn9 Callable9 Arg9 arg9,
    RecursiveFn8 Callable8 Arg8 arg8,
    RecursiveFn7 Callable7 Arg7 arg7,
    RecursiveFn6 Callable6 Arg6 arg6,
    RecursiveFn5 Callable5 Arg5 arg5,
    RecursiveFn4 Callable4 Arg4 arg4,
    RecursiveFn3 Callable3 Arg3 arg3,
    RecursiveFn2 Callable2 Arg2 arg2,
    RecursiveFn1 Callable1 Arg1 arg1,
    RecursiveFn0 Callable0 Arg0 arg0,
}

/*** MOD ***/

// gcd, x, y
pub fn extended_gcd(a: i64, b: i64) -> (i64, i64, i64) {
    if a == 0 {
        (b, 0, 1)
    } else {
        let (g, y, mut x) = extended_gcd(b % a, a);
        x -= (b / a) * y;
        (g, x, y)
    }
}

pub trait HasConstVal {
    const VAL: i64;
}

// const of V has to be prime
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct ModBase<M: HasConstVal + Copy> {
    v: i64,
    phantom: PhantomData<M>,
}

impl<M: HasConstVal + Copy> ModBase<M> {
    pub fn new(mut v: i64) -> Self {
        v %= M::VAL;
        if v < 0 {
            v = v + M::VAL;
        }
        Self {
            v,
            phantom: PhantomData,
        }
    }

    pub fn inv(&self) -> Self {
        let (_, x, _) = extended_gcd(self.v, M::VAL);
        Self::new(x)
    }

    pub fn pow(&self, n: usize) -> Self {
        let v = self.v;
        let mut res = Self::new(1);
        for _ in 0..n {
            res *= v;
        }
        res
    }
}

impl<M: HasConstVal + Copy> ops::Add<i64> for ModBase<M> {
    type Output = Self;

    fn add(self, rhs: i64) -> Self {
        Self::new(self.v + rhs)
    }
}

impl<M: HasConstVal + Copy> ops::Add for ModBase<M> {
    type Output = Self;

    fn add(self, rhs: Self) -> Self {
        Self::new(self.v + rhs.v)
    }
}

impl<M: HasConstVal + Copy> ops::AddAssign<i64> for ModBase<M> {
    fn add_assign(&mut self, rhs: i64) {
        self.v = (self.v + rhs) % M::VAL;
    }
}

impl<M: HasConstVal + Copy> ops::AddAssign for ModBase<M> {
    fn add_assign(&mut self, rhs: Self) {
        self.v = (self.v + rhs.v) % M::VAL;
    }
}

impl<M: HasConstVal + Copy> ops::Sub<i64> for ModBase<M> {
    type Output = Self;

    fn sub(self, rhs: i64) -> Self {
        Self::new(self.v - rhs)
    }
}

impl<M: HasConstVal + Copy> ops::Sub for ModBase<M> {
    type Output = Self;

    fn sub(self, rhs: Self) -> Self {
        Self::new(self.v - rhs.v)
    }
}

impl<M: HasConstVal + Copy> ops::SubAssign<i64> for ModBase<M> {
    fn sub_assign(&mut self, rhs: i64) {
        self.v = (self.v - rhs) % M::VAL;
    }
}

impl<M: HasConstVal + Copy> ops::SubAssign for ModBase<M> {
    fn sub_assign(&mut self, rhs: Self) {
        self.v = (self.v - rhs.v) % M::VAL;
    }
}

impl<M: HasConstVal + Copy> ops::Mul<i64> for ModBase<M> {
    type Output = Self;

    fn mul(self, rhs: i64) -> Self::Output {
        Self::new(self.v * rhs)
    }
}

impl<M: HasConstVal + Copy> ops::Mul for ModBase<M> {
    type Output = Self;

    fn mul(self, rhs: Self) -> Self::Output {
        Self::new(self.v * rhs.v)
    }
}

impl<M: HasConstVal + Copy> ops::MulAssign<i64> for ModBase<M> {
    fn mul_assign(&mut self, rhs: i64) {
        self.v = self.v * rhs % M::VAL;
    }
}

impl<M: HasConstVal + Copy> ops::MulAssign for ModBase<M> {
    fn mul_assign(&mut self, rhs: Self) {
        self.v = self.v * rhs.v % M::VAL;
    }
}

impl<M: HasConstVal + Copy> ops::Div<i64> for ModBase<M> {
    type Output = Self;

    fn div(self, rhs: i64) -> Self::Output {
        self * Self::new(rhs).inv()
    }
}

impl<M: HasConstVal + Copy> ops::Div for ModBase<M> {
    type Output = Self;

    fn div(self, rhs: Self) -> Self::Output {
        self * rhs.inv()
    }
}

impl<M: HasConstVal + Copy> ops::DivAssign<i64> for ModBase<M> {
    fn div_assign(&mut self, rhs: i64) {
        self.v = (Self::new(self.v) / rhs).v;
    }
}

impl<M: HasConstVal + Copy> ops::DivAssign for ModBase<M> {
    fn div_assign(&mut self, rhs: Self) {
        self.v = (Self::new(self.v) / rhs).v;
    }
}

impl<M: HasConstVal + Copy> ops::Neg for ModBase<M> {
    type Output = Self;

    fn neg(self) -> Self::Output {
        Self::new(-self.v)
    }
}

impl<M: HasConstVal + Copy> ops::Deref for ModBase<M> {
    type Target = i64;

    fn deref(&self) -> &Self::Target {
        &self.v
    }
}

#[macro_export]
macro_rules! Mod {
    ($val: expr) => {
        Mod!(Mod, ModV, $val);
    };
    ($name: ident, $v_name: ident, $val: expr) => {
        #[derive(Copy, Clone, Eq, PartialEq)]
        pub struct $v_name {}

        impl crate::HasConstVal for $v_name {
            const VAL: i64 = $val as i64;
        }

        type $name = ModBase<$v_name>;
    };
}


use std::io::{self, Stdin};
use std::str::{self, FromStr};
use std::error::Error;
use std::thread;
use std::collections::BTreeSet;
fn exec() {
    let mut sc = Scanner::new();
    let s: String = sc.ne();
    let mut m = BTreeSet::new();
    let n = s.len();
    for i in 0..n {
        let mut ss = s[i..n].to_string();
        ss.push_str(&s[0..i]);
        m.insert(ss);
    }
    println!("{}", m.len());
}
const DEFAULT_STACK: usize = 16 * 1024 * 1024;
fn main() {
    let builder = thread::Builder::new();
    let th = builder.stack_size(DEFAULT_STACK);
    let handle = th.spawn(|| { exec(); }).unwrap();
    let _ = handle.join();
}

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

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


//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 run() {
    input! {
        a: (u32, u32),
        b: (u32, u32),
        s: chars,
    }
    let mut f = 0;
    f += s[0].to_digit(10).unwrap() * 10 * 60;
    f += s[1].to_digit(10).unwrap() * 60;
    f += s[3].to_digit(10).unwrap() * 10;
    f += s[4].to_digit(10).unwrap();
    assert!((f - 300) % a.0 == 0);
    let start = f;
    let end = start + a.1;
    let mut p = 300;
    let mut ans = 0;
    while p < 24 * 60 {
        let (s, e) = (p, p + b.1);
        let (l, r) = (std::cmp::max(s, start), std::cmp::min(e, end));
        if l < r {
            ans += 1;
        }
        p += b.0;
    }
    println!("{}", ans);
}

fn main() {
    run();
}


use std::io;
use std::iter;
use std::cmp;

fn main() {
    let (a, b): (f64, f64) = {
        let mut input = String::new();
        io::stdin().read_line(&mut input).unwrap();
        let mut it = input.split_whitespace().map(|k| k.parse().unwrap());
        (
            it.next().unwrap(),
            it.next().unwrap(),
            )
    };

    let n1 = a.sqrt().floor() - 1.0;

    let delta = 1.0 + 4.0 * b;
    let n2 = (delta.sqrt() - 1.0) / 2.0;
    let n2 = n2.floor();

    if n1 < n2 {
        println!("Vladik");
    } else {
        println!("Valera");
    }
}


use std::io;
use std::iter;
use std::cmp;

fn main() {
    let (a, b): (f64, f64) = {
        let mut input = String::new();
        io::stdin().read_line(&mut input).unwrap();
        let mut it = input.split_whitespace().map(|k| k.parse().unwrap());
        (
            it.next().unwrap(),
            it.next().unwrap(),
            )
    };

    let delta = 1.0 + 4.0 * a;
    let n1 = (delta.sqrt() - 1.0) / 2.0;
    let n1 = n1.floor();

    let n2 = b.sqrt().floor() - 1.0;

    println!("{} {}", n1, n2);

    if n2 < n1 {
        println!("Valera");
    } else {
        println!("Vladik");
    }
}