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

    let mut it = input.split_whitespace();

    let a: i32 = it.next().unwrap().parse().unwrap();
    let b: i32 = it.next().unwrap().parse().unwrap();

    let d = (b - a).abs();

    let q = d / 2;
    let r = d % 2;

    let ans = q * (q + 1) + if r == 1 { q + 1 } else { 0 };

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


#![allow(unused_imports)]
use std::io::*;
use std::cmp::*;
use std::collections::*;

macro_rules! debug(
    ($($arg:tt)*) => { {
        let r = writeln!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);

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

impl Scanner {

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

   fn process(&mut self) -> String {
      if self.buffer.len() == 0 {
         let mut input = String::new();
         std::io::stdin().read_line(&mut input).ok();
         for word in input.split_whitespace() {
            self.buffer.push_back(word.to_string())
         }
      }

      self.buffer.pop_front().unwrap()
   }

   fn next<T : std::str::FromStr >(&mut self) -> T {
      self.process().parse::<T>().ok().unwrap()
   }

   #[allow(dead_code)]
   fn next_char(&mut self) -> char {
      self.process().into_bytes()[0] as char
   }
}

fn cost(x : i64, n : i64, k : i64) -> i64 {
   let left_limit = min(k, x - 1);
   let right_limit = min(n - k - 1, x - 1);

   let left_cost = left_limit*x - (left_limit*(left_limit+1)/2);
   let right_cost = right_limit*x - (right_limit*(right_limit+1)/2);

   let left_extra = max(k - left_limit, 0);
   let right_extra = max((n - k - 1) - right_limit, 0);

   x + left_cost + right_cost + left_extra + right_extra
}

fn search(n : i64, k : i64, m : i64) -> i64 {
   let mut upper = m;
   let mut lower = 1;
   let mut middle = 0;

   while lower <= upper {
      middle = (lower + upper)/2;
      let c = cost(middle, n, k);
      debug!("l: {}, m: {}, u: {}, c: {}", lower, middle, upper, c);

      if c < m {
         lower = middle + 1;
      } else if c > m {
         upper = middle - 1;
      } else {
         break;
      }
   }

   while cost(middle, n, k) > m {
      middle -= 1;
   }

   middle
}

fn main() {
   let mut sin = Scanner::new();
   let (n, m, k) : (i64, i64, i64) = (sin.next(), sin.next(), sin.next());

   println!("{}", search(n, k - 1, m));
}


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

mod pollard_rho {
    use std::collections::HashMap;
    /// binary gcd
    pub fn gcd(mut x: i64, mut y: i64) -> i64 {
        if y == 0 { return x; }
        if x == 0 { return y; }
        let mut sh = 0;
        while ((x | y) & 1) == 0 {
            x >>= 1; y >>= 1; sh += 1;
        }
        while (x & 1) == 0 { x >>= 1; }
        while y != 0 {
            while (y & 1) == 0 { y >>= 1; }
            if x > y { let t = x; x = y; y = t; }
            y -= x;
        }
        x << sh
    }

    fn add_mod(x: i64, y: i64, n: i64) -> i64 {
        let z = x + y;
        if z >= n { z - n } else { z }
    }

    fn mul_mod(x: i64, mut y: i64, n: i64) -> i64 {
        assert!(x >= 0);
        assert!(x < n);
        let mut sum = 0;
        let mut cur = x;
        while y > 0 {
            if (y & 1) == 1 {
                sum = add_mod(sum, cur, n);
            }
            cur = add_mod(cur, cur, n);
            y >>= 1;
        }
        sum
    }

    fn mod_pow(x: i64, mut e: i64, n: i64) -> i64 {
        let mut prod = if n == 1 { 0 } else { 1 };
        let mut cur = x % n;
        while e > 0 {
            if (e & 1) == 1 {
                prod = mul_mod(prod, cur, n);
            }
            cur = mul_mod(cur, cur, n);
            e >>= 1;
        }
        prod
    }

    pub fn is_prime(n: i64) -> bool {
        if n <= 1 { return false; }
        let small = [2, 3, 5, 7, 11, 13];
        if small.iter().any(|&u| u == n) { return true; }
        if small.iter().any(|&u| n % u == 0) { return false; }
        let mut d = n - 1;
        let mut e = 0;
        while (d & 1) == 0 {
            d >>= 1;
            e += 1;
        }
        let a = [2, 325, 9375, 28178, 450775, 9780504, 1795265022];
        a.iter().all(|&a| {
            if a >= n { return true; }
            let mut x = mod_pow(a, d, n);
            if x == 1 { return true; }
            for _ in 0 .. e {
                if x == n - 1 {
                    return true;
                }
                x = mul_mod(x, x, n);
                if x == 1 { return false; }
            }
            x == 1
        })
    }

    fn pollard_rho(n: i64, c: &mut i64) -> i64 {
        if n % 2 == 0 { return 2; }
        loop {
            let mut x: i64 = 2;
            let mut y = 2;
            let mut d = 1;
            let cc = *c;
            let f = |i| add_mod(mul_mod(i, i, n), cc, n);
            while d == 1 {
                x = f(x);
                y = f(f(y));
                d = gcd((x - y).abs(), n);
            }
            if d == n {
                *c += 1;
                continue;
            }
            return d;
        }
    }

    /// Outputs (p, e) in p's ascending order.
    pub fn factorize(x: i64) -> Vec<(i64, usize)> {
        if x <= 1 {
            return Vec::new();
        }
        let mut hm = HashMap::new();
        let mut pool = vec![x];
        let mut c = 1;
        while let Some(u) = pool.pop() {
            if is_prime(u) {
                *hm.entry(u).or_insert(0) += 1;
                continue;
            }
            let p = pollard_rho(u, &mut c);
            pool.push(p);
            pool.push(u / p);
        }
        let mut v: Vec<_> = hm.into_iter().collect();
        v.sort();
        v
    }
} // mod pollard_rho

use pollard_rho::*;

fn solve() {
    let n = get();
    let x: i64 = get();
    let y: i64 = get();
    if y % x != 0 {
        println!("0");
        return;
    }
    let a: Vec<i64> = (0 .. n).map(|_| get()).collect();
    let b: Vec<i64> = a.iter().filter_map(|&a| if a % x == 0 { Some(a / x) } else { None }).collect();
    let c: Vec<i64> = a.iter().filter_map(|&a| if y % a == 0 { Some(y / a) } else { None }).collect();
    let y = y / x;
    let fac = factorize(y);
    let m = fac.len();
    let mut pat1 = vec![0i64; 1 << m];
    let mut pat2 = vec![0i64; 1 << m];
    for &b in &b {
        let mut hot = 0;
        for i in 0 .. m {
            let p = fac[i].0;
            if b % p == 0 {
                hot |= 1 << i;
            }
        }
        pat1[hot] += 1;
    }
    for &c in &c {
        let mut hot = 0;
        for i in 0 .. m {
            let p = fac[i].0;
            if c % p == 0 {
                hot |= 1 << i;
            }
        }
        pat2[hot] += 1;
    }
    // zeta
    for i in 0 .. m {
        for bits in 0 .. 1 << m {
            if (bits & 1 << i) != 0 {
                pat2[bits] += pat2[bits ^ 1 << i];
            }
        }
    }
    let mut ans = 0;
    for bits in 0 .. 1 << m {
        ans += pat1[bits] * pat2[(1 << m) - 1 - bits];
    }
    println!("{}", ans);
}

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


fn main() {
    use std::io;
    use std::io::prelude::*;

     let stdin = io::stdin();
     let mut lc = 1;
     let mut str_len = 0;
     for line in stdin.lock().lines() {
     	match lc  {
     		1 => {
     			str_len = line.unwrap().parse::<usize>().unwrap();
     		},
     		2 => {
     			let s = line.unwrap();
     			// println!("{:?}", s);
     			let mut num = 0;
     			let mut chars = s.chars();
     			let mut prev_ch = '1';
     			for ch in chars {
     				match ch {
	     				'1' => num += 1,
	     				'0' => { print!("{}", num); num = 0; },
	     				_ => panic!("SOS"),
     				}
     				prev_ch = ch;
     			}
     			if num > 0 {
	     			println!("{}", num);
     			}
     			if prev_ch == '0' {
     				print!("0");
     			}
     		}
     		_ => {
     			panic!("SOS");
     		}
     	}
     	lc += 1;
     }
}


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

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

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

    let owned = input_iter.next().unwrap();
    let price1 = input_iter.next().unwrap();
    let price2 = input_iter.next().unwrap();
    let price3 = input_iter.next().unwrap();

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

    let purchase = 4 - owned % 4;
    let result = match purchase {
        1 => min(price1, min(price3 * 3, price2 + price3)),
        2 => min(price2, min(price1 * 2, price3 * 2)),
        3 => min(price3, min(price1 * 3, price2 + price1)),
        _ => u64::max_value()
    };

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


use std::io::*;

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

fn volume_of(word: &str) -> usize {
    word.chars().filter(|x| x.is_uppercase()).count()
}

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

    let _n: usize = read(sin);
    let s: String = read(sin);

    println!("{}", s.split(" ").map(|x| volume_of(x)).max().unwrap_or(0));
}


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

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

fn solve() {
    let field: Vec<Vec<u8>> = (0..10).map(|_| parse_line!(String).bytes().collect()).collect();
    let mut ok = false;
    for i in 0..10 {
        for j in 0..10 {
            if i + 5 <= 10 {
                let mut xs = 0;
                let mut os = 0;
                for d in 0..5 {
                    if field[i + d][j] == b'X' {
                        xs += 1;
                    }else if field[i + d][j] == b'O' {
                        os += 1;
                    }
                }
                if os == 0 && xs >= 4 {
                    ok = true;
                }
            }
            if j + 5 <= 10 {
                let mut xs = 0;
                let mut os = 0;
                for d in 0..5 {
                    if field[i][j + d] == b'X' {
                        xs += 1;
                    }else if field[i][j + d] == b'O' {
                        os += 1;
                    }
                }
                if os == 0 && xs >= 4 {
                    ok = true;
                }
            }
            if i + 5 <= 10 && j + 5 <= 10 {
                let mut xs = 0;
                let mut os = 0;
                for d in 0..5 {
                    if field[i + d][j + d] == b'X' {
                        xs += 1;
                    }else if field[i + d][j + d] == b'O' {
                        os += 1;
                    }
                }
                if os == 0 && xs >= 4 {
                    ok = true;
                }
            }
            if i + 5 <= 10 && j >= 4 {
                let mut xs = 0;
                let mut os = 0;
                for d in 0..5 {
                    if field[i + d][j - d] == b'X' {
                        xs += 1;
                    }else if field[i + d][j - d] == b'O' {
                        os += 1;
                    }
                }
                if os == 0 && xs >= 4 {
                    ok = true;
                }
            }
        }
    }
    println!("{}", if ok {"YES"} else {"NO"});
}

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


#![allow(unused_imports)]
use std::io::*;
use std::cmp::*;
use std::collections::*;

macro_rules! debug(
    ($($arg:tt)*) => { {
        let r = writeln!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);

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

impl Scanner {

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

   fn process(&mut self) -> String {
      if self.buffer.len() == 0 {
         let mut input = String::new();
         std::io::stdin().read_line(&mut input).ok();
         for word in input.split_whitespace() {
            self.buffer.push_back(word.to_string())
         }
      }

      self.buffer.pop_front().unwrap()
   }

   fn next<T : std::str::FromStr >(&mut self) -> T {
      self.process().parse::<T>().ok().unwrap()
   }

   fn next_char(&mut self) -> char {
      self.process().into_bytes()[0] as char
   }
}

fn main() {
   let mut s = Scanner::new();
   let (n, m) = (s.next(), s.next());

   let mut color = false;
   for _ in 0..n {
      for _ in 0..m {
         let c = s.next_char();
         match c {
            'C' | 'M' | 'Y' => color = true,
            _ => { }
         }
      }
   }

   if color {
      println!("#Color");
   } else {
      println!("#Black&White");
   }
}


use std::io;

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

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

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

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


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

fn scan_helper(lock : &mut StdinLock) -> String {
    let mut buffer = String::new();
    lock.read_line(&mut buffer).ok();
    buffer
}

macro_rules! scan {
    ($lock:ident, $t:ty) => ({
        scan_helper(&mut $lock).split_whitespace()
            .next().unwrap()
            .parse::<$t>().unwrap()
    });
    ($lock:ident, $($t:ty),+) => ({
        let buffer = scan_helper(&mut $lock);
        let mut iter = buffer.split_whitespace();
        ($(
            {
                iter.next().unwrap()
                    .parse::<$t>().unwrap()
            },
        )+)
    })
}

macro_rules! scan_iter {
    ($lock:ident, $t:ty) => ({
        scan_helper(&mut $lock).split_whitespace()
            .map(|x| x.parse::<$t>().unwrap())
            .collect()
    })
}

trait Ext {
    fn idx(&self) -> usize;
    fn num(&self) -> i64;
}

macro_rules! ext {
    ($t:ty) => (
        impl Ext for $t {
            #[inline]
            fn idx(&self) -> usize {
                *self as usize
            }

            #[inline]
            fn num(&self) -> i64 {
                *self as i64
            }
        }
    )
}
ext!(i64);
ext!(usize);

macro_rules! derive_regular {
    ($t:ty) => (
        impl Ord for $t {
            fn cmp(&self, other : &$t) -> Ordering {
                self.partial_cmp(other).unwrap()
            }
        }
        impl PartialEq for $t {
            fn eq(&self, other : &$t) -> bool {
                self.cmp(other) == Ordering::Equal
            }
        }
        impl Eq for $t {}
    )
}

fn solve(v : &Vec<i64>, n : i64, d : bool, memo : &mut HashMap<(i64, bool), (i64, i64)>) -> (i64, i64) {
    if n == v.len().num() {
        if d {
            return (0, 0);
        } else {
            return (0, 0);
        }
    }
    if let Some(&x) = memo.get(&(n, d)) {
        return x;
    }

    let mut take = solve(v, n+1, !d, memo);
    if d {
        take.1 += v[n.idx()];
    } else {
        take.0 += v[n.idx()];
    }
    let mut defer = solve(v, n+1, d, memo);
    if d {
        defer.0 += v[n.idx()];
    } else {
        defer.1 += v[n.idx()];
    }

    let result = if d {
        if take.1 >= defer.1 {
            take
        } else {
            defer
        }
    } else {
        if take.0 >= defer.0 {
            take
        } else {
            defer
        }
    };
    memo.insert((n, d), result);

    result
}

fn main() {
    let stdin = stdin();
    let mut s = stdin.lock();
    let n = scan!(s, i64);
    let data : Vec<_> = scan_iter!(s, i64);

    let mut memo = HashMap::new();

    let result = solve(&data, 0, true, &mut memo);
    println!("{} {}", result.0, result.1);
}


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

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

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

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

fn linear_sieve(n: u64) -> (Vec<u64>, Vec<u64>) {
    let n = n as usize;
    let mut mpf = vec![0u64; n + 1];
    let mut primes = Vec::new();
    for i in 2..=n {
        if mpf[i] == 0 {
            mpf[i] = i as u64;
            primes.push(i as u64);
        }
        // for (int j = 0; j < primes.size() && i * primes[j] <= n && primes[j] <= mpf[i]) {
        //   mpf[i * primes[j]] = primes[j]
        // }
        for &p in primes.iter() {
            let num = i * p as usize;
            if num > n || p > mpf[i] {
                break;
            }
            mpf[num] = p;
        }
    }
    (primes, mpf)
}

fn get_mpf(n: u64, primes: &[u64], mpf: &[u64]) -> u64 {
    if (n as usize) < mpf.len() {
        return mpf[n as usize];
    }
    for &p in primes {
        if n % p == 0 {
            return p;
        }
    }
    n
}

fn solve<R: io::BufRead, W: io::Write>(scan: &mut Scanner<R>, out: &mut W) {
    let (primes, mpf) = linear_sieve(1000000);
    let mut n: u64 = scan.token();
    let mut ans = n;
    while n > 1 {
        let factor = n / get_mpf(n, &primes, &mpf);
        ans += factor;
        n = factor;
    }
    writeln!(out, "{}", ans).ok();
}

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


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 ts: usize = scan.next();
    for _ in 0..ts {
        let n: usize = scan.next();
        if n <= 7 {
            println!("1");
            continue;
        }
        let result = n / 7 + if n % 7 != 0 { 1 } else { 0 };
        println!("{}", result);
    }
}

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


use std::io::Read;

fn triangle(a: i32, b: i32, c: i32) -> bool {
  return a < b + c && b < c + a && c < a + b;
}
fn segment(a: i32, b: i32, c: i32) -> bool {
  return a == b + c || b == c + a || c == a + b;
}

fn main() {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).unwrap();
  let mut tokens = buf.split_whitespace();
  let a:i32 = tokens.next().unwrap().parse().unwrap();
  let b:i32 = tokens.next().unwrap().parse().unwrap();
  let c:i32 = tokens.next().unwrap().parse().unwrap();
  let d:i32 = tokens.next().unwrap().parse().unwrap();
  if triangle(a,b,c) || triangle(a,b,d) || triangle(a,c,d) || triangle(b,c,d) {
    println!("TRIANGLE");
  } else if segment(a,b,c) || segment(a,b,d) || segment(a,c,d) || segment(b,c,d) {
    println!("SEGMENT");
  } else {
    println!("IMPOSSIBLE");
  }
}


#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

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

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

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      aa: [i64; n]
    }
    let h = n/2 + n%2;
    let mut pos = 0;
    let mut neg = 0;
    for i in 0..n {
        if aa[i] > 0 {
            pos += 1;
        }
        if aa[i] < 0 {
            neg += 1;
        }
    }
    if pos >= h {
        println!("{}", 1);
    } else if neg >= h {
        println!("{}", -1);
    } else {
        println!("{}", 0);
    }
}


macro_rules! readln {
    () => {{
        use std::io;

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

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

fn main() {
    let (a,b) = readln!(i32,i32);
    let mut live = a;
    let mut dead = 0;
    let mut res = 0;
    while live>0 {
        res += live;
        dead += live;
        live = 0;
        live += (dead/b);
        dead %= b;
    }
    println!("{}",res);
}


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

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

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

    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop_front() {
                break token.parse::<T>().ok().unwrap();
            }
            let line = self.next_line();
            self.buffer = line.split_whitespace().map(String::from).collect();
        }
    }
}

fn get_order(x: usize, y: usize) -> usize {
    if x == 0 {
        return 0;
    }
    let mut x = x;
    let mut count = 0usize;
    while x % y == 0 {
        x /= y;
        count += 1;
    }
    count
}

fn _main() {
    let mut scan = Scan::new();
    let mut a: usize = scan.next();
    let mut b: usize = scan.next();
    let mut result = 0usize;
    let possible: Vec<usize> = vec![2, 3, 5];
    for i in possible {
        let ia = get_order(a, i);
        let ib = get_order(b, i);
        let diff = ia.max(ib) - ia.min(ib);
        result += diff;

        if ia > ib {
            a /= i.pow(diff as u32);
        } else if ia < ib {
            b /= i.pow(diff as u32);
        }
    }
    if a != b {
        println!("-1");
    } else {
        println!("{}", result);
    }
}

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


use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s = s.trim().to_string();
    let mut cnt1 = 0;
    let mut cnt2 = 0;
    for c in s.chars() {
        if (c as i32) >= ('a' as i32) {
            cnt1 += 1;
        } else {
            cnt2 += 1;
        }
    }
    for c in s.chars() {
        if cnt1 >= cnt2 {
            print!("{}", c.to_lowercase());
        } else {
            print!("{}", c.to_uppercase());
        }
    }
}


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

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

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

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

fn main() {
    let n: usize = get_line().trim().parse().unwrap();

    let a: Vec<u32> = get_vec();

    let dist = |a, b| {
        if a < b {
            b - a
        } else {
            a - b
        }
    };

    let prefix_sums: Vec<_> = (0..1).chain(a.into_iter().scan(0, |state, a| {
        *state += a;
        Some(*state)
    })).collect();

    let mut ans = None;

    for i in 0..n {
        for j in i + 1..n + 1 {
            let y = prefix_sums[j] - prefix_sums[i];
            let x = dist(y, 180);
            match ans {
                Some(ans) if ans < x => (),
                _ => {
                    ans = Some(x);
                },
            }
        }
    }

    println!("{}", 2 * ans.unwrap());
}


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


use std::cmp::Ordering;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let (n, k) = {
        let temp: Vec<u64> = buf
            .trim()
            .split_whitespace()
            .map(|a| a.parse().unwrap())
            .collect();
        (temp[0], temp[1])
    };

    let (mut index, mut jump) = (n / 2, n / 2);
    loop {
        let sum_n = index * (index + 1) / 2;
        let eaten = n - index;

        if eaten > sum_n {
            jump = 1.max(jump / 2);
            index += jump;
            continue;
        }

        match k.cmp(&(sum_n - eaten)) {
            Ordering::Equal => break,
            Ordering::Greater => {
                jump = 1.max(jump / 2);
                index += jump;
            }
            Ordering::Less => {
                jump = 1.max(jump / 2);
                index -= jump;
            }
        }
    }

    println!("{}", n - index);
}


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

const MOD: i64 = 1e9 as i64 + 7;

fn pow(mut a: i64, mut b: i64) -> i64 {
    let mut ans: i64 = 1;
    while b > 0 {
        if b & 1 == 1 {
            ans = (ans as i64 * a as i64) % MOD;
        }
        a = (a * a) % MOD;
        b >>= 1;
    }
    ans
}

fn main() {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let mut sc = cf_scanner::Scanner::new(stdin.lock());
    let mut out = io::BufWriter::new(stdout.lock());

    for _ in 0..sc.next() {
        writeln!(out, "{}", pow(sc.next(), sc.next())).unwrap();
    }
}

#[allow(dead_code)]
mod cf_scanner {
    use std::io;
    use std::str::{FromStr, SplitAsciiWhitespace};

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

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

        pub fn next<T: FromStr>(&mut self) -> T {
            loop {
                if let Some(token) = self.buf_iter.next() {
                    return token.parse().ok().expect("Failed parse");
                }
                self.buf_str.clear();
                self.reader
                    .read_until(b'\n', &mut self.buf_str)
                    .expect("Failed read");
                self.buf_iter = unsafe {
                    let slice = std::str::from_utf8_unchecked(&self.buf_str);
                    std::mem::transmute(slice.split_ascii_whitespace())
                }
            }
        }
    }
}


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

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

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

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

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

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

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

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

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

fn solve<Inner: BufRead, Output: Write>(inf: &mut Input<Inner>, ouf: &mut Output) {
	let (n, d) = read!(inf,usize,i32);
	let mut a = vec![0; n];
	for i in 0..n {
		a[i] = read!(inf,i32);
	}
	a.sort_unstable();
	let mut ans = n;
	for i in 0..n {
		for j in i..n {
			if a[j] - a[i] <= d {
				ans = min(ans, i + n - 1 - j);
			}
		}
	}
	writeln!(ouf, "{}", ans);
}


#![allow(unused_variables)]
#![allow(unused_must_use)]
use std::io::{self, prelude::*};
use std::cmp::min;

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

}
fn solve<R: BufRead, W: Write>(mut input: FastInput<R>, mut w: W) {
    let a: i64 = input.token();
    let b: i64 = input.token();
    let mut x: i64 = input.token();
    let mut y: i64 = input.token();
    let g = gcd(x,y);
    x = x / g;
    y = y / g;
    write!(w, "{}\n", min(a/x, b/y));

}

fn main() {
  let stdin = io::stdin();
  let stdout = io::stdout();
  let input = FastInput::from(stdin.lock());
  let output = io::BufWriter::new(stdout.lock());
  solve(input, output)
}

trait TokenStream<T> {
    fn token(&mut self) -> T;
}

struct FastInput<R> {
    stdin: R,
    pos: usize,
}

impl<R: BufRead> From<R> for FastInput<R> {
    fn from(r: R) -> Self {
        FastInput { stdin: r, pos: 0 }
    }
}

impl<R: BufRead> TokenStream<u8> for FastInput<R> {
    fn token(&mut self) -> u8 {
        loop {
            if let Ok(buf) = self.stdin.fill_buf() {
                while self.pos < buf.len() {
                    self.pos += 1;
                    if buf[self.pos - 1] > 32 {
                        return buf[self.pos - 1];
                    }
                }
                if self.pos == 0 {
                    return 0;
                }
            } else {
                return 0;
            }
            self.stdin.consume(self.pos);
            self.pos = 0;
        }
    }
}

impl<R: BufRead> TokenStream<Vec<u8>> for FastInput<R> {
    fn token(&mut self) -> Vec<u8> {
        let mut ans = Vec::new();
        let mut parse_token = false;
        loop {
            if let Ok(buf) = self.stdin.fill_buf() {
                if !parse_token {
                    while self.pos < buf.len() && buf[self.pos] <= 32 {
                        self.pos += 1;
                    }
                }
                while self.pos < buf.len() && buf[self.pos] > 32 {
                    parse_token = true;
                    ans.push(buf[self.pos]);
                    self.pos += 1;
                }
                if self.pos != buf.len() || self.pos == 0 {
                    return ans;
                }
            }
            self.stdin.consume(self.pos);
            self.pos = 0;
        }
    }
}

macro_rules! impl_token_stream {
    ($($t:ident),+) => {$(
        impl<R: BufRead> TokenStream<$t> for FastInput<R> {
           fn token(&mut self) -> $t {
                let mut ans = 0;
                let mut parse_token = false;
                loop {
                    if let Ok(buf) = self.stdin.fill_buf() {
                        if !parse_token {
                            while self.pos < buf.len() && buf[self.pos] <= 32 {
                                self.pos += 1;
                            }
                        }
                        while self.pos < buf.len() && buf[self.pos] > 32 {
                            parse_token = true;
                            ans = ans * 10 + (buf[self.pos] - b'0') as $t;
                            self.pos += 1;
                        }
                        if self.pos != buf.len() || self.pos == 0 {
                            return ans;
                        }
                    }
                    self.stdin.consume(self.pos);
                    self.pos = 0;
                }
           }
        }
    )+}
}

impl_token_stream!(i64);


use std::io;
use std::io::Write;

// Outline
// read in numberse first and parse

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

    io::stdin().read_line(&mut input)
        .expect("Couldn't read line.");

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

    let number_of_pages: i32 = input[0];
    let current_page: i32 = input[1];
    let range_of_pages: i32 = input[2];

    let lower_bound = {
        if current_page - range_of_pages <= 0 {
            1
        } else {
            current_page - range_of_pages
        }
    };

    let higher_bound = {
        if current_page + range_of_pages > number_of_pages {
            number_of_pages
        } else {
            current_page + range_of_pages
        }
    };

    if higher_bound != number_of_pages && lower_bound != 1 {
        print!("<< ");
        io::stdout().flush().unwrap();
        for page in lower_bound..higher_bound+1 {
            if page == current_page {
                print!("({}) ", page);
                io::stdout().flush().unwrap();
            } else {
                print!("{} ", page);
                io::stdout().flush().unwrap();
            }
        }
        print!(">>");
        io::stdout().flush().unwrap();
    } else if higher_bound == number_of_pages && lower_bound != 1 {
        print!("<< ");
        io::stdout().flush().unwrap();
        for page in lower_bound..higher_bound+1 {
            if page == current_page {
                print!("({}) ", page);
                io::stdout().flush().unwrap();
            } else {
                print!("{} ", page);
                io::stdout().flush().unwrap();
            }
        }
    } else if higher_bound == number_of_pages && lower_bound == 1 {
        for page in lower_bound..higher_bound+1 {
            if page == current_page {
                print!("({}) ", page);
                io::stdout().flush().unwrap();
            } else {
                print!("{} ", page);
                io::stdout().flush().unwrap();
            }
        }
    } else if higher_bound != number_of_pages && lower_bound == 1 {
        for page in lower_bound..higher_bound+1 {
            if page == current_page {
                print!("({}) ", page);
                io::stdout().flush().unwrap();
            } else {
                print!("{} ", page);
                io::stdout().flush().unwrap();
            }
        }
        print!(">>");
        io::stdout().flush().unwrap();
    }
}


// ---------- begin BitSet ----------
#[derive(Clone)]
struct BitSet {
    size: usize,
    a: Vec<usize>,
}

fn bit_size() -> usize {
    8 * std::mem::size_of::<usize>()
}

fn quot_rem(n: usize) -> (usize, usize) {
    let w = bit_size();
    (n / w, n % w)
}

#[allow(dead_code)]
impl BitSet {
    fn new(size: usize) -> Self {
        let w = bit_size();
        BitSet {
            size: size,
            a: vec![0; (size + w - 1) / w],
        }
    }
    fn set_at(&mut self, x: usize) {
        assert!(x < self.size);
        let (q, r) = quot_rem(x);
        self.a[q] |= 1 << r;
    }
    fn clear_at(&mut self, x: usize) {
        assert!(x < self.size);
        let (q, r) = quot_rem(x);
        self.a[q] &= !(1 << r);
    }
    fn get_at(&self, x: usize) -> bool {
        if x >= self.size {
            return false;
        }
        let (q, r) = quot_rem(x);
        (self.a[q] >> r) & 1 == 1
    }
    fn any(&self) -> bool {
        self.a.iter().any(|a| *a != 0)
    }
    fn fix(&mut self) {
        let (q, r) = quot_rem(self.size);
        if r != 0 {
            self.a[q] &= (1 << r) - 1;
        }
    }
    fn clear(&mut self) {
        let len = self.a.len();
        self.a.clear();
        self.a.resize(len, 0);
    }
    fn truncate(&mut self, len: usize) {
        if len >= self.size {
            return;
        }
        let w = bit_size();
        self.a.truncate((len + w - 1) / w);
        self.size = len;
        self.fix();
    }
    fn popcnt(&self) -> usize {
        self.a.iter().fold(0, |s, a| s + a.count_ones() as usize)
    }
    fn shift_left(&self, rhs: usize) -> Self {
        let (q, r) = quot_rem(rhs);
        let mut ans = BitSet::new(self.size + rhs);
        if r == 0 {
            for (x, y) in ans.a[q..].iter_mut().zip(self.a.iter()) {
                *x = *y;
            }
        } else {
            let w = bit_size();
            let mut prev = 0;
            for (x, y) in ans.a[q..].iter_mut().zip(self.a.iter()) {
                *x = (*y << r) | (prev >> (w - r));
                prev = *y;
            }
            *ans.a.last_mut().unwrap() |= prev >> (w - r);
        }
        ans.fix();
        ans
    }
    fn shift_right(&self, rhs: usize) -> Self {
        if rhs >= self.size {
            return BitSet::new(1);
        }
        let (q, r) = quot_rem(rhs);
        let mut ans = BitSet::new(self.size - rhs);
        if r == 0 {
            for (x, y) in ans.a.iter_mut().zip(self.a[q..].iter()) {
                *x = *y;
            }
        } else {
            let w = bit_size();
            let mut prev = 0;
            for (x, y) in ans.a.iter_mut().zip(self.a[q..].iter()).rev() {
                *x |= (*y >> r) | (prev << (w - r));
                prev = *y;
            }
        }
        ans.fix();
        ans
    }
    fn bitwise_or(&self, rhs: &Self) -> Self {
        let (x, y) = if self.size >= rhs.size {
            (self, rhs)
        } else {
            (rhs, self)
        };
        let mut a = x.a.clone();
        for (a, y) in a.iter_mut().zip(y.a.iter()) {
            *a |= *y;
        }
        BitSet { size: x.size, a: a }
    }
    fn bitwise_and(&self, rhs: &Self) -> Self {
        let (x, y) = if self.size <= rhs.size {
            (self, rhs)
        } else {
            (rhs, self)
        };
        let mut a = x.a.clone();
        for (a, y) in a.iter_mut().zip(y.a.iter()) {
            *a &= *y;
        }
        BitSet { size: x.size, a: a }
    }
    fn bitwise_xor(&self, rhs: &Self) -> Self {
        let (x, y) = if self.size >= rhs.size {
            (self, rhs)
        } else {
            (rhs, self)
        };
        let mut a = x.a.clone();
        for (a, y) in a.iter_mut().zip(y.a.iter()) {
            *a ^= *y;
        }
        BitSet { size: x.size, a: a }
    }
    fn bitwise_or_assign(&mut self, rhs: &Self) {
        if self.size < rhs.size {
            self.size = rhs.size;
            self.a.resize(rhs.a.len(), 0);
        }
        for (a, b) in self.a.iter_mut().zip(rhs.a.iter()) {
            *a |= *b;
        }
    }
    fn bitwise_and_assign(&mut self, rhs: &Self) {
        if self.size > rhs.size {
            self.size = rhs.size;
            self.a.resize(rhs.a.len(), 0);
        }
        for (a, b) in self.a.iter_mut().zip(rhs.a.iter()) {
            *a &= *b;
        }
    }
    fn bitwise_xor_assign(&mut self, rhs: &Self) {
        if self.size < rhs.size {
            self.size = rhs.size;
            self.a.resize(rhs.a.len(), 0);
        }
        for (a, b) in self.a.iter_mut().zip(rhs.a.iter()) {
            *a ^= *b;
        }
    }
}
// ---------- end BitSet ----------
//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")
    };
}

//

// 異なる値が含まれるやつはどっちがどっちかわからないので不可能
// 同じ値のみを聞き出す戦略
// 同じ値のみを残せるように聞く戦略
// 同じ値を残せるように聞く戦略ができるならのみを聞き出すことも可能
//
// 同じ値のみを残す
// a をk 個聞き出せる条件は
// aを使わないで(k - i) * a を作れないこと
// 分割統治bitset?

fn calc(a: &[(usize, usize)], dp: &[BitSet]) -> usize {
    let n = a.len();
    if n == 1 {
        let (a, c) = a[0];
        let mut ans = 1;
        for k in 2..=c {
            let mut ok = true;
            for j in 0..k {
                ok &= !dp[k - j].get_at(a * (k - j));
            }
            if ok {
                ans = k;
            }
        }
        return ans;
    }
    let (l, r) = a.split_at(n / 2);
    let mut p = vec![];
    p.extend_from_slice(dp);
    for &(a, c) in l.iter() {
        for _ in 0..c {
            for i in (1..dp.len()).rev() {
                let mut set = p[i].bitwise_or(&p[i - 1].shift_left(a));
                set.truncate(dp[0].size);
                p[i] = set;
            }
        }
    }
    let a = calc(r, &p);
    let mut p = vec![];
    p.extend_from_slice(dp);
    for &(a, c) in r.iter() {
        for _ in 0..c {
            for i in (1..dp.len()).rev() {
                let mut set = p[i].bitwise_or(&p[i - 1].shift_left(a));
                set.truncate(dp[0].size);
                p[i] = set;
            }
        }
    }
    std::cmp::max(a, calc(l, &p))
}

fn run() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut a = a.into_iter().map(|a| (a, 1)).collect::<Vec<_>>();
    a.sort();
    a.dedup_by(|a, b| {
        a.0 == b.0 && {
            b.1 += a.1;
            true
        }
    });
    if a.len() <= 2 {
        println!("{}", n);
        return;
    }
    let w = n * 100;
    let mut dp = vec![BitSet::new(w + 1); n + 1];
    dp[0].set_at(0);
    let ans = calc(&a, &dp);
    println!("{}", ans);
}

fn main() {
    run();
}


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

fn main() {
    let mut buffer = String::new();
    let stdin = io::stdin();
    let mut handle = stdin.lock();
    handle.read_to_string(&mut buffer).unwrap();

    let arr : Vec<_> = buffer.split_whitespace().map(|x| x.parse::<u64>().unwrap() ).collect();
    let n = arr[0];
    let mut d = 0;
    let mut h = n;
    while h > 0 {
        d += 1;
        h = h / 10;
    }
    use std::cmp;
    let mut a = 0;
    'outer: for i in 0..d {
        // println!("{}",a);
        let mut r = 0;
        for j in 0..10 {
            let y = j * 10u64.pow(i);
            if a + y <= n {
                r = cmp::max(a + y, r);
                // println!("{}",r);
            }
        }
        a = r;
    }
    let mut b = n - a;
    // println!("{} {}", a, b);
    let mut ans = 0;
    while a > 0 {
        ans += a % 10;
        a = a / 10;
    }
    while b > 0 {
        ans += b % 10;
        b = b / 10;
    }
    println!("{}", ans);
}


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

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

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

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

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

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

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

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

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

/// Verified by: https://atcoder.jp/contests/pakencamp-2018-day3/submissions/3878249
mod mod_int {
    use std::ops::*;
    pub trait Mod: Copy + Clone { fn m() -> i64; }
    #[derive(Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
    pub struct ModInt<M> { pub x: i64, phantom: ::std::marker::PhantomData<*const M> }
    impl<M: Mod> ModInt<M> {
        fn check_integrity(self) {
            debug_assert!(self.x >= 0);
            debug_assert!(self.x < M::m());
        }
        // x >= 0
        pub fn new(x: i64) -> Self { ModInt::new_internal(x % M::m()) }
        fn new_internal(x: i64) -> Self {
            ModInt { x: x, phantom: ::std::marker::PhantomData }
        }
        #[allow(dead_code)]
        pub fn mul_fast(self, other: Self) -> Self {
            self.check_integrity();
            other.check_integrity();
            ModInt::new_internal(self.x * other.x % M::m())
        }
        #[allow(dead_code)]
        pub fn mul_slow(self, other: Self) -> Self {
            // Naive multiplication in order to avoid overflow
            self.check_integrity();
            other.check_integrity();
            let mut sum = ModInt::new_internal(0);
            let mut cur = self;
            let mut e = other.x;
            if self.x < other.x {
                cur = other;
                e = self.x;
            }
            while e > 0 {
                if e % 2 == 1 { sum += cur; }
                cur += cur;
                e /= 2;
            }
            sum
        }
        pub fn pow(self, mut e: i64) -> Self {
            self.check_integrity();
            debug_assert!(e >= 0);
            let mut sum = ModInt::new_internal(1);
            let mut cur = self;
            while e > 0 {
                if e % 2 != 0 { sum *= cur; }
                cur *= cur;
                e /= 2;
            }
            sum
        }
        #[allow(dead_code)]
        pub fn inv(self) -> Self { self.pow(M::m() - 2) }
    }
    impl<M: Mod> Add for ModInt<M> {
        type Output = Self;
        fn add(self, other: Self) -> Self {
            self.check_integrity();
            other.check_integrity();
            let mut sum = self.x + other.x;
            if sum >= M::m() { sum -= M::m(); }
            ModInt::new_internal(sum)
        }
    }
    impl<M: Mod> Sub for ModInt<M> {
        type Output = Self;
        fn sub(self, other: Self) -> Self {
            self.check_integrity();
            other.check_integrity();
            let mut sum = self.x - other.x;
            if sum < 0 { sum += M::m(); }
            ModInt::new_internal(sum)
        }
    }
    impl<M: Mod> Mul for ModInt<M> {
        type Output = Self;
        fn mul(self, other: Self) -> Self { self.mul_fast(other) }
    }
    impl<M: Mod> AddAssign for ModInt<M> {
        fn add_assign(&mut self, other: Self) { *self = *self + other; }
    }
    impl<M: Mod> SubAssign for ModInt<M> {
        fn sub_assign(&mut self, other: Self) { *self = *self - other; }
    }
    impl<M: Mod> MulAssign for ModInt<M> {
        fn mul_assign(&mut self, other: Self) { *self = *self * other; }
    }
    impl<M> ::std::fmt::Display for ModInt<M> {
        fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
            self.x.fmt(f)
        }
    }
    impl<M> ::std::fmt::Debug for ModInt<M> {
        fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
            self.x.fmt(f)
        }
    }
} // mod mod_int

macro_rules! define_mod {
    ($struct_name: ident, $modulo: expr) => {
        #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
        struct $struct_name {}
        impl mod_int::Mod for $struct_name { fn m() -> i64 { $modulo } }
    }
}
const MOD: i64 = 998244353;
define_mod!(P, MOD);
type ModInt = mod_int::ModInt<P>;

/// FFT (in-place)
/// R: Ring + Copy
/// Verified by: ATC001-C (http://atc001.contest.atcoder.jp/submissions/1175827)
mod fft {
    use std::ops::*;
    /// n should be a power of 2. zeta is a primitive n-th root of unity.
    /// one is unity
    /// Note that the result should be multiplied by 1/sqrt(n).
    pub fn transform<R>(f: &mut [R], zeta: R, one: R)
        where R: Copy +
        Add<Output = R> +
        Sub<Output = R> +
        Mul<Output = R> {
        let n = f.len();
        assert!(n.is_power_of_two());
        {
            let mut i = 0;
            for j in 1 .. n - 1 {
                let mut k = n >> 1;
                loop {
                    i ^= k;
                    if k <= i { break; }
                    k >>= 1;
                }
                if j < i {
                    f.swap(i, j);
                }
            }
        }
        let mut zetapow = Vec::new();
        {
            let mut m = 1;
            let mut cur = zeta;
            while m < n {
                zetapow.push(cur);
                cur = cur * cur;
                m *= 2;
            }
        }
        let mut m = 1;
        while m < n {
            let m2 = 2 * m;
            let base = zetapow.pop().unwrap();
            let mut r = 0;
            while r < n {
                let mut w = one;
                for x in 0 .. m {
                    let s = x + r;
                    let u = f[s];
                    let d = f[s + m] * w;
                    f[s] = u + d;
                    f[s + m] = u - d;
                    w = w * base;
                }
                r += m2;
            }
            m *= 2;
        }
    }
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        k: usize,
        d: [usize; k],
    }
    const N: usize = 1 << 22;
    let one = ModInt::new(1);
    let mut f = vec![ModInt::new(0); N];
    let zeta = ModInt::new(3).pow((MOD - 1) / N as i64);
    for i in 0 .. k {
        f[d[i]] += one;
    }
    fft::transform(&mut f, zeta, one);
    for i in 0 .. N {
        f[i] = f[i].pow(n as i64 / 2);
    }
    fft::transform(&mut f, zeta.inv(), one);
    let factor = ModInt::new(N as i64).inv();
    for i in 0 .. N {
        f[i] *= factor;
    }
    let mut tot = ModInt::new(0);
    for i in 0 .. N {
        tot += f[i].pow(2);
    }
    puts!("{}\n", tot);
}

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


use std::io;

#[derive(Debug, Copy, Clone, PartialEq)]
enum Color {
    C,
    Y,
    M,
    U,
}

impl Color {
    fn create(c: char) -> Self {
        match c {
            'C' => Color::C,
            'Y' => Color::Y,
            'M' => Color::M,
            _ => Color::U,
        }
    }
}

pub fn main() {
    let input = get_input();
    let length = input.len();
    let mut unknowns = 0;
    let mut two_solutions = false;
    let mut unknown_location = 0;
    //println!("{:?}", input);
    if input[0] == Color::U {
        two_solutions = true;
    }
    for i in 1..length {
        if input[i] == Color::U {
            if i == length - 1 || i == 0 ||
                input[i + 1] == input[i - 1] || input[i - 1] == Color::U {
                two_solutions = true;
            }
        } else if input[i] == input[i - 1] {
            println!("No");
            return;
        }
    }
    if two_solutions {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn get_input() -> Vec<Color> {
    let mut input = String::new();
    io::stdin().read_line(&mut input);
    let mut input = String::new();
    io::stdin().read_line(&mut input);
    input.trim().chars().map(|c| Color::create(c)).collect()
}


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

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

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

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

fn main() {
    let n: usize = get_line().trim().parse().unwrap();

    let s = get_line().trim().to_string();

    let it = s.split_terminator(char::is_uppercase);

    let ans = it.map(|s| {
        s.bytes().fold(vec![false; 26], |mut acc, c| {
            acc[(c - b'a') as usize] = true;
            acc
        }).into_iter().filter(|&b| b).count()
    }).max().unwrap();

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


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

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

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

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

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

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


use std::io;

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

    let _ = stdin.read_line(&mut s)?;
    s = s.trim().to_string();

    let word = "hello";
    if calc(word, &s) {
        println!("YES");
    } else {
        println!("NO");
    }

    Ok(())
}

fn calc(sub: &str, s: &str) -> bool {
    calc2(sub.as_bytes(), s.as_bytes())
}

fn calc2<'a, T>(sub: T, s: T) -> bool
where
    T: IntoIterator<Item = &'a u8>,
    T::IntoIter: Clone
{
    let mut sub_iter = sub.into_iter();
    let mut s_iter = s.into_iter();

    if let Some(c) = sub_iter.next() {
        while let Some(c2) = s_iter.next() {
            if c == c2 && calc2(sub_iter.clone(), s_iter.clone()) {
                return true
            }
        }
        false
    } else {
        true
    }
}


fn read_string() -> String {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).expect("Failed");
    input
}

fn main(){

    let mut x = read_string();
    x = x.replace("\r", "");
    let vec: Vec<&str> = x.split("").collect();
    let mut found: bool =  false;
    for n in 2..(vec.len()-3){
        if ((vec[n] != ".") && (vec[n+1] != ".") && (vec[n-1] != ".")) &&
            ((vec[n] != vec[n+1]) && (vec[n-1] != vec[n+1]) && (vec[n] != vec[n-1]))
            {
            found = true;
            break
        }
    }
    println!("{}", if found {"YES"} else {"NO"});
}


#[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 mut n: i64 = get();
    let k: i32 = get();
    let mut cnt = 0;
    let mut kk = k;
    while kk > 0 {
        if n == 0 {
            cnt = max(cnt + k - kk - 1, 0);
            break;
        }
        if n % 10 != 0 {
            cnt += 1;
        } else {
            kk -= 1;
        }
        n /= 10;
    }
    println!("{}", cnt);
}

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


pub trait Readable {
    type Output;
    fn words_count() -> usize;
    fn read_words(words: &[&str]) -> Result<Self::Output, String>;
}
#[macro_export]
macro_rules! readable {
    ( $ t : ty , $ words_count : expr , |$ words : ident | $ read_words : expr ) => {
        impl Readable for $t {
            type Output = $t;
            fn words_count() -> usize {
                $words_count
            }
            fn read_words($words: &[&str]) -> Result<$t, String> {
                Ok($read_words)
            }
        }
    };
}
readable!((), 1, |_ss| ());
readable!(String, 1, |ss| ss[0].to_string());
impl Readable for char {
    type Output = char;
    fn words_count() -> usize {
        1
    }
    fn read_words(words: &[&str]) -> Result<char, String> {
        let chars: Vec<char> = words[0].chars().collect();
        if chars.len() == 1 {
            Ok(chars[0])
        } else {
            Err(format!("cannot parse `{}` as a char", words[0]))
        }
    }
}
pub struct Chars();
impl Readable for Chars {
    type Output = Vec<char>;
    fn words_count() -> usize {
        1
    }
    fn read_words(words: &[&str]) -> Result<Vec<char>, String> {
        Ok(words[0].chars().collect())
    }
}
macro_rules ! impl_readable_for_ints { ( $ ( $ t : ty ) * ) => { $ ( impl Readable for $ t { type Output = Self ; fn words_count ( ) -> usize { 1 } fn read_words ( words : & [ & str ] ) -> Result <$ t , String > { use std :: str :: FromStr ; <$ t >:: from_str ( words [ 0 ] ) . map_err ( | _ | { format ! ( "cannot parse `{}` as {}" , words [ 0 ] , stringify ! ( $ t ) ) } ) } } ) * } ; }
impl_readable_for_ints ! ( i8 u8 i16 u16 i32 u32 i64 u64 isize usize f32 f64 ) ;
macro_rules ! define_one_origin_int_types { ( $ new_t : ident $ int_t : ty ) => { # [ doc = " Converts 1-origin integer into 0-origin when read from stdin." ] # [ doc = "" ] # [ doc = " # Example" ] # [ doc = "" ] # [ doc = " ```no_run" ] # [ doc = " # #[macro_use] extern crate atcoder_snippets;" ] # [ doc = " # use atcoder_snippets::read::*;" ] # [ doc = " // Stdin: \"1\"" ] # [ doc = " read!(a = usize_);" ] # [ doc = " assert_eq!(a, 0);" ] # [ doc = " ```" ] # [ allow ( non_camel_case_types ) ] pub struct $ new_t ; impl Readable for $ new_t { type Output = $ int_t ; fn words_count ( ) -> usize { 1 } fn read_words ( words : & [ & str ] ) -> Result < Self :: Output , String > { <$ int_t >:: read_words ( words ) . map ( | n | n - 1 ) } } } ; ( $ new_t : ident $ int_t : ty ; $ ( $ inner_new_t : ident $ inner_int_t : ty ) ;* ) => { define_one_origin_int_types ! ( $ new_t $ int_t ) ; define_one_origin_int_types ! ( $ ( $ inner_new_t $ inner_int_t ) ;* ) ; } ; }
define_one_origin_int_types ! ( u8_ u8 ; u16_ u16 ; u32_ u32 ; u64_ u64 ; usize_ usize ) ;
macro_rules ! impl_readable_for_tuples { ( $ t : ident $ var : ident ) => ( ) ; ( $ t : ident $ var : ident ; $ ( $ inner_t : ident $ inner_var : ident ) ;* ) => { impl_readable_for_tuples ! ( $ ( $ inner_t $ inner_var ) ;* ) ; impl <$ t : Readable , $ ( $ inner_t : Readable ) ,*> Readable for ( $ t , $ ( $ inner_t ) ,* ) { type Output = ( <$ t >:: Output , $ ( <$ inner_t >:: Output ) ,* ) ; fn words_count ( ) -> usize { let mut n = <$ t >:: words_count ( ) ; $ ( n += <$ inner_t >:: words_count ( ) ; ) * n } # [ allow ( unused_assignments ) ] fn read_words ( words : & [ & str ] ) -> Result < Self :: Output , String > { let mut start = 0 ; let $ var = <$ t >:: read_words ( & words [ start .. start +<$ t >:: words_count ( ) ] ) ?; start += <$ t >:: words_count ( ) ; $ ( let $ inner_var = <$ inner_t >:: read_words ( & words [ start .. start +<$ inner_t >:: words_count ( ) ] ) ?; start += <$ inner_t >:: words_count ( ) ; ) * Ok ( ( $ var , $ ( $ inner_var ) ,* ) ) } } } ; }
impl_readable_for_tuples ! ( T8 x8 ; T7 x7 ; T6 x6 ; T5 x5 ; T4 x4 ; T3 x3 ; T2 x2 ; T1 x1 ) ;
pub trait ReadableFromLine {
    type Output;
    fn read_line(line: &str) -> Result<Self::Output, String>;
}
fn split_into_words(line: &str) -> Vec<&str> {
    #[allow(deprecated)]
    line.trim_right_matches('\n').split_whitespace().collect()
}
impl<T: Readable> ReadableFromLine for T {
    type Output = T::Output;
    fn read_line(line: &str) -> Result<T::Output, String> {
        let words = split_into_words(line);
        if words.len() != T::words_count() {
            return Err(format!(
                "line `{}` has {} words, expected {}",
                line,
                words.len(),
                T::words_count()
            ));
        }
        T::read_words(&words)
    }
}
macro_rules ! impl_readable_from_line_for_tuples_with_from_iterator { ( $ u : ident : $ ( + $ bound : path ) * => $ seq_in : ty , $ seq_out : ty ; $ t : ident $ var : ident ) => { impl <$ u : Readable > ReadableFromLine for $ seq_in where <$ u as Readable >:: Output : Sized $ ( + $ bound ) * { type Output = $ seq_out ; fn read_line ( line : & str ) -> Result <$ seq_out , String > { let n = $ u :: words_count ( ) ; let words = split_into_words ( line ) ; if words . len ( ) % n != 0 { return Err ( format ! ( "line `{}` has {} words, expected multiple of {}" , line , words . len ( ) , n ) ) ; } let mut result = Vec :: new ( ) ; for chunk in words . chunks ( n ) { match $ u :: read_words ( chunk ) { Ok ( v ) => result . push ( v ) , Err ( msg ) => { let flagment_msg = if n == 1 { format ! ( "word {}" , result . len ( ) ) } else { let l = result . len ( ) ; format ! ( "words {}-{}" , n * l + 1 , ( n + 1 ) * l ) } ; return Err ( format ! ( "{} of line `{}`: {}" , flagment_msg , line , msg ) ) ; } } } Ok ( result . into_iter ( ) . collect ( ) ) } } impl < T : Readable , $ u : Readable > ReadableFromLine for ( T , $ seq_in ) where <$ u as Readable >:: Output : Sized $ ( + $ bound ) * { type Output = ( T :: Output , $ seq_out ) ; fn read_line ( line : & str ) -> Result < Self :: Output , String > { let n = T :: words_count ( ) ; # [ allow ( deprecated ) ] let trimmed = line . trim_right_matches ( '\n' ) ; let words_and_rest : Vec <& str > = trimmed . splitn ( n + 1 , ' ' ) . collect ( ) ; if words_and_rest . len ( ) < n { return Err ( format ! ( "line `{}` has {} words, expected at least {}" , line , words_and_rest . len ( ) , n ) ) ; } let words = & words_and_rest [ .. n ] ; let empty_str = "" ; let rest = words_and_rest . get ( n ) . unwrap_or ( & empty_str ) ; Ok ( ( T :: read_words ( words ) ?, <$ seq_in >:: read_line ( rest ) ? ) ) } } } ; ( $ u : ident : $ ( + $ bound : path ) * => $ seq_in : ty , $ seq_out : ty ; $ t : ident $ var : ident , $ ( $ inner_t : ident $ inner_var : ident ) ,+ ) => { impl_readable_from_line_for_tuples_with_from_iterator ! ( $ u : $ ( + $ bound ) * => $ seq_in , $ seq_out ; $ ( $ inner_t $ inner_var ) ,+ ) ; impl <$ t : Readable , $ ( $ inner_t : Readable ) ,+ , $ u : Readable > ReadableFromLine for ( $ t , $ ( $ inner_t ) ,+ , $ seq_in ) where <$ u as Readable >:: Output : Sized $ ( + $ bound ) * { type Output = ( $ t :: Output , $ ( $ inner_t :: Output ) ,+ , $ seq_out ) ; fn read_line ( line : & str ) -> Result < Self :: Output , String > { let mut n = $ t :: words_count ( ) ; $ ( n += $ inner_t :: words_count ( ) ; ) + # [ allow ( deprecated ) ] let trimmed = line . trim_right_matches ( '\n' ) ; let words_and_rest : Vec <& str > = trimmed . splitn ( n + 1 , ' ' ) . collect ( ) ; if words_and_rest . len ( ) < n { return Err ( format ! ( "line `{}` has {} words, expected at least {}" , line , words_and_rest . len ( ) , n ) ) ; } let words = & words_and_rest [ .. n ] ; let empty_str = "" ; let rest = words_and_rest . get ( n ) . unwrap_or ( & empty_str ) ; let ( $ var , $ ( $ inner_var ) ,* ) = < ( $ t , $ ( $ inner_t ) ,+ ) >:: read_words ( words ) ?; Ok ( ( $ var , $ ( $ inner_var ) ,* , <$ seq_in >:: read_line ( rest ) ? ) ) } } } ; }
#[macro_export]
macro_rules ! readable_collection { ( $ u : ident => $ collection_in : ty , $ collection_out : ty ) => { impl_readable_from_line_for_tuples_with_from_iterator ! ( $ u : => $ collection_in , $ collection_out ; T8 x8 , T7 x7 , T6 x6 , T5 x5 , T4 x4 , T3 x3 , T2 x2 , T1 x1 ) ; } ; ( $ u : ident : $ ( $ bound : path ) ,* => $ collection_in : ty , $ collection_out : ty ) => { impl_readable_from_line_for_tuples_with_from_iterator ! ( $ u : $ ( + $ bound ) * => $ collection_in , $ collection_out ; T8 x8 , T7 x7 , T6 x6 , T5 x5 , T4 x4 , T3 x3 , T2 x2 , T1 x1 ) ; } }
readable_collection ! ( U => Vec < U >, Vec < U :: Output > ) ;
readable_collection ! ( U => std :: collections :: VecDeque < U >, std :: collections :: VecDeque < U :: Output > ) ;
readable_collection ! ( U : Eq , std :: hash :: Hash => std :: collections :: HashSet < U >, std :: collections :: HashSet < U :: Output > ) ;
readable_collection ! ( U : Ord => std :: collections :: BTreeSet < U >, std :: collections :: BTreeSet < U :: Output > ) ;
readable_collection ! ( U : Ord => std :: collections :: BinaryHeap < U >, std :: collections :: BinaryHeap < U :: Output > ) ;
pub fn read<T: ReadableFromLine>() -> T::Output {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    T::read_line(&line).unwrap()
}
#[macro_export]
macro_rules ! read { ( ) => { let mut line = String :: new ( ) ; std :: io :: stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; } ; ( $ pat : pat = $ t : ty ) => { let $ pat = read ::<$ t > ( ) ; } ; ( $ ( $ pat : pat = $ t : ty ) ,+ ) => { read ! ( ( $ ( $ pat ) ,* ) = ( $ ( $ t ) ,* ) ) ; } ; }
#[macro_export]
macro_rules ! readls { ( $ ( $ pat : pat = $ t : ty ) ,+ ) => { $ ( read ! ( $ pat = $ t ) ; ) * } ; }
pub fn readx<T: ReadableFromLine>() -> Vec<T::Output> {
    use std::io::{self, BufRead};
    let stdin = io::stdin();
    let result = stdin
        .lock()
        .lines()
        .map(|line_result| {
            let line = line_result.expect("read from stdin failed");
            T::read_line(&line).unwrap()
        })
        .collect();
    result
}
#[macro_export]
macro_rules ! readx_loop { ( |$ pat : pat = $ t : ty | $ body : expr ) => { { use std :: io :: BufRead ; let stdin = std :: io :: stdin ( ) ; for line in stdin . lock ( ) . lines ( ) { let line = line . expect ( "read from stdin failed" ) ; let $ pat = <$ t >:: read_line ( & line ) . unwrap ( ) ; $ body } } } ; ( |$ ( $ pat : pat = $ t : ty ) ,*| $ body : expr ) => { readx_loop ! ( | ( $ ( $ pat ) ,* ) = ( $ ( $ t ) ,* ) | $ body ) ; } ; }
pub fn readn<T: ReadableFromLine>(n: usize) -> Vec<T::Output> {
    use std::io::{self, BufRead};
    let stdin = io::stdin();
    let result: Vec<T::Output> = stdin
        .lock()
        .lines()
        .take(n)
        .map(|line_result| {
            let line = line_result.expect("read from stdin failed");
            T::read_line(&line).unwrap()
        })
        .collect();
    if result.len() < n {
        panic!(
            "expected reading {} lines, but only {} lines are read",
            n,
            result.len()
        );
    }
    result
}
#[macro_export]
macro_rules ! readn_loop { ( $ n : expr , |$ pat : pat = $ t : ty | $ body : expr ) => { { use std :: io :: BufRead ; let stdin = std :: io :: stdin ( ) ; let mut lock = stdin . lock ( ) ; for _ in 0 ..$ n { let mut line = String :: new ( ) ; lock . read_line ( & mut line ) . expect ( "read from stdin failed" ) ; let $ pat = <$ t >:: read_line ( & line ) . unwrap ( ) ; $ body } } } ; ( $ n : expr , |$ ( $ pat : pat = $ t : ty ) ,*| $ body : expr ) => { readn_loop ! ( $ n , | ( $ ( $ pat ) ,* ) = ( $ ( $ t ) ,* ) | $ body ) ; } ; }
pub trait Words {
    fn read<T: Readable>(&self) -> T::Output;
}
impl<'a> Words for [&'a str] {
    fn read<T: Readable>(&self) -> T::Output {
        T::read_words(self).unwrap()
    }
}
impl<'a> Words for &'a str {
    fn read<T: Readable>(&self) -> T::Output {
        T::read_words(&[self]).unwrap()
    }
}

fn main() {
    read!(d_a = u32, d_b = u32);
    if d_a == d_b {
        println!("{} {}", d_a*10, d_a*10+1);
    } else if d_b == d_a+1 {
        println!("{} {}", d_a*10+9, d_b*10);
    } else if d_b == 1 && d_a == 9 {
        println!("9 10");
    } else {
        println!("-1");
    }
}


fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let size = s.split_whitespace().map(|x| x.parse::<i32>().unwrap()).collect::<Vec<i32>>();
    let mut c = -1;
    if size.iter().fold(true, |acc, &x| acc && (x==0)) == true {
        c=-1;
    } else {
    for i  in 0..=100 {
        if size.iter().map(|x| x-i).sum::<i32>() == 0 {
           c = i;
           break;
        }
    }
    }
    println!("{}",c );
}