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

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

	let s = rin.vb();
	let n = s.len();
	let mut sol = 1000;
	for (y,x) in vec![(b'2',b'5'), (b'5',b'0'), (b'0',b'0')] {
		l!(mut px,py = n);
		for i in (0..n).rev() {
			if px == n && s[i] == x {
				px = i;
			} else if py == n && s[i] == y {
				py = i;
			}
		}
		if px < n && py < n {
			let mut res = 2*n - 3 - px - py;
			if px < py {
				res += 1;
			}
			min!(sol, res);
		}
	}
	if sol < 1000 {
		writeln!(rout, "{}", sol).ok();
	} else {
		writeln!(rout, "-1").ok();
	}
}


pub fn main() {
    let mut input = io::Input::new();
}

#[allow(unused)]
pub mod io {

    const BUFFER_SIZE: usize = 8192;

    use std::collections::VecDeque;
    use std::str::FromStr;
    use std::io;
    use std::io::Read;

    type AsciiStr = Vec<u8>;

    pub struct Input {
        token_buffer: VecDeque<String>,
        remaining: String,
    }

    impl Input {

        pub fn new() -> Input {
            Input {
                token_buffer: VecDeque::with_capacity(100),
                remaining: String::new(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T
            where T::Err: ::std::fmt::Debug
        {
            self.fill_buffer();
            self.token_buffer.pop_front().unwrap().parse().unwrap()
        }

        pub fn next_ascii_string(&mut self) -> AsciiStr {
            self.fill_buffer();
            Vec::from(self.token_buffer.pop_front().unwrap().as_bytes())
        }

        fn fill_buffer(&mut self) {
            while self.token_buffer.is_empty() {
                let mut minibuffer = [0u8; BUFFER_SIZE];
                let size = io::stdin().read(&mut minibuffer[..]).unwrap();

                self.remaining += &String::from_utf8_lossy(&minibuffer[..size]);

                if self.remaining.trim().len() > 0 {
                    for token in self.remaining.trim().split_whitespace() {
                        self.token_buffer.push_back(String::from(token))
                    }

                    if size > 0 && ! self.remaining.ends_with(|c: char|char::is_ascii_whitespace(&c)) {
                        self.remaining = self.token_buffer.pop_back().unwrap();
                    } else {
                        self.remaining.clear();
                    }

                } else if size == 0 {
                    panic!("EOF");
                }
            }
        }
    }
}


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

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

const INF: i32 = 1 << 29;

fn calc(n: &[char], pat: &[char]) -> i32 {
    let len = n.len();
    let mut mi = INF;
    for i in 0 .. len {
        if n[i] == '0' { continue; }
        for j in 0 .. len {
            if i == j || pat[0] != n[j] { continue; }
            for k in 0 .. len {
                if i == k || j == k || pat[1] != n[k] { continue; }
                let mut cost = 0;
                cost += i as i32;
                let mut x = if i < j { j } else { j + 1 } as i32;
                let mut y = if i < k { k } else { k + 1 } as i32;
                cost += (y - len as i32 + 1).abs();
                if x > y { x -= 1; }
                cost += (x - len as i32 + 2).abs();
                mi = min(mi, cost);
            }
        }
    }
    return mi;
}

fn solve() {
    let n: Vec<char> = get_word().chars().collect();
    let mut mi = INF;
    for pat in [['0', '0'], ['2', '5'], ['5', '0'], ['7', '5']].iter() {
        mi = min(mi, calc(&n, pat));
    }
    println!("{}", if mi == INF { -1 } else { mi });
}

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


#[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::io::prelude::BufRead;
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufReader, BufWriter, Write};
#[allow(unused_imports)]
use std::mem::swap;
#[allow(unused_imports)]
use std::str::FromStr;

fn main() {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let start;
    let end;
    {
        let line = buf.trim().split(":").collect::<Vec<_>>();
        start = line[0].parse::<usize>().unwrap() * 60 + line[1].parse::<usize>().unwrap();
    }
    buf.clear();
    stdin().read_line(&mut buf).unwrap();
    {
        let line = buf.trim().split(":").collect::<Vec<_>>();
        end = line[0].parse::<usize>().unwrap() * 60 + line[1].parse::<usize>().unwrap();
    }
    let mid = (start + end) / 2;
    let (h, m) = (mid / 60, mid % 60);
    println!("{}:{}", h, m);
}

#[allow(dead_code)]
fn read<T>() -> T
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    return buf.trim().parse().unwrap();
}

#[allow(dead_code)]
fn read_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::with_capacity(100);
    stdin().read_line(&mut buf).unwrap();
    return buf.split_whitespace().map(|s| s.parse().unwrap()).collect();
}

#[allow(dead_code)]
fn read_matrix<T>() -> Vec<Vec<T>>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    use std::io::prelude::*;
    let stdin = stdin();
    let mut reader = BufReader::with_capacity(100 * 1024, stdin);
    let mut line = String::with_capacity(100);
    let mut matrix: Vec<Vec<T>> = Vec::new();

    while reader.read_line(&mut line).unwrap() > 0 {
        matrix.push(
            line.trim()
                .split_whitespace()
                .map(|s| s.parse().unwrap())
                .collect(),
        );
        line.clear();
    }

    return matrix;
}

#[allow(dead_code)]
fn read_chars() -> Vec<char> {
    let stdin = stdin();
    let mut buf = String::new();
    let _bytes = stdin.read_line(&mut buf).unwrap();
    return buf.trim().chars().collect();
}


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 mut input: usize = scan.next();
    let mut result = true;
    let mut count4 = 0usize;
    let mut first = true;
    while input > 0 {
        let digit = input % 10;
        input /= 10;
        if digit == 4 {
            count4 += 1;
            if count4 > 2 || first {
                result = false;
                break;
            }
        } else if digit == 1 {
            count4 = 0;
        } else {
            result = false;
            break;
        }
        first = false;
    }
    println!("{}", if result { "YES" } else { "NO" });
}

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


fn input() -> u64 {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

fn main() {
    let n = input();
    let (mut sum_a, mut sum_b) = (0u64, 0u64);
    for i in (1..=n).rev() {
        if sum_a < sum_b {
            sum_a += i;
        } else {
            sum_b += i;
        }
    }
    // dbg!(sum_a, sum_b);
    print!("{}", sum_a.max(sum_b) - sum_a.min(sum_b))
}


use std::io;

fn main() {
    let n: u64 = {
        let mut read_buf = String::new();
        io::stdin().read_line(&mut read_buf).unwrap();
        read_buf.trim().parse().unwrap()
    };
    if n == 1 {
        println!("1");
    } else if n == 2 {
        println!("1");
    } else if n == 3 {
        println!("0");
    } else if n % 2 == 0 {
        println!("0");
    } else {
        println!("1");
    }
}


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' if prev_ch == '0' => {
	     					print!("0");
	     				}
	     				'0' => {
	     					print!("{}", num);
	     					num = 0;
	     				}
	     				_ => panic!("SOS"),
     				}
     				prev_ch = ch;
     			}
     			if num > 0 {
	     			println!("{}", num);
     			}
     		}
     		_ => {
     			panic!("SOS");
     		}
     	}
     	lc += 1;
     }
}


use std::io;

fn main() {
    io::stdin().read_line(&mut String::new()).expect("");
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut ans = String::new();
    let mut cnt = 0;
    for c in s.trim().chars() {
        if c == '0' {
            if cnt > 0 {
                ans += &cnt.to_string();
                cnt = 0;
            }
            ans.push_str("0");
            continue;
        }
        cnt += 1;
    }
    if cnt > 0 {
        ans += &cnt.to_string();
    }
    println!("{}", ans);
}


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 is_match(pat: &str, text: &str) -> bool {
    pat.chars().zip(text.chars())
        .all(|(p, t)| p == '.' || t == p)
}

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 pool: Vec<_> = "vaporeon jolteon flareon espeon umbreon leafeon glaceon and sylveon"
        .split_ascii_whitespace()
        .collect();

    let _n: usize = scan.token();
    let s: String = scan.token();

    writeln!(out, "{}", pool.into_iter().filter(|t| is_match(&s, t)).next().unwrap())?;

    Ok(())
}


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

fn main() {
    let mut buf = String::new();
    io::stdin().read_to_string(&mut buf).expect("Error");
    let lines = buf.lines();
    let mut ship1 = Ship { w: 0, h: 0 };
    let mut ship2 = Ship { w: 0, h: 0 };
    for line in lines {
        let st = &mut line.split_whitespace();
        ship1.set_wh(get_value(st), get_value(st));
        ship2.set_wh(get_value(st), get_value(st));
    }
    println!("{}",ship1_area(&ship1, &ship2));
    println!("{}",ship2_area(&ship1, &ship2));

    println!(
        "{}",
        ship1_area(&ship1, &ship2) + ship2_area(&ship1, &ship2)
    )
}

fn ship1_area(ship1: &Ship, ship2: &Ship) -> u8 {
    let mut a = ship1.get_full_area() - (ship2.get_w() + 3);
    if ship2.get_w() >= ship1.get_w() {
        a -= 1;
    }
    a
}

fn ship2_area(ship1: &Ship, ship2: &Ship) -> u8 {
    if ship2.get_w() < ship1.get_w() {
        ship2.get_full_area() - (ship2.get_w()+1)
    } else {
        ship2.get_full_area() - ship1.get_w()
    }
}

fn get_value(ws: &mut SplitWhitespace) -> u8 {
    ws.next().unwrap().parse::<u8>().unwrap()
}

struct Ship {
    w: u8,
    h: u8,
}

impl Ship {
    fn set_wh(&mut self, w: u8, h: u8) {
        self.h = h;
        self.w = w;
    }

    fn get_w(&self) -> u8 {
        self.w
    }

    fn get_full_area(&self) -> u8 {
        (self.w * 2 + self.h * 2) + 4
    }
}


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

fn main() {
    let mut buf = String::new();
    io::stdin().read_to_string(&mut buf).expect("Error");
    let lines = buf.lines();
    let mut ship1 = Ship { w: 0, h: 0 };
    let mut ship2 = Ship { w: 0, h: 0 };
    for line in lines {
        let st = &mut line.split_whitespace();
        ship1.set_wh(get_value(st), get_value(st));
        ship2.set_wh(get_value(st), get_value(st));
    }
    //println!("{}",ship1_area(&ship1, &ship2));
    //println!("{}",ship2_area(&ship1, &ship2));

    println!(
        "{}",
        ship1_area(&ship1, &ship2) + ship2_area(&ship1, &ship2)
    )
}

fn ship1_area(ship1: &Ship, ship2: &Ship) -> u8 {
    let mut a = ship1.get_full_area() - (ship2.get_w() + 3);
    if ship2.get_w() >= ship1.get_w() {
        a -= 1;
    }
    a
}

fn ship2_area(ship1: &Ship, ship2: &Ship) -> u8 {
    if ship2.get_w() < ship1.get_w() {
        ship2.get_full_area() - (ship2.get_w()+1)
    } else {
        ship2.get_full_area() - ship1.get_w()
    }
}

fn get_value(ws: &mut SplitWhitespace) -> u8 {
    ws.next().unwrap().parse::<u8>().unwrap()
}

struct Ship {
    w: u8,
    h: u8,
}

impl Ship {
    fn set_wh(&mut self, w: u8, h: u8) {
        self.h = h;
        self.w = w;
    }

    fn get_w(&self) -> u8 {
        self.w
    }

    fn get_full_area(&self) -> u8 {
        (self.w * 2 + self.h * 2) + 4
    }
}


use std::io;

fn f(n: i64, l: i64, r: i64, t: i32, w: i32) -> i64 {
    let mut result = 0;
        if(n < r) {
            if(n >= l) {
                result += 1;
            }
            if(w == 0) {
                result += f(2*n, l, r, t+1, w);
            }
            result += f(3*n, l , r, t, w+1);
        }
    return result;
}

macro_rules! parse_line {
    ($($t: ty),+) => ({
        let mut a_str = String::new();
        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"),
            )+
        )
    })
}

fn main() {
    let (a, b) = parse_line!(i64, i64);

	let mut cnt = f(1, a, b, 0, 0);
	println!("{}", cnt);
}


#[allow(unused_imports)]
use std::io;
use std::cmp::{min, max};
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 d = input.next_vec::<i64>(3);
    println!("{}", min(d[0] + d[1] + d[2], 2 * (d[0] + d[1])))
}

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


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 next_n<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.next::<T>()).collect()
    }

}

fn _main() {
    let mut scan = Scan::new();
    let d1: usize = scan.next();
    let d2: usize = scan.next();
    let d3: usize = scan.next();
    let result = (d1+d2+d3).min((d1+d2)*2).min(d1*2+d3*2);
    println!("{}", result);
}

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


#![allow(unused_imports, unused_variables, dead_code, non_snake_case, unused_macros)]
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

fn getline() -> String{
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
}

macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

macro_rules! mvec {
    ($v: expr, $s: expr) => {
        vec![$v; $s]
    };
    ($v: expr, $s: expr, $($t: expr),*) => {
        vec![mvec!($v, $($t),*); $s]
    };
}

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

fn printiter<'a, T>(v: &'a T)
where
    &'a T: std::iter::IntoIterator,
    <&'a T as std::iter::IntoIterator>::Item: std::fmt::Display {
    for (i,e) in v.into_iter().enumerate() {
        if i != 0 {
            print!(" ");
        }
        print!("{}", e);
    }
    println!("");
}

struct ContestPrinter {
    s: String,
}

impl ContestPrinter {
    fn new() -> ContestPrinter {
        ContestPrinter {
        s: String::new(),
        }
    }

    fn print<T>(&mut self, x: T)
        where T: std::fmt::Display {
        self.s.push_str(format!("{}", x).as_str());
    }

    fn println<T>(&mut self, x: T)
        where T: std::fmt::Display {
        self.s.push_str(format!("{}\n", x).as_str());
    }
}

impl std::ops::Drop for ContestPrinter {
    fn drop(&mut self) {
        print!("{}", self.s);
    }
}

fn main() {
    let mut printer = ContestPrinter::new();

    let (mut L, mut R, mut A) = readl!(i32, i32, i32);
    if L > R {
        R += A;
    } else {
        L += A;
    }
    while (L - R).abs() > 1 {
        if (L == 0) | (R == 0) { break; }
        if L > R {
            L -= 1;
            R += 1;
        } else {
            R -= 1;
            L += 1;
        }
    }
    printer.println(2 * min(L, R));
}


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

fn main() {
    "abc".split_whitespace();
    let mut input = String::new();
    io::stdin().read_line(&mut input);
    let mut iter = input.split_whitespace();
    let distance: i64 = iter.next().expect("distance expected").parse().expect("integer distance expected");
    let km_per_stop: i64 = iter.next().expect("km_per_stop expected").parse().expect("integer km_per_stop expected");
    let car_km_time: i64 = iter.next().expect("car_km_time expected").parse().expect("car_km_time distance expected");
    let walk_km_time: i64 = iter.next().expect("walk_km_time expected").parse().expect("walk_km_time distance expected");
    let repair_time: i64 = iter.next().expect("repair_time expected").parse().expect("repair_time distance expected");

    let trip_time;
    let car_cost : i64 = car_km_time * km_per_stop - walk_km_time * km_per_stop + repair_time;
    if car_cost >= 0 {
        let car_dist = cmp::min(km_per_stop, distance);
        let walk_dist = distance - car_dist;
        trip_time = car_dist * car_km_time + walk_dist * walk_km_time;
    } else {
        let full_stops = distance / km_per_stop;
        let distance_cost = (full_stops * km_per_stop) * car_km_time;
        let repair_cost = (full_stops - 1) * repair_time;
        let full_stops_cost = distance_cost + repair_cost;

        let remaining_dist = distance % km_per_stop;
        let remaining_walk = remaining_dist * walk_km_time;
        let remaining_car = remaining_dist * car_km_time + repair_time;
        let remaining_cost = cmp::min(remaining_walk, remaining_car);

        trip_time = full_stops_cost + remaining_cost;
    }
    println!("{}", trip_time);

}


fn main() {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).expect("input: read line failed");
    let vec = input.trim().split_whitespace().map(|item| {
        item.parse::<i32>().expect("item: parse to i32 failed")
    }).collect::<Vec<i32>>();

    let (mut width, mut height, mut rings) = (vec[0], vec[1], vec[2]);

    let mut amount = i32::default();

    while rings > 0 {
        amount += (width + height) * 2 - 4;
        width -= 2;
        height -= 2;
        rings -= 1;
    }

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


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

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

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

    let a = input.i();
    let b = input.i();
    let c = input.i();
    let d = b - a;
    if d == 0 || (d % c == 0 && d / c > 0) {
        println!("YES");
    } else {
        println!("NO");
    }
}


fn check_row(v: Vec<u8>) {
    let mut count = 0;
    let mut hole = false;
    for c in v {
        match (c, hole) {
            (0, false) => {if count != 0 { count += 1; hole = true }},
            (0, true) => {count = 0; hole = false},
            (1, _) => count += 1,
            (2, _) => count = 0,
            (_, _) => panic!("Invalid grid value"),
        }
        if count == 5 {
            println!("YES");
            std::process::exit(0);
        }
    }
}

fn main() {
    let mut grid: Vec<u8> = Vec::with_capacity(100);

    for _ in 0..10 {
        let mut input = String::new();
        std::io::stdin().read_line(&mut input).unwrap();
        for c in input.trim().chars() {
            match c {
                '.' => grid.push(0),
                'X' => grid.push(1),
                'O' => grid.push(2),
                _ => panic!("Invalid character"),
            }
        }
    }

    for i in 0..10 {
        let it = (0..100).filter_map(|k| if k / 10 == i {Some(grid[k])} else {None});
        check_row(it.collect());

        let it = (0..100).filter_map(|k| if k % 10 == i {Some(grid[k])} else {None});
        check_row(it.collect());
    }

    for i in 0..6 {
        check_row((i..10).zip(0..(10 - i)).map(|(i, j)| grid[10 * i + j]).collect());
        check_row((i..10).zip(0..(10 - i)).map(|(i, j)| grid[10 * j + i]).collect());
        check_row((i..10).zip((i..10).rev()).map(|(i, j)| grid[10 * j + i]).collect());
    }

    for i in 4..10 {
        check_row((0..(i + 1)).rev().zip(0..(i + 1)).map(|(i, j)| grid[10 * i + j]).collect());
    }

    println!("NO");
}


use std::io;

fn main() -> io::Result<()> {
    let coins = [100, 20, 10, 5, 1];
    let mut input = String::new();
    let mut ans = 0;
    let mut dollars;

    loop {
        ans = 0;

        if io::stdin().read_line(&mut input)? == 0 {
            break Ok(());
        }

        dollars = input.trim().parse::<u32>().unwrap();
        input.clear();

        for coin in &coins {
            ans += dollars / coin;
            dollars %= coin;

            if dollars == 0 {
                break;
            }
        }

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


use std::io;

fn main() -> io::Result<()> {
    let mut input = String::new();
    let mut table = Vec::new();
    let mut ans = 0;
    let mut total = 0;
    let mut length: usize = 0;

    while io::stdin().read_line(&mut input)? != 0 {
        for chr in input.chars() {
            match chr {
                'Q' => {
                    if length == 0 {
                        table.push(0);
                        length += 1;
                        continue;
                    }
                    ans += total;
                    let mut t = total;
                    for num in &table {
                        t -= num;
                        ans += t;
                    }
                    if table[length - 1] != 0 {
                        table.push(0);
                        length += 1;
                    }
                }
                'A' => {
                    if length != 0 {
                        table[length - 1] += 1;
                        total += 1;
                    }
                }
                _ => (),
            }
        }

        println!("{}", ans);
        input.clear();
        table.clear();
        ans = 0;
        total = 0;
        length = 0;
    }

    Ok(())
}


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

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

  if b == 0 {
    return a;
  }

  if a == b {
    return a;
  }

  if a>b {
    return gcd(a-b, b);
  }

  return gcd(a, b-a)

}
fn solve<R: BufRead, W: Write>(mut input: FastInput<R>, mut w: W) {
    let a: i32 = input.token();
    let b: i32 = input.token();
    let mut x: i32 = input.token();
    let mut y: i32 = 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!(i32);


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

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

  if b == 0 {
    return a;
  }

  if a == b {
    return a;
  }

  if a>b {
    return gcd(a-b, b);
  }

  return gcd(a, b-a)

}
fn solve<R: BufRead, W: Write>(mut input: FastInput<R>, mut w: W) {
    let a: i32 = input.token();
    let b: i32 = input.token();
    let mut x: i32 = input.token();
    let mut y: i32 = input.token();
    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!(i32);


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

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

  if b == 0 {
    return a;
  }

  if a == b {
    return a;
  }

  if a>b {
    return gcd(a-b, b);
  }

  return gcd(a, b-a)

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


#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

#[allow(unused_macros)]
macro_rules! invec {
    ( $ t : ty ) => {{
        let mut s = String::new();
        match std::io::stdin().read_line(&mut s) {
            Ok(0) => Vec::<$t>::new(),
            Ok(n) => s
                .trim()
                .split_whitespace()
                .map(|s| s.parse::<$t>().unwrap())
                .collect::<Vec<$t>>(),
            Err(_) => Vec::<$t>::new(),
        }
    }};
}

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

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut 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)*}
    };
    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

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

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

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

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

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = i64::max_value() / 2;
#[allow(dead_code)]
static INF_I32: i32 = i32::max_value() / 2;
#[allow(dead_code)]
static INF_USIZE: usize = usize::max_value() / 2;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    let s = get!(String).chars().toVec();
    let s2 = get!(String).chars().toVec();
    mydbg!(s, s2);
    let mut a = true;
    let mut b = true;

    let mut h = vec![0; 26];
    let mut h2 = vec![0; 26];

    let mut cur = 0;
    for &c in &s2 {
        a = false;
        while cur < s.len() {
            if s[cur] == c {
                a = true;
                break;
            }
            cur += 1;
        }
    }

    if a {
        echo!("automaton");
        return;
    }
    a = true;
    if s.len() <= s2.len() {
        a = false;
    }

    for &c in &s {
        let c = c as usize - 'a' as usize;
        h[c] += 1;
    }
    for &c in &s2 {
        let c = c as usize - 'a' as usize;
        h2[c] += 1;
    }

    for i in 0..26 {
        if h[i] != h2[i] {
            b = false;
        }
    }

    if b {
        echo!("array");
        return;
    }
    b = true;
    for i in 0..26 {
        if h[i] < h2[i] {
            b = false;
        }
    }
    if a && b {
        echo!("both");
        return;
    }
    echo!("need tree");
}


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(),
            )+
        )
    }}
}

fn main() {
    let length = readln!(usize);

    if length % 2 == 0 {
        println!("{}", length);
    } else {
        println!("0");
    }
}


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

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

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

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

    (v[0], v[1], v[2], v[3])
}

fn main() {
    let (a, b, c, d) = get_nums();

    let misha = std::cmp::max(3 * a / 10, a / 250 * c);
    let vasya = std::cmp::max(3 * b / 10, b / 250 * d);

    if misha > vasya {
        println!("Misha");
    } else if misha < vasya {
        println!("Vasya");
    } else {
        println!("Tie");
    }
}


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

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

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

fn fact(n: u64) -> u64 {
    (1..=n).product()
}

fn run() {
    input! {
        n: u64,
    }
    let mut ans = fact(n) / fact(n / 2) / fact(n / 2) / 2;
    if n / 2 > 3 {
        ans *= (fact(n / 2  - 1)).pow(2);
    }
    println!("{}", ans);
}

fn main() {
    run();
}


//! https://codeforces.com/problemset/problem/630/I
//! To quickly hire highly skilled specialists one of the new IT City companies made an unprecedented move. Every employee was granted a car, and an employee can choose one of four different car makes.
//! The parking lot before the office consists of one line of (2n - 2) parking spaces. Unfortunately the total number of cars is greater than the parking lot capacity. Furthermore even amount of cars of each make is greater than the amount of parking spaces! That's why there are no free spaces on the parking lot ever.
//! Looking on the straight line of cars the company CEO thought that parking lot would be more beautiful if it contained exactly n successive cars of the same make. Help the CEO determine the number of ways to fill the parking lot this way.
use std::io;

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

    let ans: u64 = (inp -2 ) * 6 * binexp(4, inp - 2);
    println!("{}", ans);
}

fn binexp(mut x: u64, mut y: u64) -> u64 {
    let mut res = 1;
    while y != 0 {
        if y & 1 == 1 {
            res *= x;
        }
        x*=x;
        y>>=1;
    }
    res
}


use std::io;

fn steps(dist: i32, counter: &mut i32) -> &i32 {
    match dist {
        dist if dist <= 0 => (),
        dist if dist % 5 == 0 => {
            *counter += 1;
            steps(dist - 5, counter);
        }
        dist if dist % 4 == 0 => {
            *counter += 1;
            steps(dist - 4, counter);
        }
        dist if dist % 3 == 0 => {
            *counter += 1;
            steps(dist - 3, counter);
        }
        dist if dist % 2 == 0 => {
            *counter += 1;
            steps(dist - 2, counter);
        }
        dist if dist % 1 == 0 => {
            *counter += 1;
            steps(dist - 1, counter);
        }
        _ => (),
    }
    counter
}

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

    let mut counter = 0;

    println!("{}", steps(buffer.trim().parse().unwrap(), &mut counter));
}


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

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let distance = BufReader::new(std::io::stdin())
        .lines()
        .map(Result::unwrap)
        .next()
        .unwrap()
        .parse::<usize>()?;

    println!("{}", distance / 5 + 1);
    Ok(())
}


fn main() {
    let mut text = String::new();
    std::io::stdin().read_line(&mut text).expect("");
    println!("{}", resolver(text.trim().parse().expect("msg: &str"), 0));
}

fn resolver(value: usize, step: usize) -> usize {
    if value == 1 {
        step + 1
    } else if value % 5 == 0 {
        (value / 5) + step
    } else if value % 4 == 0 {
        (value / 4) + step
    } else if value % 3 == 0 {
        (value / 3) + step
    } else if value % 2 == 0 {
        (value / 2) + step
    } else {
        resolver(value - 5, step + 1)
    }
}


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

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

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

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

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

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

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

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

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

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

impl std::str::FromStr for ModInt {
    type Err = std::num::ParseIntError;
    fn from_str(s: &str) -> Result<Self, Self::Err> {
        let val = s.parse::<u32>()?;
        Ok(ModInt::new(val))
    }
}

impl From<usize> for ModInt {
    fn from(val: usize) -> ModInt {
        ModInt((val % MOD as usize) as u32)
    }
}

#[allow(dead_code)]
impl ModInt {
    pub fn new(n: u32) -> ModInt {
        ModInt(n % MOD)
    }
    pub fn zero() -> ModInt {
        ModInt(0)
    }
    pub fn one() -> ModInt {
        ModInt(1)
    }
    pub fn pow(self, mut n: u32) -> ModInt {
        let mut t = ModInt::one();
        let mut s = self;
        while n > 0 {
            if n & 1 == 1 {
                t *= s;
            }
            s *= s;
            n >>= 1;
        }
        t
    }
    pub fn inv(self) -> ModInt {
        assert!(self.0 > 0);
        self.pow(MOD - 2)
    }
}
// ---------- end ModInt ----------
// ---------- begin Precalc ----------
#[allow(dead_code)]
struct Precalc {
    inv: Vec<ModInt>,
    fact: Vec<ModInt>,
    ifact: Vec<ModInt>,
}

#[allow(dead_code)]
impl Precalc {
    pub fn new(n: usize) -> Precalc {
        let mut inv = vec![ModInt::one(); n + 1];
        let mut fact = vec![ModInt::one(); n + 1];
        let mut ifact = vec![ModInt::one(); n + 1];
        for i in 2..(n + 1) {
            inv[i] = -inv[MOD as usize % i] * ModInt(MOD / i as u32);
            fact[i] = fact[i - 1] * ModInt(i as u32);
            ifact[i] = ifact[i - 1] * inv[i];
        }
        Precalc {
            inv: inv,
            fact: fact,
            ifact: ifact,
        }
    }
    pub fn inv(&self, n: usize) -> ModInt {
        self.inv[n]
    }
    pub fn fact(&self, n: usize) -> ModInt {
        self.fact[n]
    }
    pub fn ifact(&self, n: usize) -> ModInt {
        self.ifact[n]
    }
    pub fn comb(&self, n: usize, k: usize) -> ModInt {
        if k > n {
            return ModInt::zero();
        }
        self.fact[n] * self.ifact[k] * self.ifact[n - k]
    }
}
// ---------- end Precalc ----------
// ---------- begin Aho-Corasick ----------
const F: usize = 2;

fn convert(s: Vec<char>) -> Vec<usize> {
    let mut a = Vec::with_capacity(s.len());
    for c in s {
        let k = c.to_digit(10).unwrap() as usize;
        a.push(k);
    }
    a
}

struct ACTrieNode {
    elem: bool,
    fail: usize,
    depth: usize,
    next: [usize; F],
}

impl ACTrieNode {
    fn new() -> ACTrieNode {
        ACTrieNode {
            elem: false,
            fail: 0,
            depth: 0,
            next: [0; F],
        }
    }
}

struct AhoCorasick {
    node: Vec<ACTrieNode>,
}

#[allow(dead_code)]
impl AhoCorasick {
    fn new() -> Self {
        let root = ACTrieNode::new();
        AhoCorasick {
            node: vec![root],
        }
    }
    fn insert(&mut self, s: &Vec<usize>) -> usize {
        let node = &mut self.node;
        let mut v = 0;
        for &k in s {
            if node[v].next[k] == 0 {
                node[v].next[k] = node.len();
                let mut t = ACTrieNode::new();
                t.depth = node[v].depth + 1;
                node.push(t);
            }
            v = node[v].next[k];
        }
        node[v].elem = true;
        v
    }
    fn build(&mut self) {
        let mut q = std::collections::VecDeque::new();
        let node = &mut self.node;
        for i in 0..F {
            if node[0].next[i] != 0 {
                q.push_back(node[0].next[i]);
            }
        }
        while let Some(v) = q.pop_front() {
            for i in 0..F {
                let u = node[v].next[i];
                if u == 0 {
                    continue;
                }
                let mut fail = node[v].fail;
                while fail > 0 && node[fail].next[i] == 0 {
                    fail = node[fail].fail;
                }
                let f = node[fail].next[i];
                node[u].fail = f;
                q.push_back(u);
            }
        }
    }
    fn next(&self, v: usize, k: usize) -> usize {
        self.node[v].next[k]
    }
    fn trans(&self, mut v: usize, k: usize) -> usize {
        let node = &self.node;
        while v > 0 && node[v].next[k] == 0 {
            v = node[v].fail;
        }
        node[v].next[k]
    }
    fn elem(&self, k: usize) -> bool {
        self.node[k].elem
    }
    fn fail(&self, k: usize) -> usize {
        self.node[k].fail
    }
    fn depth(&self, k: usize) -> usize {
        self.node[k].depth
    }
    fn get_size(&self) -> usize {
        self.node.len()
    }
}
// ---------- end Aho-Corasick ----------
// ---------- begin Matrix ----------
#[allow(dead_code)]
mod matrix {
    use std::ops::{Add, Mul};
    pub trait SemiRing: Add<Output = Self> + Mul<Output = Self> + Copy {
        fn zero() -> Self;
        fn one() -> Self;
    }
    pub const SIZE: usize = 202;
    #[derive(Clone)]
    pub struct SquareMatrix<T: SemiRing> {
        buf: [[T; SIZE]; SIZE],
    }
    impl<T: SemiRing> SquareMatrix<T> {
        pub fn zero() -> Self {
            let z = T::zero();
            SquareMatrix {
                buf: [[z; SIZE]; SIZE],
            }
        }
        pub fn identity() -> Self {
            let mut m = Self::zero();
            for i in 0..SIZE {
                m.buf[i][i] = T::one();
            }
            m
        }
        pub fn set_at(&mut self, i: usize, j: usize, v: T) {
            self.buf[i][j] = v;
        }
        pub fn get_at(&self, i: usize, j: usize) -> T {
            self.buf[i][j]
        }
        pub fn matmul(&self, rhs: &Self) -> Self {
            let mut res = Self::zero();
            for (x, a) in res.buf.iter_mut().zip(self.buf.iter()) {
                for (a, b) in a.iter().zip(rhs.buf.iter()) {
                    for (x, b) in x.iter_mut().zip(b.iter()) {
                        *x = *x + *a * *b;
                    }
                }
            }
            res
        }
        pub fn matadd(&self, rhs: &Self) -> Self {
            let mut c = Self::zero();
            for (c, (a, b)) in c.buf.iter_mut().zip(self.buf.iter().zip(rhs.buf.iter())) {
                for (c, (a, b)) in c.iter_mut().zip(a.iter().zip(b.iter())) {
                    *c = *a + *b;
                }
            }
            c
        }
        pub fn matpow(&self, mut n: usize) -> Self {
            let mut t = Self::identity();
            let mut s = self.clone();
            while n > 0 {
                if n & 1 == 1 {
                    t = t.matmul(&s);
                }
                s = s.matmul(&s);
                n >>= 1;
            }
            t
        }
    }
}
// ---------- end Matrix ----------
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

// ここまで

use matrix::*;

impl SemiRing for ModInt {
    fn zero() -> Self {
        ModInt::zero()
    }
    fn one() -> Self {
        ModInt::one()
    }
}

fn run() {
    input! {
        n: usize,
        x: usize,
        s: chars,
    }
    let s = convert(s);
    let mut aho = AhoCorasick::new();
    aho.insert(&s);
    aho.build();
    type M = SquareMatrix<ModInt>;
    let mut zero = M::identity();
    for i in 0..=n {
        let v = aho.trans(i, 0);
        let u = zero.get_at(v, i);
        zero.set_at(v, i, u + ModInt::one());
        let u = zero.get_at(n + 1 + v, n + 1 + i);
        zero.set_at(n + 1 + v, n + 1 + i, u + ModInt::one());
        if v == n {
            let u = zero.get_at(n + 1 + v, i);
            zero.set_at(n + 1 + v, i, u + ModInt::one());
        }
    }
    /*
    println!("zero");
    for i in 0..(2 * n + 2) {
        for j in 0..(2 * n + 2) {
            print!("{} ", zero.get_at(i, j));
        }
        println!();
    }
    println!();
    */
    let mut one = M::identity();
    for i in 0..=n {
        let v = aho.trans(i, 1);
        let u = one.get_at(v, i);
        one.set_at(v, i, u + ModInt::one());
        let u = one.get_at(n + 1 + v, n + 1 + i);
        one.set_at(n + 1 + v, n + 1 + i, u + ModInt::one());
        if v == n {
            let u = one.get_at(n + 1 + v, i);
            one.set_at(n + 1 + v, i, u + ModInt::one());
        }
    }
    /*
    println!("one");
    for i in 0..(2 * n + 2) {
        for j in 0..(2 * n + 2) {
            print!("{} ", one.get_at(i, j));
        }
        println!();
    }
    println!();
    */
    let mut dp = vec![];
    dp.push(zero);
    dp.push(one);
    for i in 2..=x {
        let v = dp[i - 2].matmul(&dp[i - 1]);
        dp.push(v);
    }
    /*
    for i in 0..(2 * n + 2) {
        for j in 0..(2 * n + 2) {
            print!("{} ", dp[x].get_at(i, j));
        }
        println!();
    }
    */
    let mut ans = ModInt::zero();
    for k in 0..=n {
        ans += dp[x].get_at(n + 1 + k, 0);
    }
    println!("{}", ans);
}

fn main() {
    run();
}


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

mod lib {
pub fn bam() {
    println!("Hi!")
}
}

fn is_square(n: u32) -> bool {
    let mut l: u64 = 1;
    let mut r: u64 = 60000;
    while r - l > 1 {
        let m = (r + l) / 2;
        if m * m > 0 && m * m <= n as u64 {
            l = m
        } else {
            r = m
        }
    }
    return l * l == n as u64;
}

fn recurse<F : FnMut(u32)>(n: u32, mut f: F) {
    if n < 10 {
        return;
    }

    let mut pow10: u64 = 1;
    while (n as u64) >= pow10 {
        if pow10 * 10 > (n as u64) && ((n as u64) % pow10 < pow10 / 10) {
            continue
        }
        f(((n as u64 / (pow10 * 10) * pow10) + (n as u64 % pow10)) as u32);

        pow10 *= 10;
    }
}

fn get(n: u32, xs: &mut Vec<Option<Option<u32>>>) -> Option<u32> {
    if xs[n as usize].is_none() {
        if is_square(n) {
            xs[n as usize] = Some(Some(0));
        } else {
            let mut result: Option<u32> = None;
            recurse(n, |n_rm| {
                if let Some(k_rm) = get(n_rm, xs) {
                    result = result.map_or(
                        Some(k_rm + 1), |k| Some(cmp::min(k, k_rm + 1))
                    );
                }
            });
            xs[n as usize] = Some(result);
        }
    }
    return xs[n as usize].unwrap();
}

fn main() {
    let stdin = io::stdin();
    let mut input = stdin.lock().lines().flat_map(
        |x| x.unwrap().split_whitespace().map(|x| x.to_string()).collect::<Vec<_>>()
    );
    let n: u32 = input.next().unwrap().parse().unwrap();

    let mut array: Vec<_> = iter::repeat(None).take(100000).collect();
    if let Some(k) = get(n, &mut array) {
        println!("{}", k);
    } else {
        println!("-1");
    }
}


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

mod lib {
pub fn bam() {
    println!("Hi!")
}
}

fn is_square(n: u32) -> bool {
    let mut l: u64 = 1;
    let mut r: u64 = 60000;
    while r - l > 1 {
        let m = (r + l) / 2;
        if m * m > 0 && m * m <= n as u64 {
            l = m
        } else {
            r = m
        }
    }
    return l * l == n as u64;
}

fn recurse<F : FnMut(u32)>(n: u32, mut f: F) {
    if n < 10 {
        return;
    }

    let mut pow10: u64 = 1;
    while (n as u64) >= pow10 {
        if pow10 * 10 > (n as u64) && ((n as u64) % pow10 < pow10 / 10) {
            continue
        }
        f(((n as u64 / (pow10 * 10) * pow10) + (n as u64 % pow10)) as u32);

        pow10 *= 10;
    }
}

fn get(n: u32, xs: &mut Vec<Option<Option<u32>>>) -> Option<u32> {
    if n as usize >= xs.len() || xs[n as usize].is_none() {
        let res = if is_square(n) {
                Some(0)
            } else {
                let mut result: Option<u32> = None;
                recurse(n, |n_rm| {
                    if let Some(k_rm) = get(n_rm, xs) {
                        result = result.map_or(
                            Some(k_rm + 1), |k| Some(cmp::min(k, k_rm + 1))
                        );
                    }
                });
                result
            };

        if (n as usize) < xs.len() {
            xs[n as usize] = Some(res);
        }
        return res;
    }
    return xs[n as usize].unwrap();
}

fn main() {
    let stdin = io::stdin();
    let mut input = stdin.lock().lines().flat_map(
        |x| x.unwrap().split_whitespace().map(|x| x.to_string()).collect::<Vec<_>>()
    );
    let n: u32 = input.next().unwrap().parse().unwrap();

    let mut array: Vec<_> = iter::repeat(None).take(100000).collect();
    if let Some(k) = get(n, &mut array) {
        println!("{}", k);
    } else {
        println!("-1");
    }
}


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

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

fn is_square(s: Vec<i32>) -> bool {
    if s.len() == 0 { return false; }
    if s.len() >= 2 && s[0] == 0 { return false; }
    let mut val = 0;
    for u in s {
        val *= 10;
        val += u as i64;
    }
    let mut pass = 0;
    let mut fail = 1 << 16;
    while fail - pass > 1 {
        let mid = (fail + pass) / 2;
        if mid * mid <= val { pass = mid; }
        else { fail = mid; }
    }
    pass * pass == val
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($format:expr) => (write!(out,$format).unwrap());
        ($format:expr, $($args:expr),+) => (write!(out,$format,$($args),*).unwrap())
    }
    let n: Vec<_> = get_word().chars().map(|c| c as u8 as i32 - b'0' as i32).collect();
    let len = n.len();
    let mut ans = 1 << 20;
    for bits in 0 .. 1usize << len {
        let mut t = Vec::new();
        for i in 0 .. len {
            if (bits & 1 << i) == 0 {
                t.push(n[i]);
            }
        }
        if is_square(t) {
            ans = min(ans, bits.count_ones() as i32);
        }
    }
    puts!("{}\n", if ans == 1 << 20 { -1 } else { 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();
}


use std::io;

macro_rules! except {
    ($result: expr) => {
        match $result {
            Err(e) => panic!("{}", e),
            Ok(m) => m,
        }
    };
    ($result: expr, $msg: expr) => {
        match $result {
            Err(e) => panic!("{}: {}", $msg, e),
            Ok(m) => m,
        }
    };
}

fn parse_line() -> Vec<u8> {
    let mut input = String::new();
    except!(io::stdin().read_line(&mut input));
    input.trim().split_whitespace()
       .map(|x| except!(x.parse::<u8>()))
       .collect()
}

fn main() {
    let nm = parse_line();
    let (n, m) = (nm[0], nm[1]);
    if n > m {
        println!("0");
        return
    }
    let a = parse_line();
    let mut counts = a.iter().fold([0u8; 101], |mut v, &x| {v[x as usize] += 1; v});
    counts.sort_unstable_by(|x, y| y.cmp(x));
    let mut nums = vec![0u8; n as usize];
    for _ in 0..n {
        let (index, _) = nums.iter().enumerate()
            .max_by_key(|&(i, v)| counts[i] / (v + 1)).unwrap();
        nums[index] += 1;
    }
    let (index, _) = nums.iter().filter(|&v| *v != 0).enumerate()
        .min_by_key(|&(i, v)| counts[i] / v).unwrap();
    println!("{}", counts[index] / nums[index]);
}


use std::io;

macro_rules! except {
    ($result: expr) => {
        match $result {
            Err(e) => panic!("{}", e),
            Ok(m) => m,
        }
    };
    ($result: expr, $msg: expr) => {
        match $result {
            Err(e) => panic!("{}: {}", $msg, e),
            Ok(m) => m,
        }
    };
}

fn parse_line() -> Vec<u8> {
    let mut input = String::new();
    except!(io::stdin().read_line(&mut input));
    input.trim().split_whitespace()
       .map(|x| except!(x.parse::<u8>()))
       .collect()
}

fn main() {
    let n = parse_line()[0];
    let a = parse_line();
    let counts = a.iter().fold([0u8; 101], |mut v, &x| {v[x as usize] += 1; v});
    for i in 1..101 {
        if n > counts.iter().fold(0, |v, x| v + x / i) {
            println!("{}", i - 1);
            return
        }
    }
}


use std::io;

macro_rules! unwrap {
    ($result: expr) => {
        match $result {
            Err(e) => panic!("{}", e),
            Ok(m) => m,
        }
    };
}

fn parse_line() -> Vec<u8> {
    let mut input = String::new();
    unwrap!(io::stdin().read_line(&mut input));
    input.trim().split_whitespace()
       .map(|x| unwrap!(x.parse::<u8>()))
       .collect()
}

const MAXN: u8 = 100;

fn main() {
    let n = parse_line()[0];
    let a = parse_line();
    let counts = a.iter().fold([0u8; MAXN as usize + 1], |mut v, &x| {v[x as usize] += 1; v});
    for i in 1..counts.len() as u8 / n + 1 {
        if n > counts.iter().fold(0, |v, x| v + x / i) {
            println!("{}", i - 1);
            return
        }
    }
    println!("{}", MAXN);
}


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>(s: String) -> Vec<T>
    where T: FromStr,
          <T as FromStr>::Err: std::fmt::Debug,
{
    s.split_whitespace().map(|k| k.parse().unwrap()).collect()
}

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

    if n <= m {
        println!("{}", n);
        return;
    }

    let delta_sqrt = {
        let tmp = 8 * (n - m) - 1;
        let tmp = tmp as f64;
        tmp.sqrt()
    };

    let k = (delta_sqrt - 1.0) / 2.0;
    let k = k.ceil() as u64;

    let ans = m + k;

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


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

/// min{x | x * (x + 1) / 2 >= v }
fn calc(v: i64) -> i64 {
    assert! (v > 0);
    let piv = (v as f64).sqrt() as i64;
    for k in max(piv - 2, 0) .. piv + 3 {
        if k * (k + 1) >= 2 * v {
            return k;
        }
    }
    panic!();
}

fn solve() {
    let n: i64 = get();
    let m: i64 = get();
    if n <= m {
        println!("{}", n);
        return;
    }
    println!("{}", m + calc(n - m));
}

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::fmt::Debug;
use std::str::FromStr;

pub struct TokenReader {
    reader: std::io::Stdin,
    tokens: Vec<String>,
    index: usize,
}

impl TokenReader {
    pub fn new() -> Self {
        Self {
            reader: std::io::stdin(),
            tokens: Vec::new(),
            index: 0,
        }
    }

    pub fn next<T>(&mut self) -> T
    where
        T: FromStr,
        T::Err: Debug,
    {
        if self.index >= self.tokens.len() {
            self.load_next_line();
        }
        self.index += 1;
        self.tokens[self.index - 1].parse().unwrap()
    }

    pub fn vector<T>(&mut self) -> Vec<T>
    where
        T: FromStr,
        T::Err: Debug,
    {
        if self.index >= self.tokens.len() {
            self.load_next_line();
        }
        self.index = self.tokens.len();
        self.tokens.iter().map(|tok| tok.parse().unwrap()).collect()
    }

    pub fn load_next_line(&mut self) {
        let mut line = String::new();
        self.reader.read_line(&mut line).unwrap();

        self.tokens = line
            .split_whitespace()
            .map(String::from)
            .collect();
        self.index = 0;
    }
}

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

fn lcm(a: i32, b: i32) -> i32 {
    ((a as i64 * b as i64) / (gcd(a, b) as i64)) as i32
}

fn solve(n: i32) -> (i32, i32) {
    let mut res = (n / 2, n - n / 2);
    let mut res_lcm = lcm(res.0, res.1);

    let mut i = 1i64;
    while i * i <= n as i64 {
        if n % i as i32 != 0 {
            i += 1;
            continue;
        }

        let a = i as i32;
        let b = n - a;
        let curr_lcm = lcm(a, b);

        if curr_lcm < res_lcm && a > 0 && b > 0 {
            res_lcm = curr_lcm;
            res = (a, b);
        }

        let a = n / i as i32;
        let b = n - a;
        let curr_lcm = lcm(a, b);

        if curr_lcm < res_lcm && a > 0 && b > 0 {
            res_lcm = curr_lcm;
            res = (a, b);
        }
        i += 1;
    }
    res
}

fn main() {
    let mut reader = TokenReader::new();
    let tests = reader.next();

    for _ in 0..tests {
        let n = reader.next();
        let (a, b) = solve(n);
        println!("{} {}", a, b);
    }
}


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

pub struct TokenReader {
    reader: std::io::Stdin,
    tokens: Vec<String>,
    index: usize,
}

impl TokenReader {
    pub fn new() -> Self {
        Self {
            reader: std::io::stdin(),
            tokens: Vec::new(),
            index: 0,
        }
    }

    pub fn next<T>(&mut self) -> T
    where
        T: FromStr,
        T::Err: Debug,
    {
        if self.index >= self.tokens.len() {
            self.load_next_line();
        }
        self.index += 1;
        self.tokens[self.index - 1].parse().unwrap()
    }

    pub fn vector<T>(&mut self) -> Vec<T>
    where
        T: FromStr,
        T::Err: Debug,
    {
        if self.index >= self.tokens.len() {
            self.load_next_line();
        }
        self.index = self.tokens.len();
        self.tokens.iter().map(|tok| tok.parse().unwrap()).collect()
    }

    pub fn load_next_line(&mut self) {
        let mut line = String::new();
        self.reader.read_line(&mut line).unwrap();

        self.tokens = line
            .split_whitespace()
            .map(String::from)
            .collect();
        self.index = 0;
    }
}

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

fn lcm(a: i32, b: i32) -> i32 {
    ((a as i64 * b as i64) / (gcd(a, b) as i64)) as i32
}

fn is_prime(n: i32) -> bool {
    if n < 2 {
        return false;
    }

    let mut i: i64 = 2;
    while i * i <= n as i64 {
        if n as i64 % i == 0 {
            return false;
        }
        i += 1;
    }
    true
}

fn solve(n: i32) -> (i32, i32) {
    if n % 2 == 0 {
        return (n / 2, n / 2);
    }
    if is_prime(n) {
        return (1, n - 1);
    }

    let mut res = (n / 2, n / 2 + 1);
    let mut res_lcm = lcm(res.0, res.1);

    for i in 1..=n/2 + 1 {
        let a = i;
        let b = n - i;
        let curr_lcm = lcm(a, b);

        if curr_lcm < res_lcm {
            res_lcm = curr_lcm;
            res = (a, b);
        }
    }
    res
}

fn main() {
    let mut reader = TokenReader::new();
    let tests = reader.next();

    for _ in 0..tests {
        let n = reader.next();
        let (a, b) = solve(n);
        println!("{} {}", a, b);
    }
}


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

fn main() -> Result<(), Box<dyn Error>> {
    let stdin = stdin();

    let cases = {
        let mut l = line(&stdin)?;
        let mut ite = l.trim().split(' ');
        usize::from_str(ite.next().unwrap())?
    };

    for _ in 0..cases {
        let it = {
            let mut l = line(&stdin)?;
            let mut ite = l.trim().split(' ');
            u32::from_str(ite.next().unwrap())?
        };

        let mut best: u32 = 1;
        for d in 2..=f64::sqrt(it as f64) as u32 {
            if it % d == 0 {
                let nd = it / d;
                if nd > best {
                    best = nd;
                }
            }
        }
        println!("{} {}", best, it / best);
    }

    Ok(())
}

fn line(s: &Stdin) -> io::Result<String> {
    let mut i = String::new();
    s.read_line(&mut i)?;
    Ok(i)
}


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

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

fn get_primes(n: i64) -> Vec<i64> {
    let mut is_prime = vec![true; n as usize + 1];
    let mut primes = Vec::new();
    is_prime[0] = false;
    is_prime[1] = false;

    for i in 2..n + 1 {
        if is_prime[i as usize] {
            primes.push(i);
            let mut j = 2 * i;
            while j < n {
                is_prime[j as usize] = false;
                j += i;
            }
        }
    }
    primes
}

fn main() {
    let n = read::<usize>();
    let primes = get_primes(1001);
    'outer: for _ in 0..n {
        let n = read::<i64>();
        for &p in primes.iter() {
            if n % p == 0 {
                println!("{} {}", n / p, n - n / p);
                continue 'outer;
            }
        }
        println!("{} {}", 1, n - 1);
    }
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


/*
    date   : 2020 / 5 / 5
    author : quickn (quickn.ga)
    email  : quickwshell@gmail.com
*/

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

mod scanner {
    use std::{io, str};
    /* https://github.com/EbTech/rust-algorithms */

    /// 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: str::SplitAsciiWhitespace<'static>,
    }

    impl<R: io::BufRead> UnsafeScanner<R> {
        pub fn new(reader: R) -> Self {
            Self {
                reader,
                buf_str: Vec::new(),
                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())
                }
            }
        }
    }
}

fn main() {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let (mut scan, mut sout) = (
        scanner::UnsafeScanner::new(stdin.lock()),
        BufWriter::new(stdout.lock()),
    );
    let t: usize = scan.token();
    for i in 0..t {
        let n: usize = scan.token();
        let mut d: usize = 0;
        let mut d2: usize = n;
        use std::cmp::{max, min};
        for a in 1..=((n as f64).sqrt() as usize) {
            if n % a == 0 {
                d = max(d, a);
                d2 = min(d2, n/a);
            }
        }
        d = max(d, d2);
        writeln!(sout, "{} {}", d, n-d).ok();
    }
}


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

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

    let n = input.i() - 1;
    let mut sol = 0;
    for i in 1.. {
        if i * i > n { break; }
        if i * i == n { sol += 1; }
        else if n % i == 0 { sol += 2; }
    }
    println!("{}", sol);
}


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

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let n = BufReader::new(std::io::stdin())
        .lines()
        .next()
        .unwrap()?
        .parse::<usize>()?;

    let sqrt = (n as f32).sqrt().floor() as usize;
    let mut factors = 0;

    for factor in 1..=sqrt {
        if n % factor == 0 {
            factors += if factor == sqrt { 1 } else { 2 };;
        }
    }

    println!("{}", factors - 1);
    Ok(())
}


use std::io;

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

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

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


use std::io;

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

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

    let n = input.trim().parse::<usize>().unwrap();

    input.clear();
    io::stdin().read_line(&mut input)?;

    let v: Vec<u32> = input
        .trim()
        .split(' ')
        .map(|x| x.parse::<u32>().unwrap())
        .collect();

    let mut easy = 0;
    for i in 0..n {
        if v[i] != 0 {
            easy = 1
        }
    }

    if easy == 0 {
        print!("EASY");
    } else {
        print!("HARD");
    }

    Ok(())
}


use std::io;

fn main() {
    let mut buffer = String::new();
    io::stdin().read_line(&mut buffer)
        .expect("Failed to read line");
    let num_employees = buffer.trim().parse::<f64>().expect("parse error");
    let max_tl = num_employees.sqrt().floor() as i32;
    let num_employees = num_employees as i32;

    let mut count = 1;
    for tl in 1..max_tl {
        if num_employees % tl == 0 {
            count += 1;
        }
    }
    println!("{}", count)
}


//---------- begin union_find ----------
#[allow(dead_code)]
mod union_find {
    pub struct UF {
        p: Vec<i32>,
    }
    impl UF {
        pub fn new(n: usize) -> UF {
            UF {p: vec![-1; n] }
        }
        pub fn init(&mut self) {
            for p in self.p.iter_mut() {
                *p = -1;
            }
        }
        pub fn root(&self, mut x: usize) -> usize {
            while self.p[x] >= 0 {
                x = self.p[x] as usize;
            }
            x
        }
        pub fn same(&self, x: usize, y: usize) -> bool {
            self.root(x) == self.root(y)
        }
        pub fn unite(&mut self, x: usize, y: usize) -> Option<(usize, usize)> {
            let mut x = self.root(x);
            let mut y = self.root(y);
            if x == y {
                return None;
            }
            if self.p[x] > self.p[y] {
                std::mem::swap(&mut x, &mut y);
            }
            self.p[x] += self.p[y];
            self.p[y] = x as i32;
            Some((x, y))
        }
        pub fn parent(&self, x: usize) -> Option<usize> {
            let p = self.p[x];
            if p >= 0 {
                Some(p as usize)
            } else {
                None
            }
        }
        pub fn get_size(&self, x: usize) -> usize {
            let r = self.root(x);
            (-self.p[r]) as usize
        }
    }
}
//---------- end union_find ----------

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

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

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

//

fn run() {
    input! {
        n: usize,
        m: usize,
        e: [(usize1, usize1); m],
    }
    let mut e = e;
    e.sort();
    let mut deg = vec![0; n];
    for &(a, b) in e.iter() {
        deg[a] += 1;
        deg[b] += 1;
    }
    let mut ans = vec![n; n];
    for i in 0..n {
        if deg[i] == n - 1 {
            ans[i] = 1;
        }
    }
    let mut u = union_find::UF::new(n);
    for &(a, b) in e.iter() {
        if deg[a] != n - 1 && deg[b] == n - 1 {
            u.unite(a, b);
        }
    }
    let mut id = 0;
    let mut add = 2;
    for i in 0..n {
        if deg[i] != n - 1 && i == u.root(i) {
            ans[i] = id;
            id += add;
            add = 1;
        }
    }
    if id > 3 {
        println!("No");
        return;
    }
    for i in 0..n {
        for j in (i + 1)..n {
            if ans[i] == ans[j] || ans[i] == ans[j] + 1 || ans[i] + 1 == ans[j] {
                if e.binary_search(&(i, j)).is_err() {
                    println!("No");
                    return;
                }
            }
        }
    }
    println!("Yes");
    let mut s = String::new();
    let op: Vec<char> = "abc".chars().collect();
    for a in ans {
        s.push(op[a]);
    }
    println!("{}", s);
}

fn main() {
    run();
}


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

fn read_line() -> Vec<i64> {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    return buf.trim().split(" ")
        .map(|x| {x.parse::<i64>().unwrap() })
        .collect();
}

fn main(){

    let mut line = read_line();
    let (a, b) = (line[0], line[1]);
    line = read_line();
    let (c, d) = (line[0], line[1]);

    let mut ans = -1;

    'outer: for i in 1..101 {

        for j in 1..101 {
            if ((a*i + b) == (c*j + d)){
                ans = a*i + b;
                break 'outer;
            }
        }
    }

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


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>(s: String) -> Vec<T>
    where T: FromStr,
          <T as FromStr>::Err: std::fmt::Debug,
{
    s.split_whitespace().map(|k| k.parse().unwrap()).collect()
}

fn extended_euclid(a: i32, b: i32) -> (i32, i32, i32) {
    if b == 0 {
        (a, 1, 0)
    } else {
        let (d, x, y) = extended_euclid(b, modulo(a, b));
        (d, y, x - a / b * y)
    }
}

fn modulo(a: i32, b: i32) -> i32 {
    let ret_val = a % b;
    if ret_val < 0 {
        ret_val + b
    } else {
        ret_val
    }
}

fn main() {
    let (a, b): (i32, i32) = {
        let input = get_line();
        let mut it = input.split_whitespace().map(|k| k.parse().unwrap());
        (
            it.next().unwrap(),
            it.next().unwrap(),
            )
    };

    let (c, d): (i32, i32) = {
        let input = get_line();
        let mut it = input.split_whitespace().map(|k| k.parse().unwrap());
        (
            it.next().unwrap(),
            it.next().unwrap(),
            )
    };

    let e = d - b;

    let (g, x, y) = extended_euclid(a, c);

    let ans = if e % g != 0 {
        -1
    } else {
        let x1 = x * e / g;
        let x2 = modulo(x1, c / g);
        b + x2 * a
    };

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


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

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

    l!(t,s,x = input.i());
    if x >= t && (x == t || (x - t) % s <= 1) {
        println!("YES");
    } else {
        println!("NO");
    }
}