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

fn read_int_line () -> i32 {
    let mut num = String::new();
    io::stdin().read_line(&mut num)
        .expect("Failed to read line");

    num.trim().parse()
        .expect("Not an integer")
}

fn main() {

    let num = read_int_line();

    let mut a: i32 = -1;
    let mut b: i32 = -1;

    let mut an: i32 = 0;
    let mut bn: i32 = 0;

    let mut foo: bool = true;

    for i in (0..num).rev(){
        let temp = read_int_line();
        match temp.cmp(&a) {
            Ordering::Equal => an += 1,
            _ => match temp.cmp(&b) {
                Ordering::Equal => bn += 1,
                _ => match b.cmp(&(-1)) {
                    Ordering::Equal => b = temp,
                    _ => match a.cmp(&-1) {
                        Ordering::Equal => a = temp,
                        _ => { println!("NO"); foo = false; break; } ,
                    }
                },
            },
        }
    }

    if foo {
        match a.cmp(&b) {
            Ordering::Equal => println!("NO"),
            _ => match an.cmp(&bn) {
                Ordering::Equal => {println!("YES"); println!("{} {}", a, b);},
                _ => println!("NO"),
            },
        }
    }
}

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

fn read_int_line () -> i32 {
    let mut num = String::new();
    io::stdin().read_line(&mut num)
        .expect("Failed to read line");

    num.trim().parse()
        .expect("Not an integer")
}

fn main() {

    let num = read_int_line();

    let mut a: i32 = -1;
    let mut b: i32 = -1;

    let mut an: i32 = 0;
    let mut bn: i32 = 0;

    let mut foo: bool = true;

    for i in (0..num).rev(){
        let temp = read_int_line();
        if !foo {

        }
        else if a == temp {
            an += 1;
        }
        else if b == temp {
            bn += 1;
        }
        else if b == -1 {
            b = temp;
        }
        else if a == -1 {
            a = temp;
        }
        else {
            foo = false;
        }
    }

    if foo {
        match a.cmp(&b) {
            Ordering::Equal => println!("NO"),
            _ => match an.cmp(&bn) {
                Ordering::Equal => {println!("YES"); println!("{} {}", a, b);},
                _ => println!("NO"),
            },
        }
    }
    else {
        println!("NO");
    }
}

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 mut set = vec![0; 100];

    for s in BufReader::new(io::stdin()).lines() {
        let s = s.unwrap();
        let a: usize = s.trim().parse::<usize>().unwrap() - 1;
        set[a] += 1;
    }

    let ans = set.iter().filter(|&&x| x != 0).count() == 2
        && {
            let mut it = set.iter().filter(|&&x| x != 0);
            it.next().unwrap() == it.next().unwrap()
        };

    if ans {
        println!("YES");
        for (i, _) in set.iter().enumerate().filter(|&(_, &x)| x != 0) {
            print!("{} ", i + 1);
        }
        println!("");
    } else {
        println!("NO");
    }
}


use std::io;

fn main() {
    let (mut cnt1, mut cnt2);

    cnt1 = 0;
    cnt2 = 0;

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

    let n: usize = s.trim().parse().unwrap();

    s = String::new();
    io::stdin().read_line(&mut s).expect("Failed to read line");
    let a = s
        .split_whitespace()
        .map(|x| x.parse::<i32>())
        .collect::<Result<Vec<i32>, _>>()
        .unwrap();

    s = String::new();
    io::stdin().read_line(&mut s).expect("Failed to read line");
    let b = s
        .split_whitespace()
        .map(|x| x.parse::<i32>())
        .collect::<Result<Vec<i32>, _>>()
        .unwrap();

    for i in 0usize..n {
        if a[i] == 1 && b[i] == 0 {
            cnt1 = cnt1 + 1;
        } else if a[i] == 0 && b[i] == 1 {
            cnt2 = cnt2 + 1;
        }
    }

    if cnt1 == 0 {
        println!("-1");
    } else {
        println!("{}", cnt2 / cnt1 + 1);
    }
}

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

fn main() {
    let _n = get_input().trim().parse::<usize>().unwrap();
    let ra: Vec<usize> = get_input().trim().split(' ').map(|x| x.parse::<usize>().unwrap()).collect();
    let rb: Vec<usize> = get_input().trim().split(' ').map(|x| x.parse::<usize>().unwrap()).collect();
    let mut badv = 0;
    let mut rchn = 0;
    for (rv, bv) in ra.iter().zip(rb) {
        if *rv == 0 && bv == 1 {
            badv += 1;
        } else if *rv == 1 && bv == 0 {
            rchn += 1;
        }
    }

    if rchn == 0 {
        println!("{}", -1);
    } else if badv == 0 {
        println!("{}", 1);
    } else {
        let rwin = badv + 1;
        if rwin % rchn != 0 {
            println!("{}", 1 + (rwin / rchn));
        } else {
            println!("{}", rwin / rchn);
        }
    }
}

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

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines();
    let _ = lines.next().unwrap().unwrap().parse::<i32>().unwrap();
    let a: Vec<i32> = lines.next().unwrap().unwrap().split(" ").map(|s| s.parse::<i32>().unwrap()).collect();
    let b: Vec<i32> = lines.next().unwrap().unwrap().split(" ").map(|s| s.parse::<i32>().unwrap()).collect();
    println!("{}", solve(a, b).unwrap_or(-1));
}

pub fn solve( a: Vec<i32>, b: Vec<i32>) -> Option<i32> {
    let b_score = a.iter().zip(b.iter()).fold(0, |mut acc, (x,y)| {
        if x < y {
            acc += 1;
        }
        acc
    });
    let outperform = a.iter().zip(b.iter()).fold(0, |mut acc, (x,y)| {
        if x > y {
            acc += 1;
        }
        acc
    });
    match outperform {
        0 => None,
        r => Some(b_score / outperform + 1),
    }
}

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

 impl Scanner {

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

    fn next<T : std::str::FromStr >(&mut self) -> T {
       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())
          }
       }
       let front = self.buffer.pop_front().unwrap();
       front.parse::<T>().ok().unwrap()
    }

}

fn main() {
    let mut scanner = Scanner::new();
    let n : usize = scanner.next();
    let mut r: Vec<i32> = Vec::new();
    let (mut r_win, mut b_win) = (0, 0);
    for _ in 0..n {
        let num : i32 = scanner.next();
        r.push(num);
    }
    for i in 0..n {
        let num : i32 = scanner.next();
        if num > r[i] {
            b_win += 1;
        } else if num < r[i] {
            r_win += 1;
        }
    }
    if r_win == 0 {
        println!("-1");
    } else {
        println!("{}", b_win / r_win + 1);
    }
}

#[doc = " https://github.com/hatoo/competitive-rust-snippets"]
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[macro_export]
macro_rules ! chmax { ( $ x : expr , $ ( $ v : expr ) ,+ ) => { $ ( $ x = std :: cmp :: max ( $ x ,$ v ) ; ) + } ; }
#[macro_export]
macro_rules ! chmin { ( $ x : expr , $ ( $ v : expr ) ,+ ) => { $ ( $ x = std :: cmp :: min ( $ x ,$ v ) ; ) + } ; }
#[macro_export]
macro_rules ! max { ( $ x : expr ) => ( $ x ) ; ( $ x : expr , $ ( $ xs : expr ) ,+ ) => { std :: cmp :: max ( $ x , max ! ( $ ( $ xs ) ,+ ) ) } ; }
#[macro_export]
macro_rules ! min { ( $ x : expr ) => ( $ x ) ; ( $ x : expr , $ ( $ xs : expr ) ,+ ) => { std :: cmp :: min ( $ x , min ! ( $ ( $ xs ) ,+ ) ) } ; }
#[macro_export]
macro_rules ! dvec { ( $ t : expr ; $ len : expr ) => { vec ! [ $ t ; $ len ] } ; ( $ t : expr ; $ len : expr , $ ( $ rest : expr ) ,* ) => { vec ! [ dvec ! ( $ t ; $ ( $ rest ) ,* ) ; $ len ] } ; }
#[macro_export]
macro_rules ! cfor { ( ; $ ( $ rest : tt ) * ) => { cfor ! ( ( ) ; $ ( $ rest ) * ) } ; ( $ ( $ init : stmt ) ,+; ; $ ( $ rest : tt ) * ) => { cfor ! ( $ ( $ init ) ,+; ! false ; $ ( $ rest ) * ) } ; ( $ ( $ init : stmt ) ,+; $ cond : expr ; ; $ body : block ) => { cfor ! { $ ( $ init ) ,+; $ cond ; ( ) ; $ body } } ; ( $ ( $ init : stmt ) ,+; $ cond : expr ; $ ( $ step : expr ) ,+; $ body : block ) => { { $ ( $ init ; ) + while $ cond { let mut _first = true ; let mut _continue = false ; loop { if ! _first { _continue = true ; break } _first = false ; $ body } if ! _continue { break } $ ( $ step ; ) + } } } ; }
#[doc = " main"]
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[macro_export]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut parser = Parser :: from_str ( $ s ) ; input_inner ! { parser , $ ( $ r ) * } } ; ( parser = $ parser : ident , $ ( $ r : tt ) * ) => { input_inner ! { $ parser , $ ( $ r ) * } } ; ( new_stdin_parser = $ parser : ident , $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let reader = std :: io :: BufReader :: new ( stdin . lock ( ) ) ; let mut $ parser = Parser :: new ( reader ) ; input_inner ! { $ parser , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { input ! { new_stdin_parser = parser , $ ( $ r ) * } } ; }
#[macro_export]
macro_rules ! input_inner { ( $ parser : ident ) => { } ; ( $ parser : ident , ) => { } ; ( $ parser : ident , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ parser , $ t ) ; input_inner ! { $ parser $ ( $ r ) * } } ; }
#[macro_export]
macro_rules ! read_value { ( $ parser : ident , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ parser , $ t ) ) ,* ) } ; ( $ parser : ident , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ parser , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ parser : ident , chars ) => { read_value ! ( $ parser , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ parser : ident , usize1 ) => { read_value ! ( $ parser , usize ) - 1 } ; ( $ parser : ident , $ t : ty ) => { $ parser . next ::<$ t > ( ) . expect ( "Parse error" ) } ; }
use std::io;
use std::io::BufRead;
use std::str;
pub struct Parser<R> {
    reader: R,
    buf: Vec<u8>,
    pos: usize,
}
impl Parser<io::Empty> {
    pub fn from_str(s: &str) -> Parser<io::Empty> {
        Parser {
            reader: io::empty(),
            buf: s.as_bytes().to_vec(),
            pos: 0,
        }
    }
}
impl<R: BufRead> Parser<R> {
    pub fn new(reader: R) -> Parser<R> {
        Parser {
            reader: reader,
            buf: vec![],
            pos: 0,
        }
    }
    pub fn update_buf(&mut self) {
        self.buf.clear();
        self.pos = 0;
        loop {
            let (len, complete) = {
                let buf2 = self.reader.fill_buf().unwrap();
                self.buf.extend_from_slice(buf2);
                let len = buf2.len();
                if len == 0 {
                    break;
                }
                (len, buf2[len - 1] <= 0x20)
            };
            self.reader.consume(len);
            if complete {
                break;
            }
        }
    }
    pub fn next<T: str::FromStr>(&mut self) -> Result<T, T::Err> {
        loop {
            let mut begin = self.pos;
            while begin < self.buf.len() && (self.buf[begin] <= 0x20) {
                begin += 1;
            }
            let mut end = begin;
            while end < self.buf.len() && (self.buf[end] > 0x20) {
                end += 1;
            }
            if begin != self.buf.len() {
                self.pos = end;
                return str::from_utf8(&self.buf[begin..end]).unwrap().parse::<T>();
            } else {
                self.update_buf();
            }
        }
    }
}
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }
#[doc = " https://github.com/hatoo/competitive-rust-snippets"]
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}
fn solve() {
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    input!{
        n:usize,
        a:[u8;n],
        b:[u8;n],
    }
    let mut acnt = 0;
    let mut btot = 0;
    for i in 0..n {
        if a[i] == b[i] {
        } else {
            if a[i] == 1 {
                acnt += 1;
            } else {
                btot += 1;
            }
        }
    }
    if acnt == 0 {
        writeln!(out,"-1");
        return
    }
    let ars = ArithSeq::new(0,acnt);
    let nxt = ars.next(btot+1);
    writeln!(out,"{}",nxt/acnt);
}
struct ArithSeq {
    a: i64,
    b: i64,
}
impl ArithSeq {
    pub fn new(a: i64, b: i64) -> ArithSeq {
        assert!(b > 0);
        ArithSeq { a: a, b: b }
    }
    #[doc = "a+bi >= x"]
    pub fn next(&self, x: i64) -> i64 {
        if x >= self.a {
            let d = x - self.a;
            let i = (d - 1 + self.b) / self.b;
            self.a + self.b * i
        } else {
            let d = self.a - x;
            let i = d / self.b;
            self.a - self.b * i
        }
    }
    #[doc = "a+bi <= x"]
    pub fn prev(&self, x: i64) -> i64 {
        let next = self.next(x);
        if next == x {
            x
        } else {
            next - self.b
        }
    }
    #[doc = "[a+bi, n] <= [l, u]"]
    pub fn range(&self, l: i64, u: i64) -> Option<(i64, i64)> {
        if l > u {
            return None;
        }
        let x = self.next(l);
        let y = self.prev(u);
        if x > y {
            return None;
        }
        assert!(x <= y);
        if l <= x && x <= u {
            let cnt = (y - x) / self.b;
            Some((x, cnt + 1))
        } else {
            None
        }
    }
}

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 responses = scan.next::<usize>();
    let mut robo_coder_s = String::new();
    stdin().read_line(&mut robo_coder_s).expect("Failed read");
    let robo_coder = robo_coder_s.split_whitespace().collect::<Vec<&str>>();
    let mut bionic_solver_s = String::new();
    stdin()
        .read_line(&mut bionic_solver_s)
        .expect("Failed read");
    let bionic_solver = bionic_solver_s.split_whitespace().collect::<Vec<&str>>();

    let mut only_robo_coder_wins = 0.0;
    let mut only_bionic_solver_wins = 0.0;
    for response in 0..responses {
        match (robo_coder[response], bionic_solver[response]) {
            ("1", "0") => only_robo_coder_wins += 1.0,
            ("0", "1") => only_bionic_solver_wins += 1.0,
            _ => (),
        }
    }
    let robo_code_minimum_points: f64 = if only_robo_coder_wins == 0.0 {
        -1.0
    } else {
        (only_bionic_solver_wins + 1.0) / only_robo_coder_wins
    };
    println!("{}", robo_code_minimum_points.ceil() as i32);
}

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 n = scan.next::<usize>();
    let mut a = Vec::with_capacity(n);
    for _ in 0..n {
        a.push(scan.next::<i32>());
    }
    let mut b = Vec::with_capacity(n);
    for _ in 0..n {
        b.push(scan.next::<i32>());
    }
    let mut num_a = 0;
    let mut num_b = 0;
    for i in 0..n {
        if b[i] == 0 && a[i] == 1 {
            num_a += 1;
        } else if b[i] == 1 && a[i] == 0 {
            num_b += 1;
        }
    }
    let mut ans;
    if num_a == 0 {
        ans = -1;
    } else {
        ans = 1;
        while num_a * ans <= num_b {
            ans += 1;
        }
    }
    println!("{}", ans);
}

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 n = scan.next::<usize>();
    let mut a = vec![0; n];
    for i in 0..n {
        a[i] = scan.next::<i32>();
    }
    let mut b = vec![0; n];
    for i in 0..n {
        b[i] = scan.next::<i32>();
    }
    let mut num_a = 0;
    let mut num_b = 0;
    for i in 0..n {
        if a[i] == 1 && b[i] == 0 {
            num_a += 1;
        } else if a[i] == 0 && b[i] == 1 {
            num_b += 1;
        }
    }
    let ans = {
        if num_a == 0 {
            -1
        } else {
            let mut x = 1;
            while num_a * x <= num_b {
                x += 1;
            }
            x
        }
    };
    println!("{}", ans);
}


use std::cmp::{max, min};
use std::io::stdin;
fn main() {
    let mut text = String::new();
    stdin().read_line(&mut text).unwrap();
    text.clear();
    stdin().read_line(&mut text).unwrap();
    let text: Vec<usize> = text
        .trim()
        .split_whitespace()
        .map(|e| e.parse().unwrap())
        .collect();
    let mut v: Vec<usize> = vec![];
    for x in 1..(text.len() + 1) {
        let mut value = 0;
        for a in 1..(text.len() + 1) {
            value += (abs(x, a) + abs(1, a) + abs(1, x)) * text[a - 1] * 2
        }
        v.push(value)
    }
    v.sort();

    println!("{}", v[0]);
}
fn abs(a: usize, b: usize) -> usize {
    max(a, b) - min(a, b)
}

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

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

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

fn main() {
    input!{
      n: usize,
      aa: [i64; n],
    }
    let mut ans: i64 = 1 << 32;
    for i in 0i64..n as i64 {
        let mut cost = 0;
        for j in 0i64..n as i64 {
            cost += ((j-i).abs() + j + i) * 2 * aa[j as usize] as i64;
        }
        ans = min(cost, ans);
    }
    println!("{}", ans);
}

use std::io;

fn main() {
    let n = read_one::<usize>();
    let an = read::<usize>();
    let mut ans = 0;

    for i in 0..n {
        ans += an[i] * i * 4;
    }
    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

fn main() {
    let n = read_one::<usize>();
    let an = read::<usize>();
    let mut ans = 100_000_000;

    for i in 0..n { // i + 1 : x_th
        let mut tmp = 0;
        for j in 0..n { // a_th
            tmp += (an[j] as isize) * ((i as isize - j as isize).abs()) * 2; // x -> a
            tmp += (an[j] * j * 2) as isize; // a -> ground
            tmp += (2 * i) as isize; // g -> x
        }
        ans = cmp::min(ans, tmp);
    }
    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}


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 digits(mut n: u64) -> u64 {
    let mut count = 0u64;
    while n > 0 {
        count += 1;
        n /= 10;
    }
    return count;
}

fn main() {
    let n: u64 = read_line().parse().unwrap();

    let d = digits(n);
    let mut nums_counted = 0u64;
    let mut nines = 9u64;
    let mut res = 0u64;
    for i in 1 .. d {
        let cur_len = nines - nums_counted;
        nines = nines * 10 + 9;
        res += cur_len * i;
        nums_counted += cur_len;
    }

    let cur_len = n - nums_counted;
    res += cur_len * d;

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

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

#[allow(unused_macros)]
macro_rules! m {
    ($c:tt, $x:expr, $y:expr) => {{
        let b = $y; let a = &mut $x;
        if b $c *a { *a = b; true } else { false }
    }};
}
#[allow(unused_macros)]
macro_rules! l {
    ($i:ident . $e:tt : $t:ty, $($a:ident),*) => {
        $( let $a: $t = $i.$e(); )*
    };
    ($i:ident . $e:tt, $($a:ident),*) => {
        $( let $a = $i.$e(); )*
    };
}

struct WordReader<'a> { it : SplitAsciiWhitespace<'a>, }
#[allow(dead_code)]
impl<'a> WordReader<'a> {
    fn new<T: Read>(b: &mut String, mut r: T) -> WordReader {
        b.clear();
        r.read_to_string(b).ok();
        WordReader { it: b.split_ascii_whitespace() }
    }
    fn from_stdin(b: &mut String) -> WordReader {
        WordReader::new(b, stdin())
    }
    fn sl(&mut self) ->  &str { self.it.next().unwrap() }
    fn bs(&mut self) -> &[u8] { self.sl().as_bytes()    }
    fn s(&mut self) -> String { String::from(self.sl()) }
    fn i(&mut self) ->    i32 { self.p()                }
    fn f(&mut self) ->    f64 { self.p()                }
    fn u(&mut self) ->  usize { self.p()                }
    fn sk(&mut self, n: usize) { self.it.nth(n - 1); }
    fn vi(&mut self, n: usize) -> Vec<i32> {
        self.vp::<i32>(n)
    }
    fn p<T: FromStr>(&mut self) -> T where T::Err: Debug {
        self.sl().parse::<T>().unwrap()
    }
    fn ip<T: FromStr>(&mut self, n: usize) -> impl std::iter::Iterator<Item=T> where T::Err: Debug {
        self.vp(n).into_iter()
    }
    fn vp<T: FromStr>(&mut self, n: usize) -> Vec<T> where T::Err: Debug {
        (0..n).map(|_| self.p()).collect()
    }
}

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

    let n: i64 = input.p();
    let mut sol = n * 0;
    let mut d = 1;
    let mut x = 1;
    loop {
        let xx = x * 10;
        if n < xx {
            sol += (n - x + 1) * d;
            break;
        } else {
            sol += (xx - x) * d;
            x = xx;
            d += 1;
        }
    }
    println!("{}", sol);
}


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

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

    l!(l,r: i64 = input.p());
    if l == r {
        println!("0");
    } else {
        let mut x = l ^ r;
        for i in 0..=5 {
            x |= x >> (1 << i);
        }
        println!("{}", x);
    }
}

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

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

use std::io::Write;

fn solve(writer: &mut std::io::BufWriter<std::io::Stdout>) {
    let (l, r) = parse_line!(u64, u64);
    let mut bit = 1u64 << 63;
    while bit != 0 && l & bit == r & bit {
        bit >>= 1;
    }
    if bit == 0 {
        writeln!(writer, "0").unwrap();
    }else{
        writeln!(writer, "{}", bit | (bit - 1)).unwrap();
    }
}

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


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 = ay - dm;
    let am = am - dy;
    if ay <= 0 {
        return false;
    }
    if am <= 0 {
        return true;
    }
    let yt = (hy - 1) / am;
    let mt = (hm - 1) / ay;
    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..500 {
        for dadd in 0..500 {
            let ay = ay + aadd;
            let dy = dy + dadd;
            let mut l: i64 = -1;
            let mut r: i64 = 100001;
            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();
    }
}

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 = ay - dm;
    let am = am - dy;
    if ay <= 0 {
        return false;
    }
    if am <= 0 {
        return true;
    }
    let yt = (hy - 1) / am;
    let mt = (hm - 1) / ay;
    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;
            if !resolve(hy + r, ay, dy, hm, am, dm) {
                continue;
            }
            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;
            if cost < ans {
                ans = cost;
            }
        }
    }
    println!("{}", ans);
}

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

// ---------- 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..=21000 {
        if i * h > ans {
            break;
        }
        for j in 0..=200 {
            if j * a > ans - i * h {
                break;
            }
            for k in 0..=200 {
                if win(i, j, k) {
                    ans = min(ans, i * h + j * a + k * d);
                }
            }
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}

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


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 b(n: u32) -> bool {
    let mut sum = 0;
    let mut k = n;
    while k > 0 {
        sum += k % 10;
        k /= 10;
    }
    return sum == 10;
}

fn main() {
    let mut k: u32 = read_line().parse().unwrap();
    let mut i = 0u32;
    while k > 0 {
        i += 1;
        if b(i) {
            k -= 1;
        }
    }

    println!("{}", i);

}

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

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

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

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

fn digit_sum(n: u32) -> u32 {
    let mut ans = 0;
    let mut n = n;
    while n > 0 {
        ans += n % 10;
        n /= 10;
    }
    ans
}

fn solve<R: io::BufRead, W: io::Write>(scan: &mut Scanner<R>, out: &mut W) {

    let mut k: usize = scan.token();
    let mut num = 0;
    while k > 0 {
        num += 1;
        if digit_sum(num) == 10 {
            k -= 1;
        }
    }
    writeln!(out, "{}", num).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);
}

//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).unwrap();
        WordReader { it: b.split_ascii_whitespace() }
    }
    fn from_stdin(b: &mut String) -> WordReader {
        WordReader::new(b, stdin())
    }
    fn sl(&mut self) ->  &str { self.it.next().unwrap() }
    fn bs(&mut self) -> &[u8] { self.sl().as_bytes()    }
    fn s(&mut self) -> String { String::from(self.sl()) }
    fn i(&mut self) ->    i32 { self.p()                }
    fn u(&mut self) ->  usize { self.p()                }
    fn vi(&mut self, n: usize) -> Vec<i32> {
        self.vp::<i32>(n)
    }
    fn p<T: FromStr>(&mut self) -> T where T::Err: Debug {
        self.sl().parse::<T>().unwrap()
    }
    fn vp<T: FromStr>(&mut self, n: usize) -> Vec<T> where T::Err: Debug {
        (0..n).map(|_| self.p()).collect()
    }
}

#[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 k = input.u();
    let sol = (1..).filter(|&a| {
        let mut b = a;
        let mut s = 0;
        while b > 0 {
            s += b % 10;
            b /= 10;
        }
        s == 10
    }).nth(k - 1).unwrap();
    println!("{}", sol);
}

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

#[allow(dead_code)]
const INF: i32 = 1000_000_000;
#[allow(dead_code)]
const INFLL: i64 = 1000_000_000_000_000_000;
#[allow(dead_code)]
const EPS: f64 = 1.0e-10;
#[allow(dead_code)]
const MOD: i32 = 1000_000_007;
#[allow(dead_code)]
const MODLL: i64 = 1000_000_007;

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

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

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let k: usize = sc.read();
    let mut cnt = 0;
    for i in 0..1000_000_00 {
        let mut sum = 0;
        let mut x = i;
        while x > 0 {
            sum += x % 10;
            x /= 10;
        }
        if sum == 10 {
            cnt += 1;
        }

        if cnt == k {
            println!("{}", i);
            break;
        }
    }
}

#![allow(unused_imports, unused_macros, dead_code)]
use std::f64::*;
use std::cmp::*;
use std::collections::*;

macro_rules! dump{
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

const INF: i64 = 0x3f3f3f3f3f3f3f3f;
const MOD: i64 = 1000000007;
const NOTHING: usize = std::usize::MAX;
const DX: [usize; 4] = [1, 0, std::usize::MAX, 0];
const DY: [usize; 4] = [0, 1, 0, std::usize::MAX];

fn main() {
    let mut k: u64 = readln();
    let mut i = 0;
    while k > 0 {
        i += 1;
        let mut x = i;
        let mut s = 0;
        while x > 0 {
            s += x % 10;
            x /= 10;
        }
        if s == 10 {
            k -= 1;
        }
    }
    println!("{}", i);
}

trait Read {
    fn read(s: &str) -> Self;
}

fn readln<T: Read>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    T::read(buf.trim_right())
}

macro_rules! read_impl{
    ($($t:ty)*) => ($(
        impl Read for $t {
            fn read(s: &str) -> $t{
                s.parse().unwrap()
            }
        }
    )*)
}
read_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }

impl Read for String {
    fn read(s: &str) -> Self {
        s.to_string()
    }
}

impl Read for Vec<char> {
    fn read(s: &str) -> Self {
        s.chars().collect()
    }
}

impl<T: Read> Read for Vec<T> {
    fn read(s: &str) -> Self {
        s.split_whitespace().map(T::read).collect()
    }
}

impl<A: Read, B: Read> Read for (A, B) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]))
    }
}

impl<A: Read, B: Read, C: Read> Read for (A, B, C) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]))
    }
}

impl<A: Read, B: Read, C: Read, D: Read> Read for (A, B, C, D) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]), D::read(tokens[3]))
    }
}

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

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

use std::io::Write;

fn good(mut a: u32) -> bool {
    let mut sum = 0;
    while a != 0 {
        sum += a % 10;
        a /= 10;
    }
    return sum == 10;
}

fn solve(writer: &mut std::io::BufWriter<std::io::Stdout>) {
    let mut k = parse_line!(usize);
    let mut result = 0;
    while k > 0 {
        result += 1;
        if good(result) {
            k -= 1;
        }
    }
    writeln!(writer, "{}", result).unwrap();
}

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

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

fn main() {
    let n: i32 = read_line().unwrap().parse().unwrap();
    fn sum_digits(mut n: i64) -> i32 {
        let mut sum = 0;
        while n > 0 {
            sum += (n % 10) as i32;
            n /= 10;
        }
        sum
    }
    let mut a = 19;
    let mut m = 0;
    loop {
        let sum = sum_digits(a);
        if sum == 10 {
            m += 1;
            if m == n {
                println!("{}", a);
                break;
            }
        }
        if sum >= 10 {
            a += 10 - a % 10;
        } else {
            a += 1;
        }
    }
}


//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).unwrap();
        WordReader { it: b.split_ascii_whitespace() }
    }
    fn from_stdin(b: &mut String) -> WordReader {
        WordReader::new(b, stdin())
    }
    fn sl(&mut self) ->  &str { self.it.next().unwrap() }
    fn bs(&mut self) -> &[u8] { self.sl().as_bytes()    }
    fn s(&mut self) -> String { String::from(self.sl()) }
    fn i(&mut self) ->    i32 { self.p()                }
    fn u(&mut self) ->  usize { self.p()                }
    fn vi(&mut self, n: usize) -> Vec<i32> {
        self.vp::<i32>(n)
    }
    fn p<T: FromStr>(&mut self) -> T where T::Err: Debug {
        self.sl().parse::<T>().unwrap()
    }
    fn vp<T: FromStr>(&mut self, n: usize) -> Vec<T> where T::Err: Debug {
        (0..n).map(|_| self.p()).collect()
    }
}

#[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 n = input.u();
    let mut a = vec![0; 3];
    for i in 0..n {
        a[i % 3] += input.i();
    }
    let max = a.iter().max().unwrap();
    for (x,y) in vec!["chest","biceps","back"].into_iter().zip(a.iter()) {
        if max == y {
            println!("{}", x);
        }
    }
}

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

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

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

fn _main() {
    let mut scan = Scan::new();
    let n: usize = scan.next();
    let mut cnt = [0usize; 3];
    let ex_msg = ["chest", "biceps", "back"];
    let mut maxa = 0usize;
    let mut maxi = 0usize;
    for i in 0..n {
        let a: usize = scan.next();
        let exi = i % 3;
        cnt[exi] += a;
        if cnt[exi] > maxa {
            maxa = cnt[exi];
            maxi = exi;
        }
    }
    println!("{}", ex_msg[maxi]);
}

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

fn input_count() -> [u8; 3] {
    let mut buf = String::new();
    let mut body = [0; 3];
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|elem| elem.parse::<u8>().unwrap())
        .zip(0..)
        .for_each(|(a_i, i)| body[i % 3] += a_i);
    body
}

fn main() {
    {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
    }
    println!(
        "{}",
        input_count()
            .iter()
            .zip(["chest", "biceps", "back"].iter())
            .max()
            .unwrap()
            .1
    );
}


fn dir(c: char) -> i32 {
    match c {
        'v' => 0,
        '<' => 1,
        '^' => 2,
        '>' => 3,
        _ => panic!("Invalid character"),
    }
}

fn modu(a: i32) -> i32 {
    if a < 0 {
        a % 4 + 4
    } else {
        a % 4
    }
}

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

    std::io::stdin().read_line(&mut input).unwrap();

    let mut iter = input.chars();

    let start = iter.next().unwrap();
    iter.next().unwrap();
    let end = iter.next().unwrap();

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

    let mut it = input.split_whitespace().map(|x| x.parse::<i32>().unwrap());

    let n = it.next().unwrap();

    if n % 2 == 0 {
        println!("undefined");
    } else if n % 4 == modu(dir(end) - dir(start)) {
        println!("cw");
    } else {
        println!("ccw");
    }
}

fn read_line() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).expect(
        "Could not read line",
    );
    String::from(&line[..line.len() - 1])
}

macro_rules! read_line {
    (Vec<$t: ty>) => {{
        read_line().split_whitespace().map(|token| {
            <$t as std::str::FromStr>::from_str(token).expect(
                &format!(concat!("Could not parse {} into ", stringify!($t)), token))
        }).collect::<Vec<$t>>()
    }};
    ($($t: ty),*) => {{
        let line = read_line();
        let mut iter = line.split_whitespace();
        let result = ($({
            let token = iter.next().expect("Not enough tokens");
            <$t as std::str::FromStr>::from_str(token).expect(
                &format!(concat!("Could not parse {} into ", stringify!($t)), token))
        }),*);
        if let Some(token) = iter.next() {
            panic!("Unexpected token {}", token);
        }
        result
    }};
}

fn main() {
    let (s, f) = read_line!(String, String);
    let s = s.chars().nth(0).unwrap();
    let f = f.chars().nth(0).unwrap();
    let time = read_line!(usize);
    let all = ['v', '<', '^', '>'];
    let s = all.iter().enumerate().find(|x| *x.1 == s).unwrap().0;
    let f = all.iter().enumerate().find(|x| *x.1 == f).unwrap().0;
    let canCw = (s + time) % 4 == f;
    let canCcw = s == (f + time) % 4;
    println!(
        "{}",
        match (canCw, canCcw) {
            (false, false) => panic!("impossible"),
            (true, false) => "cw",
            (false, true) => "ccw",
            (true, true) => "undefined",
        }
    );
}

fn read_line() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).expect("EOF");
    line.pop();
    return line;
}

macro_rules! read_line {
    (Vec<$t: ty>) => {{
        read_line().split_whitespace().map(|token| {
            <$t as std::str::FromStr>::from_str(token).expect("Invalid token")
        }).collect<Vec<$t>>()
    }};
    ($($t: ty),*) => {{
        let line = read_line();
        let mut iter = line.split_whitespace();
        ($({
            let token = iter.next().expect("Too few tokens");
            <$t as std::str::FromStr>::from_str(token).expect("Invalid token")
        }), *)
    }};
}

fn spinner_position(c: char) -> i32 {
    match c {
        '^' => 0,
        '>' => 1,
        'v' => 2,
        '<' => 3,
        _ => -1,
    }
}

fn main() {
    let (s, t) = read_line!(String, String);
    let n = read_line!(i32) % 4;
    let x = spinner_position(s.chars().nth(0).expect(""));
    let y = spinner_position(t.chars().nth(0).expect(""));
    let d = (y - x + 4) % 4;
    if n % 2 == 0 {
        println!("undefined");
    } else if d == n {
        println!("cw");
    } else if d == 4 - n {
        println!("ccw");
    }
}

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

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

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

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

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

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

fn modu(x: i32, y: i32) -> i32 {
  let res = x % y;
  if res < 0 { res + y } else { res }
}

fn main() {
  scanln!(start: String, end: String);
  scanln!(rotations: i32);
  let start = match &start as &str {
    "^" => 0i32,
    ">" => 1i32,
    "v" => 2i32,
    "<" => 3i32,
    _ => unreachable!()
  };
  let end = match &end as &str {
    "^" => 0i32,
    ">" => 1i32,
    "v" => 2i32,
    "<" => 3i32,
    _ => unreachable!()
  };
  let cw = modu(start + (rotations % 4), 4);
  let ccw = modu(start - (rotations % 4), 4);
  if cw == end && ccw == end {
    println!("undefined");
  } else if cw == end {
    println!("cw");
  } else if ccw == end {
    println!("ccw");
  } else {
    println!("undefined");
  }
}

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

fn read_int() -> u64 {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).expect("Failed");
    let x = input.trim().parse::<u64>().unwrap();
    input.clear();
    x
}

fn main(){
    let s = read_string();
    let vec: Vec<&str> = s.split("").collect();
    let start_pos_as_char = vec[1].chars().next().unwrap() as u8;
    let end_pos_as_char = vec[3].chars().next().unwrap() as u8;
    let x = read_int();
    let cases = vec![118, 60, 94, 62]; // down left up right
    let sp = cases.iter().position(|&r| r == start_pos_as_char).unwrap();
    let ep = cases.iter().position(|&r| r == end_pos_as_char).unwrap();
    let is_even = ((x % 2) + 2) % 2;
    let result = (((x+sp as u64) % 4) + 4) % 4;
    if is_even == 0{
        println!("undefined");
    } else if (sp < 4) && (cases[result as usize] == end_pos_as_char) || (cases[result as usize] == end_pos_as_char) && (ep == 4){
        println!("cw");
    } else {
        println!("ccw");
    }

}

fn dir(c: char) -> i32 {
    match c {
        'v' => 0,
        '<' => 1,
        '^' => 2,
        '>' => 3,
        _ => panic!("Invalid character"),
    }
}

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

    std::io::stdin().read_line(&mut input).unwrap();

    let mut iter = input.chars();

    let start = iter.next().unwrap();
    iter.next().unwrap();
    let end = iter.next().unwrap();

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

    let mut it = input.split_whitespace().map(|x| x.parse::<i32>().unwrap());

    let n = it.next().unwrap();

    if n % 2 == 0 {
        println!("undefined");
    } else if n % 4 == (dir(end) - dir(start)) % 4 {
        println!("cw");
    } else {
        println!("ccw");
    }
}


use std::io::{self, BufWriter, Write};
use std::str::{self, SplitAsciiWhitespace};

// I have no idea what I'm doing

/// Copied from https://github.com/EbTech/rust-algorithms/blob/master/src/scanner.rs
/// Same API as Scanner but nearly twice as fast, using horribly unsafe dark arts
/// **REQUIRES** Rust 1.34 or higher
pub struct UnsafeScanner<R> {
    reader: R,
    buf_str: Vec<u8>,
    buf_iter: SplitAsciiWhitespace<'static>,
}

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

    /// This function should be marked unsafe, but noone has time for that in a
    /// programming contest. Use at your own risk!
    pub fn token<T: str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buf_iter.next() {
                return token.parse().ok().expect("Failed parse");
            }
            self.buf_str.clear();
            self.reader
                .read_until(b'\n', &mut self.buf_str)
                .expect("Failed read");
            self.buf_iter = unsafe {
                let slice = str::from_utf8_unchecked(&self.buf_str);
                std::mem::transmute(slice.split_ascii_whitespace())
            }
        }
    }

    pub fn pair<T: str::FromStr>(&mut self) -> (T, T) {
        (self.token(), self.token())
    }
}

fn main() -> Result<(), io::Error> {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let mut scan = UnsafeScanner::new(stdin.lock());
    let mut out = BufWriter::new(stdout.lock());

    let mut x: i32 = scan.token();
    let m: i32 = scan.token();

    x %= m;

    let mut seen = vec![false; m as usize];

    while x > 0 && !seen[x as usize] {
        seen[x as usize] = true;
        x += x;
        if x >= m {
            x -= m;
        }
    }

    writeln!(out, "{}", match x {
        0 => "Yes",
        _ => "No",
    })?;

    Ok(())
}

use std::io::{self, BufWriter, Write};
use std::str::{self, SplitAsciiWhitespace};

// I have no idea what I'm doing

/// Copied from https://github.com/EbTech/rust-algorithms/blob/master/src/scanner.rs
/// Same API as Scanner but nearly twice as fast, using horribly unsafe dark arts
/// **REQUIRES** Rust 1.34 or higher
pub struct UnsafeScanner<R> {
    reader: R,
    buf_str: Vec<u8>,
    buf_iter: SplitAsciiWhitespace<'static>,
}

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

    /// This function should be marked unsafe, but noone has time for that in a
    /// programming contest. Use at your own risk!
    pub fn token<T: str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buf_iter.next() {
                return token.parse().ok().expect("Failed parse");
            }
            self.buf_str.clear();
            self.reader
                .read_until(b'\n', &mut self.buf_str)
                .expect("Failed read");
            self.buf_iter = unsafe {
                let slice = str::from_utf8_unchecked(&self.buf_str);
                std::mem::transmute(slice.split_ascii_whitespace())
            }
        }
    }

    pub fn pair<T: str::FromStr>(&mut self) -> (T, T) {
        (self.token(), self.token())
    }
}

fn main() -> Result<(), io::Error> {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let mut scan = UnsafeScanner::new(stdin.lock());
    let mut out = BufWriter::new(stdout.lock());

    let mut x: u32 = scan.token();
    let mut m: u32 = scan.token();

    x >>= x.trailing_zeros();
    m >>= m.trailing_zeros();

    writeln!(out, "{}", if x % m == 0 { "Yes" } else { "No" })?;

    Ok(())
}

use std::io::{self, BufWriter, Write};
use std::str::{self, SplitAsciiWhitespace};

// I have no idea what I'm doing

/// Copied from https://github.com/EbTech/rust-algorithms/blob/master/src/scanner.rs
/// Same API as Scanner but nearly twice as fast, using horribly unsafe dark arts
/// **REQUIRES** Rust 1.34 or higher
pub struct UnsafeScanner<R> {
    reader: R,
    buf_str: Vec<u8>,
    buf_iter: SplitAsciiWhitespace<'static>,
}

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

    /// This function should be marked unsafe, but noone has time for that in a
    /// programming contest. Use at your own risk!
    pub fn token<T: str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buf_iter.next() {
                return token.parse().ok().expect("Failed parse");
            }
            self.buf_str.clear();
            self.reader
                .read_until(b'\n', &mut self.buf_str)
                .expect("Failed read");
            self.buf_iter = unsafe {
                let slice = str::from_utf8_unchecked(&self.buf_str);
                std::mem::transmute(slice.split_ascii_whitespace())
            }
        }
    }

    pub fn pair<T: str::FromStr>(&mut self) -> (T, T) {
        (self.token(), self.token())
    }
}

fn main() -> Result<(), io::Error> {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let mut scan = UnsafeScanner::new(stdin.lock());
    let mut out = BufWriter::new(stdout.lock());

    let mut x: i32 = scan.token();
    let mut m: i32 = scan.token();

    while m % 2 == 0 {
        m /= 2;
    }
    while x % 2 == 0 {
        x /= 2;
    }

    writeln!(out, "{}", if x % m == 0 { "Yes" } else { "No" })?;

    Ok(())
}


fn factorial(x: usize) -> usize {
    let mut result: usize = 1;
    for i in 1..=x {
        result *= i;
    }
    result
}

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 a: usize = scan.next();
    let b: usize = scan.next();
    println!("{}", factorial(a.min(b)));
}

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

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

fn factorial(n: u32) -> u32 {
    (1..=n).fold(1, |acc, x| acc * x)
}

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    let numbers: Vec<u32> = line
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect();
    let a = numbers[0];
    let b = numbers[1];
    let ans = factorial(min(a, b));
    println!("{}", ans);
}

fn fact(n: u32) -> u32 {
    if n == 1 {
        1
    } else {
        n * fact(n - 1)
    }
}

fn main() {
    let (a, b) = {
        let mut buf = String::with_capacity(3);
        std::io::stdin().read_line(&mut buf).unwrap();
        let nums: Vec<u32> = buf
            .trim()
            .split_whitespace()
            .map(|a| a.parse().unwrap())
            .collect();
        (nums[0], nums[1])
    };

    print!("{}", fact(a.min(b)));
}

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

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

    println!("{}", (1..1 + (input.i().min(input.i()) as i64))
             .product::<i64>());
}

use std::io;
use std::str::{FromStr, SplitWhitespace};
use std::fmt::Debug;
use std::iter::Map;
use std::cmp::min;

fn main() {
    let (a,b) = Input::line().pair();
    let res = (1..min::<u64>(a,b) + 1).fold(1, |ref x, i| x * i) ;
    println!("{}", res);

}

pub trait UParse: FromStr {
    fn uparse(&str) -> Self;
}
impl<T> UParse for T
where
    T: FromStr,
    T::Err: Debug,
{
    fn uparse(str: &str) -> Self {
        str.trim().parse().unwrap()
    }
}

pub struct Input(String);
impl Input {
    pub fn line() -> Input {
        let mut str = String::new();
        io::stdin().read_line(&mut str).unwrap();
        Input(str)
    }

    fn trim_parse<T: UParse>(s: &str) -> T {
        UParse::uparse(s)
    }

    pub fn iter<T: UParse>(&self) -> Map<SplitWhitespace, fn(&str) -> T> {
        self.0.split_whitespace().map(Input::trim_parse)
    }

    pub fn single<T: UParse>(&self) -> T {
        Input::trim_parse(self.0.as_ref())
    }

    pub fn pair<A: UParse, B: UParse>(&self) -> (A, B) {
        let mut it = self.0.split_whitespace();
        let a = Input::trim_parse(it.next().unwrap());
        let b = Input::trim_parse(it.next().unwrap());
        (a, b)
    }

    pub fn triple<A: UParse, B: UParse, C: UParse>(&self) -> (A, B, C) {
        let mut it = self.0.split_whitespace();
        let a = Input::trim_parse(it.next().unwrap());
        let b = Input::trim_parse(it.next().unwrap());
        let c = Input::trim_parse(it.next().unwrap());
        (a, b, c)
    }

    pub fn quadruple<A: UParse, B: UParse, C: UParse, D: UParse>(&self) -> (A, B, C, D) {
        let mut it = self.0.split_whitespace();
        let a = Input::trim_parse(it.next().unwrap());
        let b = Input::trim_parse(it.next().unwrap());
        let c = Input::trim_parse(it.next().unwrap());
        let d = Input::trim_parse(it.next().unwrap());
        (a, b, c, d)
    }
}

use std::io;
use std::str::{FromStr, SplitWhitespace};
use std::fmt::Debug;
use std::iter::Map;
use std::cmp::min;

fn main() {
    let (a,b) = Input::line().pair();
    let res = (1..min::<u32>(a,b) + 1).fold(1, |ref x, i| x * i) ;
    println!("{}", res);

}

pub trait UParse: FromStr {
    fn uparse(&str) -> Self;
}
impl<T> UParse for T
where
    T: FromStr,
    T::Err: Debug,
{
    fn uparse(str: &str) -> Self {
        str.trim().parse().unwrap()
    }
}

pub struct Input(String);
impl Input {
    pub fn line() -> Input {
        let mut str = String::new();
        io::stdin().read_line(&mut str).unwrap();
        Input(str)
    }

    fn trim_parse<T: UParse>(s: &str) -> T {
        UParse::uparse(s)
    }

    pub fn iter<T: UParse>(&self) -> Map<SplitWhitespace, fn(&str) -> T> {
        self.0.split_whitespace().map(Input::trim_parse)
    }

    pub fn single<T: UParse>(&self) -> T {
        Input::trim_parse(self.0.as_ref())
    }

    pub fn pair<A: UParse, B: UParse>(&self) -> (A, B) {
        let mut it = self.0.split_whitespace();
        let a = Input::trim_parse(it.next().unwrap());
        let b = Input::trim_parse(it.next().unwrap());
        (a, b)
    }

    pub fn triple<A: UParse, B: UParse, C: UParse>(&self) -> (A, B, C) {
        let mut it = self.0.split_whitespace();
        let a = Input::trim_parse(it.next().unwrap());
        let b = Input::trim_parse(it.next().unwrap());
        let c = Input::trim_parse(it.next().unwrap());
        (a, b, c)
    }

    pub fn quadruple<A: UParse, B: UParse, C: UParse, D: UParse>(&self) -> (A, B, C, D) {
        let mut it = self.0.split_whitespace();
        let a = Input::trim_parse(it.next().unwrap());
        let b = Input::trim_parse(it.next().unwrap());
        let c = Input::trim_parse(it.next().unwrap());
        let d = Input::trim_parse(it.next().unwrap());
        (a, b, c, d)
    }
}

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

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

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

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

fn main() {
    let (x,y) = readln!(i64,i64);
    let p = (1..=min(x,y)).product::<i64>();
    println!("{}",p);
}

use std::io::stdin;

fn read_n() -> (u32, u32) {
    let mut buffer = String::new();
    stdin().read_line(&mut buffer).unwrap();
    let snums: Vec<&str> = buffer.trim().split(" ").collect();
    (snums[0].parse::<u32>().unwrap(), snums[1].parse::<u32>().unwrap())
}

fn factorial(x: u32) -> u32 {
    let mut n: u32 = 1;
    for i in 2..x+1 {
        n *= i;
    }
    n
}

fn main() {
    let (a, b) = read_n();
    if a < b {
        println!("{}", factorial(a));
    } else {
        println!("{}", factorial(b));
    }
}

fn factorial(n: i32) -> i32 {
    if n == 0 {
        1
    } else {
        n * factorial(n - 1)
    }
}

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

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

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

    let mut iter = input.split_whitespace().map(|p| p.parse::<i32>().unwrap());

    let a = iter.next().unwrap();
    let b = iter.next().unwrap();

    let c = cmp::min(a, b);
    println!("{}", factorial(c));
}

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

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

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

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

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

fn main1() {
    let stdin = io::stdin();
    let mut input = Scanner::new(stdin.lock());
    let a: i64 = input.next();
    let b: i64 = input.next();
    let n = min(a, b);
    let answer = (1..(n + 1)).fold(1i64, |mul, x| mul * x);
    println!("{}", answer);

}

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

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

fn factorial(x: i32) -> i32 {
    if x < 2 {
        return 1;
    } else {
        return x * factorial(x - 1);
    }
}

fn main() {
    let reader = io::stdin();
    let numbers: Vec<i32> =
        reader.lock()                           // (0)
            .lines().next().unwrap().unwrap() // (1)
            .split(' ').map(|s| s.trim())     // (2)
            .filter(|s| !s.is_empty())        // (3)
            .map(|s| s.parse().unwrap())      // (4)
            .collect();                       // (5)

    let mut min= numbers[0];
    if numbers[1] < min {
        min = numbers[1];
    }

    println!("{}", factorial(min));
}

fn main() {
  use std::io;
  use std::cmp;

  fn factorial(n: usize) -> usize {
    let mut result = 1;
    for i in 2..(n+1) {
      result *= i;
    }
    result
  }

  let mut line = String::new();
  io::stdin().read_line(&mut line).unwrap();
  let mut ns = line.split(" ").map(|str| str.trim().parse::<usize>().unwrap());
  let a = ns.next().unwrap();
  let b = ns.next().unwrap();

  println!("{}", factorial(cmp::min(a, b)));
}

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

fn factorial(n: u32) -> u32 {
    (1..=n).fold(1, |acc, x| acc * x)
}

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    let numbers: Vec<u32> = line
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect();
    let a = numbers[0];
    let b = numbers[1];
    let ans = min(factorial(a), factorial(b));
    println!("{}", ans);
}

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

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

    println!("{}", (1..(input.i().min(input.i()) as i64))
             .product::<i64>());
}


use std::io;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    let nkx : Vec<usize> = line.trim().split(" ").map(|x| x.parse::<usize>().unwrap()).collect();
    let (n, k, x) : (usize, usize, usize) = (nkx[0], nkx[1], nkx[2]);

    line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    let my_deeds : Vec<usize> = line.trim().split(" ").map(|x| x.parse::<usize>().unwrap()).collect();

    let mut min_cost = 0;
    for i in 1..(n + 1) {
        if i <= k {
            min_cost += x;
        } else {
            min_cost += my_deeds[((n - i) as usize)];
        }
    }

    print!("{}", min_cost);
}

#[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, k, x): (usize, usize, usize) = util::get3();
    let a: Vec<usize> = util::gets();

    println!("{}", a[..n - k].iter().sum::<usize>() + k * x);
}

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

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

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

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

const N: i64 = 998_244_353;

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

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

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

    let ans = &a[..a.len() - k].iter().cloned().sum::<usize>() + k * x;

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