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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

const MODULO: u64 = 1_000_000_007;

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

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

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

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

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

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

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

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

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

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

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

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

fn dp(graph: &Vec<Vec<usize>>, weights: &Vec<u64>, node: usize) -> (u64, u64, usize) {
    if graph[node].is_empty() {
        return (weights[node], 0, 1);
    }
    let weight = weights[node];
    let ans_vec = graph[node]
        .iter()
        .map(|neighbour| dp(graph, weights, *neighbour))
        .collect::<Vec<_>>();
    let max_ans = ans_vec
        .iter()
        .map(|(a, _residue, _leaves)| *a)
        .max()
        .unwrap();
    let sum_residue = ans_vec
        .iter()
        .map(|(a, res, leaves)| res + (max_ans - a) * (*leaves) as u64)
        .sum::<u64>();
    let total_leaves = ans_vec.into_iter().map(|(_a, _r, l)| l).sum::<usize>();
    if sum_residue >= weight {
        (max_ans, sum_residue - weight, total_leaves)
    } else {
        let residue = weight - sum_residue;
        (
            max_ans + ((residue + total_leaves as u64 - 1) / total_leaves as u64),
            residue % total_leaves as u64,
            total_leaves,
        )
    }
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let (n, x, pos) = read_3::<usize, usize, usize>();
    let mut left = 0;
    let mut right = n;
    //let mut checks = Vec::new();
    let mut prefix = 0;
    let mut postfix = 0;
    while left < right {
        let middle = (left + right) / 2;
        //checks.push(middle);
        if middle <= pos {
            left = middle + 1;
            prefix += 1;
        } else {
            right = middle;
            postfix += 1;
        }
    }
    //checks.sort_unstable();
    // let prefix = checks.iter().take_while(|v| **v <= pos).count();
    //let postfix = checks.iter().skip_while(|v| **v <= pos).count();
    //println!("{:?}", checks);
    //println!("{:?}", prefix);
    //println!("{:?}", postfix);
    let remain = n - prefix - postfix;
    let mut res = BigPrimeRing::from(1u8);
    for i in 1..=remain {
        res *= i as u64
    }
    //println!("{}", res.inner);
    for i in (x - prefix + 1)..=(x - 1) {
        res *= i as u64
    }
    //println!("{}", res.inner);
    for i in ((n - x) - postfix + 1)..=(n - x) {
        res *= i as u64
    }
    println!("{}", res.inner);
    Ok(())
}


use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut s: Vec<u8> = s.trim().bytes().collect();
    let mut count: u32 = 0;
    while s.len() > 1 {
        let mut b = false;
        let mut i = 0;
        while i < s.len() - 1 {
            if s[i] as i16 - s[i + 1] as i16 == 1 {
                b = true;
                s.remove(i);
                count += 1;
            }
            i += 1;
        }
        i = s.len() - 1;
        while i > 0 {
            if s[i] as i16 - s[i - 1] as i16 == 1 {
                b = true;
                s.remove(i);
                count += 1;
            }
            i -= 1;
        }
        if !b {
            break;
        }
    }
    println!("{}", count);
}


#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

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

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

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);
impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}
impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

struct BinaryIndexedTree {
    tree: Vec<isize>,
}
impl BinaryIndexedTree {
#[allow(dead_code)]
    fn new(n: usize) -> Self {
        BinaryIndexedTree {
            tree: vec![0; n + 1],
        }
    }
#[allow(dead_code)]
    fn add(&mut self, a: usize, w: isize) {
        let mut x = a as isize + 1;
        while x < self.tree.len() as isize {
            self.tree[x as usize] += w;
            x += x & (-x);
        }
    }
#[allow(dead_code)]
    fn sum(&self, n: usize) -> isize {
        let mut x = n as isize;
        let mut ret = 0;
        while x > 0 {
            ret += self.tree[x as usize];
            x -= x & (-x);
        }
        ret
    }
#[allow(dead_code)]
    fn sum_with(&self, l: usize, r: usize) -> isize {
        if l == 0 {
            self.sum(r)
        } else {
            self.sum(r) - self.sum(l - 1)
        }
    }
}

fn solve() {
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    let n = get!(usize);
    let mut s = get!(String).chars().map(|e| e as usize - 'a' as usize).collect::<Vec<_>>();

    let mut is = s.clone().into_iter().enumerate().collect::<Vec<_>>();
    is.sort_by_key(|e|Rev(e.1));

    let mut bit = BinaryIndexedTree::new(n+1);
    for (i,c) in is {
        let j = i-bit.sum(i) as usize;
        if (j>0 && s[j-1]+1 == c) || (j<s.len()-1 && s[j+1]+1 == c) {
            bit.add(i,1);
            s.remove(j);
        }
    }
    writeln!(out, "{}", n-s.len()).unwrap();
}


#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::*;
use std::str::FromStr;

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

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const MOD:i64 = 1e9 as i64 + 7;

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

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

#[allow(unused_imports)]
use std::f64;

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

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

fn main() {
    input!{n:usize, s:chars};
    let mut s = s;

    let mut ans = 0;

    loop {
        let mut f = vec![false;s.len()];
        for i in 0..s.len() {
            if i==0 {
                if s[i] as u8 == s[i+1] as u8 + 1 {
                    f[i] = true;
                }
            }
            else if i == s.len()-1 {
                if s[i] as u8 == s[i-1] as u8 + 1 {
                    f[i] = true;
                }
            }
            else {
                if s[i] as u8 == s[i-1] as u8 +1 {
                    f[i] = true;
                }
                if s[i] as u8 == s[i+1] as u8 + 1 {
                    f[i] = true;
                }
            }
        }
        let mut t = vec![];
        let mut cnt = 0;
        for i in 0..s.len() {
            if !f[i] {
                t.push(s[i]);
            }
            else { cnt += 1; }
        }
        //debug!(t);
        if cnt == 0 { break; }
        ans += cnt;
        if t.len() == 1 { break; }
        s = t;
    }

    println!("{}", ans);

}


#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::*;
use std::str::FromStr;

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

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const MOD:i64 = 1e9 as i64 + 7;

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

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

#[allow(unused_imports)]
use std::f64;

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

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

fn main() {
    input!{n:usize, s:chars};
    let mut s = s;

    let mut ans = 0;

    loop {
        if s.len() == 1 { break; }
        let mut f = vec![false;s.len()];
        for i in 0..s.len() {
            if i==0 {
                if s[i] as u8 == s[i+1] as u8 + 1 {
                    f[i] = true;
                }
            }
            else if i == s.len()-1 {
                if s[i] as u8 == s[i-1] as u8 + 1 {
                    f[i] = true;
                }
            }
            else {
                if s[i] as u8 == s[i-1] as u8 +1 {
                    f[i] = true;
                }
                if s[i] as u8 == s[i+1] as u8 + 1 {
                    f[i] = true;
                }
            }
        }
        let mut t = vec![];
        let mut cnt = 0;
        for i in 0..s.len() {
            if !f[i] {
                t.push(s[i]);
            }
            else { cnt += 1; }
        }
        //debug!(t);
        if cnt == 0 { break; }
        ans += cnt;
        s = t;
    }

    println!("{}", ans);

}


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

impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}
fn can_remove(index: usize, phrase: Vec<char>) -> bool {
    let phrase_length = phrase.len();
    let (current, previous, next) = (
        phrase[index] as i32,
        if index == 0 {
            phrase[index] as i32
        } else {
            phrase[index - 1] as i32
        },
        if index == (phrase_length - 1) {
            phrase[index] as i32
        } else {
            phrase[index + 1] as i32
        },
    );
    (current as i32 - next as i32) == 1 || (current as i32 - previous as i32) == 1
}
fn try_remove<'a>(index: usize, phrase: Vec<char>) -> Vec<char> {
    let mut cloned = phrase.clone();
    let copied: &mut Vec<char> = cloned.as_mut();
    if can_remove(index, copied.to_vec()) {
        copied.remove(index);
    }
    copied.to_vec()
}
fn start_reduce_from(start: usize, phrase: Vec<char>) -> usize {
    let len = phrase.len();
    if start >= len {
        return len;
    }
    let removed = try_remove(start, phrase.clone());
    let mut reduced_len: usize = removed.len();
    if reduced_len < len {
        reduced_len = start_reduce_from(0, removed);
    }
    min(reduced_len, start_reduce_from(start + 1, phrase))
}

fn main() {
    let mut scan = Scanner::default();
    let length = scan.next::<usize>();
    let chars: Vec<char> = scan.next::<String>().chars().collect();
    let min_len = start_reduce_from(0, chars);
    println!("{}", length - min_len)
}


use std::io::stdin;

#[allow(unused_imports)]
use std::iter::FromIterator;
#[derive(Default)]
struct Scanner {
    buffer: Vec<String>,
}

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

fn _hash(vec: Vec<char>) -> String {
    vec.iter().map(|x| format!("{}", x)).collect::<String>()
}
fn can_remove(index: usize, phrase: Vec<(char, bool)>) -> bool {
    let current = phrase[index];
    if current.1 {
        return false;
    }
    let mut can_r = false;
    let mut step = 1;
    let phrase_length = phrase.len();
    let mut max_next = false;
    let mut max_previous = false;
    loop {
        if max_next && max_previous || can_r {
            return can_r;
        }
        let next = if index + step < phrase_length && (step == 1 || phrase[index + step - 1].1) {
            phrase[index + step].0 as i32
        } else {
            max_next = true;
            phrase[index].0 as i32
        };
        let previous = if index >= step && (step == 1 || phrase[index - step + 1].1) {
            phrase[index - step].0 as i32
        } else {
            max_previous = true;
            phrase[index].0 as i32
        };
        can_r = current.0 as i32 - next == 1 || current.0 as i32 - previous == 1;
        step += 1;
    }
}
fn try_remove(index: usize, phrase: &mut Vec<(char, bool)>) -> bool {
    if can_remove(index, phrase.to_vec()) {
        phrase[index] = (phrase[index].0, true);
        return true;
    }
    false
}

fn start_reduce_from(total_len: usize, start: usize, phrase: &mut Vec<(char, bool)>) -> usize {
    let len = phrase.len();
    if start >= len {
        return 0;
    }
    if try_remove(start, phrase) {
        start_reduce_from(total_len, 0, phrase)
    } else {
        start_reduce_from(total_len, start + 1, phrase)
    }
}
fn main() {
    let mut scan = Scanner::default();
    let total_len = scan.next::<usize>();
    let mut chars: Vec<(char, bool)> = scan.next::<String>().chars().map(|x| (x, false)).collect();
    let _ = start_reduce_from(total_len, 0, &mut chars);
    println!("{}", chars.iter().cloned().filter(|(_, y)| *y).count());
}


use std::io::stdin;
fn main() {
    let mut _text = String::new();
    stdin().read_line(&mut _text).unwrap();
    let commands = parse();
    let mut robot = Robot::new();
    let mut counter = 0;
    let mut results = vec!(0);
    for i in commands {
        robot.obey(i);
        counter +=1;
        if robot.x ==0 && robot.y ==0 {
           results.push(counter);
        }
    }
    println!("{}",results[results.len()-1])

}
enum Command {
    U,
    D,
    L,
    R,
}
struct Robot {
    x: usize,
    y: usize,
}
impl Robot {
    fn new() -> Robot {
        Robot { x: 0, y: 0 }
    }
    fn obey(&mut self, c: Command) {
        match c {
            Command::U => {
                self.y += 1;
            }
            Command::D => {
                self.y -= 1;
            }
            Command::L => {
                self.x -= 1;
            }
            Command::R => {
                self.x += 1;
            }
        };
    }
}

fn parse() -> Vec<Command> {
    let mut text = String::new();
    stdin().read_line(&mut text).unwrap();
    let fu = |e: char| -> Command {
        match e {
            'U' => Command::U,
            'D' => Command::D,
            'L' => Command::L,
            _ => Command::R,
        }
    };
    let text: Vec<Command> = text.trim().chars().map(fu).collect();
    text
}


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

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

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

use std::cmp::*;

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

fn main() {
    run();
}


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

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

fn resolve(hy: i64, ay: i64, dy: i64, hm: i64, am: i64, dm: i64) -> bool {
    let ay = std::cmp::max(0, ay - dm);
    let am = std::cmp::max(0, am - dy);
    if ay == 0 {
        return false;
    }
    if am == 0 {
        return true;
    }
    let yt = (hy - 1) / am + 1;
    let mt = (hm - 1) / ay + 1;
    yt > mt
}

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

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


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

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

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

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

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

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

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

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

fn main() {
    let (_n, _m): (usize, usize) = util::get2();
    let a: HashSet<usize> = util::gets().iter().cloned().collect();
    let b: HashSet<usize> = util::gets().iter().cloned().collect();

    for i in 1..99 {
        if i < 10 {
            if a.contains(&i) && b.contains(&i) {
                println!("{}", i);
                return;
            }
        } else {
            if a.contains(&(i / 10)) && b.contains(&(i % 10)) {
                println!("{}", i);
                return;
            }
        }
    }
}


use std::io::{self, BufReader, Stdin};
use std::io::prelude::*;
use std::collections::BTreeSet;
use std::iter::Map;
use std::str::SplitWhitespace;

fn main() {
    let mut reader = ReadIn::new();

    reader.read_line();
    let a: BTreeSet<i32> = reader.read_iter().collect();
    let b: BTreeSet<i32> = reader.read_iter().collect();
    let c: BTreeSet<i32> = a.intersection(&b).map(|&x| x).collect();
    let res = (if !c.is_empty() { c.iter().map(|&x| x).next() } else {
        a.iter().next().and_then(
            |ax| b.iter().next().map(
                |bx| ax * 10 + bx))
    }).unwrap();
    print!("{}", res);
}

struct ReadIn { reader: BufReader<Stdin>, buf: String }

impl ReadIn {
    fn new() -> ReadIn { ReadIn { reader: BufReader::new(io::stdin()), buf: String::new() } }
    fn read_i32(s: &str) -> i32 { s.parse().unwrap() }
    fn read_line(&mut self) {
        self.buf.clear();
        self.reader.read_line(&mut self.buf);
    }
    fn read_iter(&mut self) -> Map<SplitWhitespace, fn(&str) -> i32> {
        self.read_line();
        self.buf.split_whitespace().map(ReadIn::read_i32)
    }
    fn read_vec(&mut self) -> Vec<i32> {
        self.read_iter().collect()
    }
}


use rand::prelude::*;
use std::boxed::Box;
use std::cmp::*;
use std::io;
#[derive(Clone)]
struct Node<T: Ord + Clone> {
    pub key: T,
    pub weight: i64,
    pub left: Option<Box<Node<T>>>,
    pub right: Option<Box<Node<T>>>,
}

impl<T: Ord + Clone> Node<T> {
    fn new(value: T) -> Self {
        Node {
            key: value,
            weight: rand::random::<i64>(),
            left: None,
            right: None,
        }
    }

    pub fn split(
        node: Option<Box<Node<T>>>,
        key: &T,
    ) -> (Option<Box<Node<T>>>, Option<Box<Node<T>>>) {
        match node {
            None => (None, None),
            Some(mut node) => match node.key.cmp(key) {
                Ordering::Less => {
                    let (l, r) = Self::split(node.right, key);
                    node.right = l;
                    (Some(node), r)
                }
                _ => {
                    let (l, r) = Self::split(node.left, key);
                    node.left = r;
                    (l, Some(node))
                }
            },
        }
    }

    pub fn merge(left: Option<Box<Node<T>>>, right: Option<Box<Node<T>>>) -> Option<Box<Node<T>>> {
        match (left, right) {
            (None, None) => None,
            (left, None) => left,
            (None, right) => right,
            (Some(mut left), Some(mut right)) => match left.weight.cmp(&right.weight) {
                Ordering::Less => {
                    left.right = Self::merge(left.right, Some(right));
                    Some(left)
                }
                _ => {
                    right.left = Self::merge(Some(left), right.left);
                    Some(right)
                }
            },
        }
    }

    fn find(node: &Option<Box<Node<T>>>, key: &T) -> bool {
        match node {
            None => false,
            Some(node) => match node.key.cmp(key) {
                Ordering::Less => Self::find(&node.right, key),
                Ordering::Greater => Self::find(&node.left, key),
                Ordering::Equal => true,
            },
        }
    }

    fn less(node: &Box<Node<T>>) -> T {
        match node.left {
            None => node.key.clone(),
            Some(ref left) => Self::less(left),
        }
    }
}

struct Treap<T: Ord + Clone> {
    root: Option<Box<Node<T>>>,
}

impl<T: Ord + Clone + std::fmt::Display> Treap<T> {
    pub fn insert(&mut self, key: T) {
        let (mut l, r) = Node::split(self.root.take(), &key);
        l = Node::merge(l, Some(Box::new(Node::new(key))));
        self.root = Node::merge(l, r);
    }

    pub fn delete(&mut self, key: &T) {
        let (l, mut r) = Node::split(self.root.take(), key);
        r = match r {
            None => None,
            Some(node) => {
                if &node.key == key {
                    Node::merge(node.left, node.right)
                } else {
                    Some(node)
                }
            }
        };
        self.root = Node::merge(l, r);
    }

    pub fn find(&self, key: &T) -> bool {
        Node::find(&self.root, key)
    }

    pub fn less(&self) -> Option<T> {
        match self.root {
            Some(ref root) => Some(Node::less(root)),
            _ => None,
        }
    }

    pub fn new() -> Self {
        Treap { root: None }
    }
}

fn main() {
    let mut buffer = String::new();
    io::stdin().read_line(&mut buffer);
    buffer = String::new();
    io::stdin().read_line(&mut buffer);
    buffer.retain(|s| s != '\r' && s != '\n');
    let a: Vec<u64> = buffer
        .split_whitespace()
        .map(|n| n.parse::<u64>().unwrap())
        .collect();

    buffer = String::new();
    io::stdin().read_line(&mut buffer);
    buffer.retain(|s| s != '\r' && s != '\n');
    let b: Vec<u64> = buffer
        .split_whitespace()
        .map(|n| n.parse::<u64>().unwrap())
        .collect();

    let mut t1 = Treap::new();
    let mut t2 = Treap::new();
    //println!("{:?} | {:?}", &a, &b);
    for n in a {
        t1.insert(n);
    }
    for n in b {
        t2.insert(n);
    }
    let (m1, m2) = (t1.less().unwrap(), t2.less().unwrap());

    match m1.cmp(&m2) {
        Ordering::Less => println!("{}{}", m1, m2),
        Ordering::Greater => println!("{}{}", m2, m1),
        Ordering::Equal => println!("{}", m2),
    }
}


use std::io::stdin;

// M => choose EVEN and choose FIRST
// E => odd

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

    let number: u32 = buffer.trim().parse().expect("Error in parsing");

    if number % 2 == 0 {
        println!("Mahmoud");
    } else {
        println!("Ehad");
    }
}


use std::io;

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

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

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


use std::io;

fn main() {
	let mut n = String::new();
	io::stdin().read_line(&mut n).expect("Time to panic");
	let n: u64 = n.parse().unwrap();
	if n % 2 == 0 {
		println!("Ehab");
	} else {
		println!("Mahmoud")
	}
}


use std::io;

fn main() {
	let mut n = String::new();
	io::stdin().read_line(&mut n).expect("Time to panic");
	let n: u64 = n.trim().parse().unwrap();
	if n % 2 == 0 {
		println!("Ehab");
	} else {
		println!("Mahmoud")
	}
}


use std::io;

fn main() {
    let mut input = String::new();
    match io::stdin().read_line(&mut input) {
            Ok(_) => {
                let number = input.trim().parse::<i32>().unwrap();
                if number % 2 == 0 {
                    println!("yes");
                }
                else {
                    println!("no");
                }
                                    }
                Err(error) => println!("error: {}", error),
    }
}


use std::io::stdin;

fn main() {
    let mut buffer = String::new();
    stdin().read_line(&mut buffer).expect("Cannot read line");
    let i = buffer.trim().parse::<u32>().expect("Cannot parse");

    if i % 2 == 0 {
        println!("YES");
    } else {
        println!("NO");
    }
}


use std::io::stdin;

fn main() {
    let mut buffer = String::new();
    stdin().read_line(&mut buffer).expect("Cannot read line");
    let i = buffer.trim().parse::<u32>().expect("Cannot parse");

    if i % 2 == 0 && n / 2 > 1 {
        println!("YES");
    } else {
        println!("NO");
    }
}


use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    let times = input.trim().parse::<i32>().unwrap();
    if times < 4 && times % 2 == 1 {
        println!("NO");
    } else {
        println!("YES");
    }
}


fn main() {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).expect("Failed");
    let x = buffer.trim().parse::<i64>().unwrap();
    if x % 2 == 0 {
        println!("YES")
    } else {
        println!("NO")
    }
}


use std::io::{self};

fn main() -> io::Result<()> {
    while true{
        let mut user_input = String::new();
        io::stdin().read_line(&mut user_input)?;
        let weight: u32 = user_input.trim_end().parse::<u32>().unwrap();

        let mut found: bool = false;
        for first_half in (2..weight).step_by(2) {
            let second_half = weight - first_half;
            if second_half % 2 == 0 {
                found = true;
                break;
            }
        }

        if found {
            println!("YES")
        }else{
            println!("NO")
        }
    }

    Ok(())
}


use std::collections::HashSet;

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

    let v = vec![2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89, 97];
    let primes:HashSet<_> = v.iter().collect();

    for i in v.iter() {
        if *i >= n {
            println!("NO");
            break;
        }
        if primes.contains(&(n - *i)) {
            println!("YES");
            break
        }
    }
 }


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

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines();
    let n: u32 = lines.next().unwrap().unwrap().trim().parse().unwrap();

    if n % 2 == 0 {
        println!("YES");
    } else {
        println!("NO");
    }

}


//use std::str::FromStr;

#[cfg(test)]
mod tests {
    use crate::quest;

    #[test]
    fn test1() {
            assert_eq!(quest(2,2,1,1),2)
    }
    #[test]
    fn test2() {
        assert_eq!(quest(4,4,2,1),3)
    }
    #[test]
    fn test3() {
        assert_eq!(quest(6,10,4,2),6)
    }

}
/*
#[inline]
pub fn input_in_four_var<T: FromStr>() -> (T, T, T, T)
where T: Copy,
{
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    let numbers: Vec<T> = line.split_whitespace().filter_map(
        |s| s.parse().ok()
    )
        .collect();
    (*numbers.get(0).unwrap(),*numbers.get(1).unwrap(),*numbers.get(2).unwrap(),*numbers.get(3).unwrap() )

}
*/

fn main()  {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    let v: i32 =match line.trim().parse() {
        Ok(t) => t,
        Err(_e) => panic!()
    };
    if v%2 ==0{
        return println!("YES")
    }
    println!("NO")

}


use std::io;

fn main() {

    let mut x = String::new();

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

    let x: i32 = x.trim().parse().expect("error");

    if x <= 1 && x <= 100 {
        let res = x % 2;

        if res == 0 && x != 2 {
            println!("YES");
        } else {
            println!("NO");
        }
    }

}


use std::io;

fn main() {

    let mut x = String::new();

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

    let x: u8 = x.trim().parse().expect("error");

    if (res >= 1 | res <= 100) {
        let res = x % 2;

        if (res == 0) {
            println!("YES");
        }
    }

}


use std::io;

fn main() {
  let mut weight = String::new();
  io::stdin().read_line(&mut weight).unwrap();
  let weight: u32 = weight.trim().parse().unwrap();
  match weight % 2 {
    0 => println!("YES"),
    _ => println!("NO"),
  }
}


fn main() {

    let mut input = String::new();
    let stdin = std::io::stdin();
    stdin.read_line(&mut input).expect("Failed to read line!");

    let weight = input.trim().parse::<u32>().unwrap();
    if weight % 2 == 0 {
        println!("YES");
    } else {
        println!("NO");
    }
}


use std::io;

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

    io::stdin().read_line(&mut s);
    let s: u8 = s.parse().unwrap();
    println!("{}", if s % 2 == 0 { "YES" } else { "NO" });
}


use std::io;

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

    io::stdin().read_line(&mut s);
    let s: u8 = s.trim().parse().unwrap();
    println!("{}", if s % 2 == 0 { "YES" } else { "NO" });
}


use std::io;

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

    io::stdin().read_line(&mut guess)
        .expect("Не удалось прочитать строку");
    //

    let part: i32 = guess.trim().parse()
        .expect("Пожалуйста, введите число!");

    if part % 2 == 0 {
        println!("YES");
    }
    else{
        println!("No");
    }

}


macro_rules! read_line {
    ($v:ident) => {
        let mut temp = String::new();
        std::io::stdin().read_line(&mut temp).unwrap();
        let $v = temp;
    };
    (var, $t:ty, $($v:ident), *) => {
        read_line!(input_line);
        let mut iter = parse_token!($t, input_line);
        $(
            let $v = iter.next().unwrap();
        )*
    };
    (vec, $t:ty, $v:ident) => {
        read_line!(input_line);
        let iter = parse_token!($t, input_line);
        let $v: Vec<$t> = iter.collect();
    };
    ($($v:ident; $t:ty), *) => {
        read_line!(input_line);
        let mut iter = input_line.split_whitespace();
        $(
            let $v: $t = iter.next().unwrap().parse().unwrap();
        )*
    };
}

macro_rules! parse_token {
    ($t:ty, $e:expr) => {
        $e.split_whitespace().map(|x| x.parse::<$t>().unwrap());
    };
}

fn main() {
    read_line!(w;u64);
    match w % 2 {
        0 => println!("YES"),
        1 => println!("NO"),
        _ => unreachable!()
    };
}


fn main() {
    let mut input = String::new();
    std::io::stdin()
        .read_line(&mut input)
        .ok()
        .expect("Couldn't read line");
    // let weigh: int = input.trim().to_string();
    let weigh: i32 = input.trim().to_string().parse::<i32>().unwrap();

    if weigh % 2 == 0 {
        println!("YES");
    } else {
        println!("NO");
    }
}


use std::io;

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

    if w > 3 && w % 2 == 0 && (w >> 1) % 2 == 0 {
        println!("YES");
    } else {
        println!("NO");
    }
}


use std::env;

fn main() {
    let weight = env::args().skip(1).map(|string| string.parse::<usize>().unwrap()).collect::<Vec<usize>>()[0];

    if weight % 2 == 0 {
        println!("YES")
    } else {
        println!("NO")
    }
}


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

fn main() {
    let mut scan = Scanner::default();

    let weight = scan.next::<usize>();

    if weight % 2 == 0 {
        print!("YES")
    } else {
        print!("NO")
    }

}


use std::io;

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

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

    if s % 2 == 0 {
        println!("YES");
    } else {
        println!("NO");
    }
}


use std::io;

fn main() {
    let mut inp = String::new();
    io::stdin().read_line(&mut inp).expect("Problem.");
    let w: u16 = inp.trim().parse().expect("A number please.");
    match w % 2 {
        0 => println!("YES"),
        _ => println!("NO"),
    };
}


use std::io;
fn main(){
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    let num: u32 = input.trim().parse().unwrap();
    if num % 2 == 0{
        println!("YES");
    }else{
        println!("NO");
    }
}


fn main() {
    let mut input = String::from("");
    std::io::stdin().read_line(&mut input).expect("Failed readline!");
    let mut input = input.trim().parse::<i32>().unwrap();

    if input % 2 == 0 {
        println!("YES");
    } else {
        println!("NO");
    }
}


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

  if n % 4 == 0 {
    println!("YES");
  } else {
    println!("NO");
  }
}

/* vim: set ts=2 sts=2 sw=2 et: */


fn main()
{
    let mut input = String::new();
    std::io::stdin()
        .read_line(&mut input)
        .expect("Bleh.");
    input = input.trim().to_string();
    let number : i32 = input.parse().unwrap();

    if (number % 2 == 0) && (number != 2)
    {
        println!("YES\n");
    }
    else
    {
        println!("NO\n");
    }


fn main()
{
    let mut input = String::new();
    std::io::stdin()
        .read_line(&mut input)
        .expect("Bleh.");
    let number : i32 = input.parse().unwrap();

    if (number % 2 == 0) && (number != 2)
    {
        println!("YES\n");
    }
    else
    {
        println!("NO\n");
    }
}


fn main () {
        // read
        let mut s = String::new();
        io::stdin().read_line(&mut s);

        let int_vec: Vec<u32> =s.trim()
                .split(" ")
                .map(|x|{
                        x.parse::<u32>().expect("not an integer")
                        })
                .collect();

        let mut a :u32 = int_vec[0];

        if a%2==0{
                println!("YES");
        }else{
                println!("NO");
        }

}


use std::io;
fn main () {
        // read
        let mut s = String::new();
        io::stdin().read_line(&mut s);

        let int_vec: Vec<u32> =s.trim()
                .split(" ")
                .map(|x|{
                        x.parse::<u32>().expect("not an integer")
                        })
                .collect();

        let mut a :u32 = int_vec[0];

        if a%2==0 && a!=0{
                println!("YES");
        }else{
                println!("NO");
        }

}


#![feature(asm)]
fn main() {
    let n: i32 = std::io::stdin()
    .lock()
    .lines()
    .next()
    .expect("stdin should be available")
    .expect("couldn't read from stdin")
    .trim()
    .parse()
    .expect("input was not an integer");
    println!(if (n > 2 && n % 2 == 0) {
        "YES"
    } else {
        "NO"
    });
}


use std::io;
fn int_input() -> i32{
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    let n: i32 = input.trim().parse().unwrap();
    n
}
fn main(){
    let n=int_input();
    if n%2==0{
        println!("YES");
    }else{
        println!("NO");
    }
}


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

use std::cmp;

#[allow(unused_must_use)]
fn run<B: BufRead, W: Write>(mut reader: Scanner<B>, mut writer: W) {
    let total_number_of_trips: i32 = reader.next();
    let number_of_trips_with_special_ticket: i32 = reader.next();
    let one_trip_price: i32 = reader.next();
    let special_ticket_price: i32 = reader.next();

    let number_of_special_tickets_bought: i32 = total_number_of_trips / number_of_trips_with_special_ticket;
    let mut total_cost: i32 = number_of_special_tickets_bought * special_ticket_price;
    let remaining_trips_needed: i32 = total_number_of_trips % number_of_trips_with_special_ticket;
    if remaining_trips_needed > 0 {
        total_cost += cmp::min(remaining_trips_needed * one_trip_price, special_ticket_price);
    }

    writeln!(writer, "{}", total_cost);
}

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

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

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

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

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

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

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

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

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


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

fn main() {
    let (n, m, a, b) = {
        let temp = input_split();
        (temp[0], temp[1], temp[2], temp[3])
    };

    if m * a > b {
        println!("{}", (n / m) * b + b.min((n % m) * a));
    } else {
        println!("{}", n * a);
    }
}


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

fn main() {
    let (n, m, a, b) = {
        let temp = input_split();
        (temp[0], temp[1], temp[2], temp[3])
    };

    if m * a > b {
        println!("{}", (n / m) * b + b.min((n % m) * a));
    } else {
        println!("{}", n * a);
    }
}


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

    if b / m >= a {
        println!("{:?}", a * n);
    } else {
        println!("{:?}", (n as f32 / m as f32).ceil() as i32 * b);
    }
}


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

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

  let x: Vec<i32> = s.trim()
    .split_whitespace()
    .map(|x| x.parse().unwrap())
    .collect();

  let n = x[0];
  let m = x[1];
  let a = x[2];
  let b = x[3];

  if m * a <= b {
    println!("{}", a*n);
  } else {
    if m > n {
      println!("{}", min(b, a*n));
    } else {
      println!("{}", b*(n/m)+a*(n%m));
    }
  }
}


// https://codeforces.com/problemset/problem/466/A
use std::io;

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

    io::stdin()
        .read_line(&mut line)
        .unwrap();

    let words: Vec<f64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    let n = words[0];
    let m = words[1];
    let a = words[2];
    let b = words[3];

    let sale: f64 = b/m;

    if sale < a {
        println!("{}", (n/m).floor()*b + (n%m)*a);
    } else {
        println!("{}", n*a);
    }
}


#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::BTreeSet;
#[allow(unused_imports)]
use std::collections::HashSet;
use std::fs::File;
use std::io::Read;
#[allow(unused_imports)]
use std::mem;
use std::fmt::Display;

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

#[allow(dead_code)]
fn comb(n: usize, k: usize, m: i64, frac: &[i64], frac_inv: &[i64]) -> i64 {
    let mut ret = 1i64;
    if n < k {
        return 0;
    }
    ret *= frac[n] * frac_inv[n - k];
    ret %= m;
    ret *= frac_inv[k];
    ret %= m;
    ret
}

#[allow(dead_code)]
fn show1dvec<T : Display>(v : &Vec<T>) {
    let n = v.len();
    for i in 0..n - 1 {
        print!("{} " , v[i]);
    }
    println!("{} " , v[n - 1]);
}

#[derive(Debug)]
struct Piece {
    mark: char,
    y: i32,
    x: i32,
}

fn main() {
    let inputstatus = 1;

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

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

    let mut iter = buf.split_whitespace();

    let n: i32 = iter.next().unwrap().parse().unwrap();
    let m: i32 = iter.next().unwrap().parse().unwrap();
    let a: i32 = iter.next().unwrap().parse().unwrap();
    let b: i32 = iter.next().unwrap().parse().unwrap();

    println!("{}", cmp::min(n * a, (n % m) * a + (n / m) * b));

    // let n = iter.next().unwrap().parse().unwrap();

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


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: isize = scan.next();
    let m: isize = scan.next();
    let a: isize = scan.next();
    let b: isize = scan.next();
    if a*m <= b {
        println!("{}", a*n);
    } else {
        let mut result = (n/m)*b;
        if b <= a*(n%m) { result += 1; }
        else {            result += (n%m)*a; }
        println!("{}", result);
    }
}

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


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

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

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

fn read_ts<T : FromStr>(stdin : &Stdin, ts : &mut Vec<T>) {
    let mut line = String::new();
    read_line(stdin, &mut line);
    let word_iter = line.split_whitespace();
    for word in word_iter {
        let x = parse_t(word);
        ts.push(x);
    }
}

fn main() {
    let stdin = io::stdin();
    let mut n_m_a_b : Vec<usize> = vec![];
    read_ts(&stdin, &mut n_m_a_b);
    let n = n_m_a_b[0];
    let m = n_m_a_b[1];
    let a = n_m_a_b[2];
    let b = n_m_a_b[3];
    let cost_1 = n * a;
    let cost_2 = ((n / m) * b) + ((n % m) * a);
    let min_cost = min(cost_1, cost_2);
    println!("{}", min_cost);
}


// use rand::Rng;

use std::collections::*;
use std::io;

fn trim_newline(s: &mut String) {
    if s.ends_with('\n') {
        s.pop();
        if s.ends_with('\r') {
            s.pop();
        }
    }
}
macro_rules! parse_input {
    ($t:ident) => {{
        let mut input_line = String::new();
        io::stdin().read_line(&mut input_line).unwrap();
        trim_newline(&mut input_line);
        input_line.parse::<$t>().unwrap()
    }};
}

macro_rules! split_input {
    ($t:ident) => {{
        parse_input!(String)
            .split(" ")
            .map(|z| z.parse::<$t>().unwrap())
            .collect::<Vec<$t>>()
    }};
}

fn main() {
    let a = split_input!(u64);
    let n = a[0];
    let single = a[2];
    let group = a[3];
    let group_count = a[1];

    if (single * group_count) <= group {
        println!("{}", single * n);
    } else {
        println!("{}", n / group_count * group + (n % group_count) * single);
    }
}


use std::io::stdin;

fn read_line() -> String {
    let mut input = String::new();
    stdin().read_line(&mut input).expect("Failed to read line!");
    input
}

fn main() {
    let input1 = read_line();
    let line1: Vec<&str> = input1.split(" ").collect();
    let n = line1[0].trim().parse::<i32>().unwrap();
    let m = line1[1].trim().parse::<i32>().unwrap();
    let a = line1[2].trim().parse::<i32>().unwrap();
    let b = line1[3].trim().parse::<i32>().unwrap();

    let costs: i32;
    if b <= a {
        costs = f32::ceil(n as f32 / m as f32) as i32 * b;
    } else if b / m < a {
        if m > n {
            if n * a > m * b {
                costs = m * b;
            } else {
                costs = n * a;
            }
        } else {
            costs = (n % m) * a + f32::floor(n as f32 / m as f32) as i32 * b
        }
    } else {
        costs = n * a;
    }
    println!("{}", costs);
}


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

fn solve() {
    let n: i64 = get();
    let x: i64 = get();
    println!("{}", (x - (n % 3) + 3) % 3);
}

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


//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();
    f = std::cmp::max(5 * 60, f);
    let start = (f + a.0 - 1) / a.0 * a.0;
    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;

fn main() {
  let mut ni = String::new();
  io::stdin().read_line(&mut ni).unwrap();
  let mut si = String::new();
  io::stdin().read_line(&mut si).unwrap();
  let sf = si.trim().matches("SF").collect::<Vec<&str>>().len();
  let fs = si.trim().matches("SF").collect::<Vec<&str>>().len();
  if sf > fs {
    println!("YES")
  } else {
    println!("NO")
  }
}


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

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

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

fn run() {
    input! {
        n: usize,
        l: u64,
    }
    let mut binom = vec![vec![0u64; n + 1]; n + 1];
    binom[0][0] = 1;
    for i in 1..=n {
        binom[i][0] = 1;
        for j in 1..=i {
            binom[i][j] = binom[i - 1][j - 1] + binom[i - 1][j];
        }
    }
    let mut fact = vec![1u64; n + 1];
    for i in 1..=n {
        fact[i] = (i as u64).saturating_mul(fact[i - 1]);
    }
    let calc = |n: usize, k: usize| -> u64 {
        assert!(1 <= k && k <= n);
        let n = n - k;
        let mut dp = vec![1u64; n + 1];
        for i in 2..=n {
            let mut way = 0u64;
            for j in 1..=i {
                way = way.saturating_add(dp[i - j]);
            }
            dp[i] = way;
        }
        dp[n]
    };
    let mut set = std::collections::BTreeSet::new();
    for i in 1..=n {
        set.insert(i);
    }
    let mut l = l - 1;
    let mut ans = vec![];
    for i in (1..=n).rev() {
        let mut del = 0;
        for (j, &v) in set.iter().enumerate() {
            let way = calc(i, j + 1);
            if way > l {
                del = v;
                break;
            } else {
                l -= way;
            }
        }
        set.remove(&del);
        ans.push(del);
    }
    for (i, a) in ans.iter().enumerate() {
        if i > 0 {
            print!(" ");
        }
        print!("{}", *a);
    }
    println!();
}

fn main() {
    run();
}


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

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

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

fn main() {
    type Element = f64;
    let input = buf_read().unwrap();
    let mut input_vectors: Vec<Vec<Element>> = vec![];
    for input_line in input {
        let input_str: Vec<String> = input_line.split(' ').map(String::from).collect();
        let mut input_vector: Vec<Element> = vec![];
        for input_elem_str in input_str {
            let elem: Element = Element::from_str(input_elem_str.as_str()).unwrap();
            input_vector.push(elem);
        }
        input_vectors.push(input_vector);
    }
    let two: f64 = 2.0;
    // println!("{:?}", two.log(input_vectors[0][0]));
    println!("{:?}", input_vectors[0][0].log(two).ceil() as i64);
}


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

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

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

fn main() {
    type Element = i64;
    let input = buf_read().unwrap();
    let mut input_vectors: Vec<Vec<Element>> = vec![];
    for input_line in input {
        let input_str: Vec<String> = input_line.split(' ').map(String::from).collect();
        let mut input_vector: Vec<Element> = vec![];
        for input_elem_str in input_str {
            let elem: Element = Element::from_str(input_elem_str.as_str()).unwrap();
            input_vector.push(elem);
        }
        input_vectors.push(input_vector);
    }
    // let two: f64 = 2.0;
    // println!("{:?}", two.log(input_vectors[0][0]));
    //
    // println!("{:?}", input_vectors[0][0].log(two).ceil() as i64);
    // for n in 0..f64::INFINITY {
    let mut n = 0;
    loop {
        if fib(n) > input_vectors[0][0] {
            println!("{}", n - 1);
            break;
        }
        n += 1;
    }
}

fn fib(e: i64) -> i64 {
    if e == 0 {
        return 1;
    } else if (e == 1) {
        return 2;
    }
    return fib(e - 1) + fib(e - 2);
}


use std::io::{self, Stdin};
use std::str::{self, FromStr};
use std::error::Error;
use std::thread;

fn exec() {
    let mut sc = Scanner::new();
    let n: i64 = sc.ne();
    let mut cur = 1i64;
    let mut cnt = 0;
    while cur < n {
        cur *= 2;
        cnt += 1;
    }
    println!("{}", cnt);
}
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()
    }
}


use std::collections::BTreeSet;
fn main() {
    let mut ri = ReadIn::new();
    let tp = ri.int2();
    let n = tp.0 as usize;
    let m = tp.1;
    let mut it = ri.ints();
    let mut num = Vec::new();
    for _ in 0..n {
        num.push(it.next().unwrap());
    }
    if n == 1 {
        println!("{}", num[0]);
        return ;
    }
    let fst = num[0..n/2].to_vec();
    let snd = num[n/2..n].to_vec();
    let s1 = explore(fst,m);
    let s2 = explore(snd,m);
    let mut it3 = s1.iter();
    let mut it4 = s2.iter();
    let mut ans = (it3.next_back().unwrap() + it4.next_back().unwrap()) % m;
    let mut it1 = s1.iter();
    let mut it2 = s2.iter();
    loop {
        match it1.next() {
            Some(v1) => {
                loop {
                    match it2.next_back() {
                        Some(v2) => {
                            if v1 + v2 < m {
                                if (v1 + v2) > ans {
                                    ans = v1 + v2;
                                }
                                break;
                            }
                        },
                        None => break,
                    }
                }
            },
            None => break,
        }
    }
    println!("{}", ans);
}

fn explore(v:Vec<i32>, m:i32) -> BTreeSet<i32> {
    let n = v.len();
    let mut st = BTreeSet::new();
    for msk in 0..1<<n {
        let mut s = 0;
        for i in 0..n {
            if (msk & (1<<i)) > 0 {
                s = (s + v[i]) % m;
            }
        }
        st.insert(s);
    }
    st
}

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

const MODULO: u128 = 1000000007;

fn delta_greater(a: usize, b: usize, c: usize) -> bool {
    if a > b {
        return (a - b) > c;
    } else {
        return (b - a) > c;
    }
}

fn sqrt_int(x: usize) -> usize {
    if x == 0 {
        return 0;
    }
    let mut value: usize = x + 2;
    let mut value1: usize = x;
    while delta_greater(value, value1, 1) {
        value = value1;
        value1 = (value + (x / value)) / 2;
    }
    value1 = (value1 + (x / value1)) / 2;
    return value1;
}

fn get_power_value(base: u128, power: u128) -> u128 {
    let mut value: u128 = 1;
    let mut z: u128 = base;
    let mut power_of_2: u128 = 1;
    let mut power_tmp: u128 = power;
    for _ in 0..127 {
        if (power_tmp & 1) != 0 {
            value *= z;
            value %= MODULO;
        }

        z *= z;
        z %= MODULO;

        power_of_2 <<= 1;
        power_tmp >>= 1;
        if power_of_2 > power {
            break;
        }
    }
    return value;
}

fn get_prime_divider_power(value: u128, divider: u128) -> u128 {
    let mut power: u128 = 0;
    let mut divider_tmp: u128 = divider;
    while divider_tmp <= value {
        power += value / divider_tmp;
        divider_tmp *= divider;
    }
    return power;
}

fn func_g1_mod(n: u128, p: u128) -> u128 {
    let power: u128 = get_prime_divider_power(n, p);
    return get_power_value(p, power);
}

fn func_f1_mod(x: usize, n: u128) -> u128 {
    let x_sqrt: usize = sqrt_int(x) + 1;
    let mut primes: Vec<bool> = Vec::with_capacity(x_sqrt);
    for _ in 0..x_sqrt {
        primes.push(true);
    }
    {
        let mut i: usize = 2;
        while (i * i) < x_sqrt {
            if primes[i] {
                let mut j: usize = i * i;
                while j < x_sqrt {
                    primes[j] = false;
                    j += i;
                }
            }
            i += 1;
        }
    }

    let mut value: u128 = 1;

    let mut x_dividers_found: bool = false;
    for i in 2..x_sqrt {
        if (i as u128) > n {
            break;
        }
        if (x % i) != 0 {
            continue;
        }
        x_dividers_found = true;
        if primes[i] {
            value *= func_g1_mod(n, i as u128);
            value %= MODULO;
        }
    }
    if !x_dividers_found {
        value *= func_g1_mod(n, x as u128);
        value %= MODULO;
    }

    return value;
}

#[cfg(test)]
mod tests {
    use super::{func_f1_mod, get_power_value, sqrt_int};

    #[test]
    fn test_a1() {
        assert_eq!(sqrt_int(0), 0);
        assert_eq!(sqrt_int(1), 1);
        assert_eq!(sqrt_int(2), 1);
        assert_eq!(sqrt_int(3), 1);
        assert_eq!(sqrt_int(4), 2);
        assert_eq!(sqrt_int(5), 2);
        assert_eq!(sqrt_int(6), 2);
        assert_eq!(sqrt_int(7), 2);
        assert_eq!(sqrt_int(8), 2);
        assert_eq!(sqrt_int(9), 3);
        assert_eq!(sqrt_int(10), 3);
    }

    #[test]
    fn test_b1() {
        assert_eq!(get_power_value(0, 1), 0);
        assert_eq!(get_power_value(0, 2), 0);
        assert_eq!(get_power_value(0, 3), 0);
        assert_eq!(get_power_value(1, 0), 1);
        assert_eq!(get_power_value(1, 1), 1);
        assert_eq!(get_power_value(1, 2), 1);
        assert_eq!(get_power_value(1, 3), 1);
        assert_eq!(get_power_value(2, 0), 1);
        assert_eq!(get_power_value(2, 1), 2);
        assert_eq!(get_power_value(2, 2), 4);
        assert_eq!(get_power_value(2, 3), 8);
        assert_eq!(get_power_value(3, 0), 1);
        assert_eq!(get_power_value(3, 1), 3);
        assert_eq!(get_power_value(3, 2), 9);
        assert_eq!(get_power_value(3, 3), 27);
    }

    #[test]
    fn test_c1() {
        assert_eq!(func_f1_mod(10, 2), 2);
    }
    #[test]
    fn test_c4() {
        assert_eq!(func_f1_mod(20190929, 1605), 363165664);
    }
    #[test]
    fn test_c5() {
        assert_eq!(func_f1_mod(947, 987654321987654321), 593574252);
    }
}

fn read_usize_u128_pair(stdin_lock: &mut std::io::StdinLock) -> (usize, u128) {
    let mut line1: String = String::new();
    stdin_lock.read_line(&mut line1).unwrap();
    let mut line1_values = line1.trim().split(" ");
    let value1: usize = line1_values.next().unwrap().parse::<usize>().unwrap();
    let value2: u128 = line1_values.next().unwrap().parse::<u128>().unwrap();
    return (value1, value2);
}

fn main() {
    let stdin: std::io::Stdin = std::io::stdin();
    let mut stdin_lock: std::io::StdinLock = stdin.lock();

    let (x, n): (usize, u128) = read_usize_u128_pair(&mut stdin_lock);

    let func_value: u128 = func_f1_mod(x, n);

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


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

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

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

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

    let r: f64 = input.p();
    let x: f64 = input.p();
    let y: f64 = input.p();
    let xx: f64 = input.p();
    let yy: f64 = input.p();
    println!("{}", (((x - xx).powi(2) + (y - yy).powi(2)).sqrt() / (2. * r) - 1e-6).ceil());
}


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

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

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

//

fn run() {
    input! {
        n: u64,
    }
    let ans = n.next_power_of_two().trailing_zeros();
    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, bytes) => {
        read_value!($iter, String).bytes().collect::<Vec<u8>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut a = a;
    a.sort();
    let mut ans = "NO";
    for i in 2..n {
        let s = a[i - 2];
        if a[(i - 2)..=i] == [s, s + 1, s + 2] {
            ans = "YES";
        }
    }
    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, bytes) => {
        read_value!($iter, String).bytes().collect::<Vec<u8>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut a = a;
    a.sort();
    a.dedup();
    let mut ans = "NO";
    for i in 2..n {
        let s = a[i - 2];
        if a[(i - 2)..=i] == [s, s + 1, s + 2] {
            ans = "YES";
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


use std::io;

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

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

fn main() {
    let n: i32 = read_line().parse().unwrap();
    let mut vs = read_line_vec();

    vs.sort();

    for i in 2..vs.len() {
        let pprev = vs[i-2];
        let prev = vs[i-1];
        let me = vs[i];

        if me == prev + 1 && pprev + 1 == prev {
            println!("YES");
            return;
        }
    }

    println!("NO");

}


use std::io;

fn run(s: String){
    let mut arr: [usize;10] = [0;10];

    for c in s.chars(){
        let mut x=(c.to_string()).parse::<usize>().unwrap();
        if x%2==0 && x!=2{
            arr[2]+=x/2;
            x-=1;
        }
        arr[x]+=1;
    }
    for i in (2..10).rev(){
        for _j in 0..arr[i]{
            print!("{}",i);
        }
    }
}
fn main()
{
    let mut s1=String::new();
    let mut s2=String::new();
    io::stdin().read_line(&mut s1).expect("read error");
    io::stdin().read_line(&mut s2).expect("read error");

    run(s2.trim().to_string());
}


use std::io;

fn run(s: String){
    let mut arr: [usize;10] = [0;10];

    for c in s.chars(){
        let mut x=(c.to_string()).parse::<usize>().unwrap();
        if x==4 || x==8 || x==6{
            if x==4{
                arr[2]+=2;
            }
            else if x==8{
                arr[2]+=3;
            }
            else{
                arr[3]+=1;
            }
            x-=1;
        }
        arr[x]+=1;
    }
    for i in (2..10).rev(){
        for _j in 0..arr[i]{
            print!("{}",i);
        }
    }
}
fn main()
{
    let mut s1=String::new();
    let mut s2=String::new();
    io::stdin().read_line(&mut s1).expect("read error");
    io::stdin().read_line(&mut s2).expect("read error");

    run(s2.trim().to_string());
}


use std::io::stdin;

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

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

    let mut a: Vec<char> = a
        .chars()
        .filter(|x| x != &'0' && x != &'1')
        .collect();

    let mut c = String::new();

    for i in a {
        if i == '4' {
            c.push_str("223");
        } else if i == '6' {
            c.push_str("53");
        } else if i == '8' {
            c.push_str("72222");
        } else if i == '9' {
            c.push_str("2337");
        } else {
            c.push(i);
        }
    }

    let mut c: Vec<u32> = c.chars().map(|x| x.to_digit(10 as u32).unwrap()).collect();

    c.sort();
    c.reverse();

    for i in c {
        print!("{}", i);
    }
    println!();
}


use std::io;

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

    io::stdin().read_line(&mut buffer)
        .expect("Failed to read from stdin");

    match buffer.trim().parse::<u32>() {
        Ok(i) if(i % 2 == 0) => println!("YES"),
        Ok(i) => println!("NO"),
        _ => println!("Invalid integer"),
    }
}


#![allow(unused)]

use std::io::prelude::*;
use std::ops::Div;
use std::{env, io};

fn main() {
    let arg: u8 = io::BufReader::new(io::stdin())
        .lines()
        .next()
        .unwrap()
        .unwrap()
        .parse()
        .unwrap();
    if arg.div(2).trailing_zeros() == 0 {
        println!("NO");
    } else {
        println!("YES");
    }
}


use std::io;

fn main() {
    let mut weight = String::new();
    io::stdin()
        .read_line(&mut weight)
        .except("Failed");
    let weight: u32 = weight.trim().parse().except("No Number");
    if (weight % 2 ==0){
        println!("YES");
        } else {
        println!("NO");
    }
}


use std::io;
fn main() {
    let mut weight = String::new();
    io::stdin().read_line(&mut weight).expect("Failure");
    let weight : u32 = weight.trim().parse().expect("No Number");
    if (weight%2==0 && weight>=2) {
        println!("YES")
    } else{
        println!("NO")
    }
}


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

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let n : u32 = s.trim().parse();
    if n % 2 == 0 {
        println!("YES");
    }
    else {
        println!("NO");
    }
}


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

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let n : u32 = s.trim().parse().unwrap();
    if n % 2 == 0 {
        println!("YES");
    }
    else {
        println!("NO");
    }
}


fn main() {

    use scan::Scan;
    let mut scanner = scan::from_stdin();
    let n = scanner.next::<i32>();
    if (n % 2 == 0){
        println!("YES");
    }
    else {
        println!("NO");
    }
}


use std::io;

fn main() {

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

    if n % 2 == 0 && n >= 2 {
        println!("YES");
    }
    else {
        println!("NO");
    }
}


use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    let n = input.trim().parse::<u32>().unwrap();
    if n % 2 == 0 {
        println!("YES");
    } else {
        println!("NO");
    }
}


use std::io;

fn main() {
	let mut inp = String::new();
	io::stdin().read_line(&mut inp).expect("error while reading input");
	let mut inp: i32 = inp.trim().parse().unwrap();
	if (inp - 2) % 2 == 0 {
		println!("YES");
	} else {
		println!("NO");
	}
}


use std::io::{ stdin };

fn main() {
    let mut input_string = String::new();
    stdin().read_line(&mut input_string).expect("");
    let input_number: i32 = input_string.trim().parse().unwrap();
    println!("{}", if (input_number % 2) == 0 {"YES"} else {"NO"});
}


use std::io;

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

    io::stdin().read_line(&mut input).unwrap();
    let num: i8 = input.trim().parse().unwrap();
    watermelon(num);
}

fn watermelon(weight: i8) {
    if weight % 2 == 0 {
        println!("YES");
    } else {
        println!("NO");
    }
}


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

fn main() {
    let weight: i32 = readln().parse().unwrap();
    println!("{}", if weight > 0 && weight % 4 == 0 { "YES" } else { "NO" });
}