#![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;
                cur += 1;
                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");
}


fn solution(arg: String) -> bool {
  let mut sf = 0;
  let mut fs = 0;
  let mut prev_char;
  let mut c;
  let mut iter = arg.chars().peekable();
  prev_char = iter.next().unwrap();
  while iter.peek().is_some() {
    c = iter.next().unwrap();
    if prev_char == 'S' && c == 'F' {
      sf+=1;
    } else if prev_char == 'F' && c == 'S' {
      fs+=1;
    }
    prev_char =  c;
  }
  sf>fs
}

fn main() {
  assert_eq!(false,solution(String::from("FSSF")));
  assert_eq!(true,solution(String::from("SF")));
  assert_eq!(false,solution(String::from("FFFFFFFFFF")));
  assert_eq!(true,solution(String::from("SSFFSFFSFF")));

  let mut s = String::new();
  std::io::stdin().read_line(&mut s).unwrap();
  s = String::new();
  std::io::stdin().read_line(&mut s).unwrap();
  println!("{}", if solution(s) {"YES"} else {"NO"});
}


use std::io;

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


use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let mut number = buf.trim().parse::<i32>().unwrap();
    //println!("{}", number);
    //println!("Hello, world!");
    let mut buffer = String::new();
    io::stdin().read_line(&mut buffer).unwrap();
    let mut string = buffer.trim().as_bytes();
    //println!("{:?}", string);
    let mut counter = 0;
    let mut S_to_F = 0;
    let mut F_to_S = 0;
    loop {
        if (counter == (number-1)) {
            break;
        }
        //F < S
        if string[counter as usize] < string[(counter+1) as usize] {
            F_to_S = F_to_S + 1;
            //println!("F to s + 1");
        }
        else if string[counter as usize] > string[(counter+1) as usize]{
            S_to_F = S_to_F + 1;
            //println!("S to f + 1");
        }
        counter = counter + 1;
    }
    if (S_to_F > F_to_S) {
        println!("YES");
    }
    else {
        println!("NO");
    }
}


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

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

    let n = input.u();
    let s = input.bs();
    if s[0] == b'S' && s[n - 1] == b'F' {
        println!("YES");
    } else {
        println!("NO");
    }
}


use std::error::Error;
use std::io;

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

fn main() -> Result<(), Box<dyn Error>> {
	let _ = get_lines()?;
	let input = get_lines()?;
	let mut iter = input.chars();

	let mut s_to_sf = 0;
	let mut sf_to_s = 0;
	let mut last = iter.next().unwrap();
	for c in iter {
		match (last, c) {
			('S', 'F') => {
				s_to_sf += 1;
			}
			('F', 'S') => {
				sf_to_s += 1;
			}
			_ => {}
		}
		last = c;
	}
	print!("{}", if s_to_sf > sf_to_s { "YES" } else { "NO" });
	Ok(())
}


fn main() {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    input.clear();
    std::io::stdin().read_line(&mut input).expect("INPUT::Read line failed");

    let sf_amount = input.trim().matches("SF").collect::<Vec<&str>>().len();
    let fs_amount = input.trim().matches("FS").collect::<Vec<&str>>().len();

    if sf_amount > fs_amount {
        println!("YES");
    }else {
        println!("NO");
    }

}


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

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

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

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

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

    let days: Vec<bool> = get_line().trim().bytes().map(|b| b == b'S').collect();

    let mut prev = None;

    let mut cnt = 0;

    let first = days[0];

    for day in days {
        match prev {
            Some(b) if b != day => {
                prev = Some(day);
                cnt += 1;
            },
            _ => {
                prev = Some(day);
            }
        }
    }

    if first && cnt % 2 == 1 {
        println!("YES");
    } else {
        println!("NO");
    }
}


use std::io;

fn foo(a: u64, b:u64) -> (u64, u64) {
  if a == 0 || b == 0 {
    (a, b)
  } else if a >= 2*b {
    foo(a % (2*b), b)
  } else if b >= 2*a {
    foo(a, b % (2*a))
  } else {
    (a, b)
  }
}

fn main() {
  let mut buffer = String::new();
  io::stdin().read_line(&mut buffer).unwrap();
  let data = buffer.split_whitespace()
                   .map(|x| x.trim().parse::<u64>().unwrap())
                   .collect::<Vec<u64>>();
  let (a,b) = foo(data[0], data[1]);
  println!("{} {}", a, b);
}


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

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

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

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

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

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

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

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

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

fn solve<Inner: BufRead, Output: Write>(inf: &mut Input<Inner>, ouf: &mut Output) {
	let (mut a, mut b) = read!(inf,i64,i64);
	while b > 0 && a > 0 {
		if a >= 2 * b {
			a %= 2 * b;
		} else if b >= 2 * a {
			b %= 2 * a;
		} else {
			break;
		}
	}
	writeln!(ouf, "{} {}", a, b);
}


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

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

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

// ここまで

fn run() {
    input! {
        a: u64,
        b: u64,
    }
    let mut a = a;
    let mut b = b;
    loop {
        if a == 0 || b == 0 {
            println!("{} {}", a, b);
            return;
        } else if a >= 2 * b {
            a %= 2 * b;
        } else if b >= 2 * a {
            b %= 2 * a;
        } else {
            println!("{} {}", a, b);
            return;
        }
    }
}

fn main() {
    run();
}


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

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

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

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

fn process(a : u64, b : u64) -> (u64, u64) {
    let mut m_a = a;
    let mut m_b = b;
    loop {
        if (m_a == 0) || (m_b == 0) {
            break;
        } else {
            let two_m_a = 2 * m_a;
            let two_m_b = 2 * m_b;
            if m_a >= two_m_b {
                m_a = m_a % two_m_b;
            } else if m_b >= two_m_a {
                m_b = m_b % two_m_a;
            } else {
                break;
            }
        }
    }
    (m_a, m_b)
}

fn main() {
    let stdin = io::stdin();
    let mut a_b = vec![];
    read_ts(&stdin, &mut a_b);
    let (c, d) = process(a_b[0], a_b[1]);
    println!("{} {}", c, d);
}


// Try Codeforces
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        () => (get().parse::<i64>().unwrap());
    }
    let mut a = get!();
    let mut b = get!();
    while a > 0 && b > 0 {
        if a >= 2 * b {
            let x = a / (2 * b);
            a -= 2 * b * x;
        } else if b >= 2 * a {
            let x = b / (2 * a);
            b -= 2 * a * x;
        } else {
            break;
        }
    }
    println!("{} {}", a, b);
}


#![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 (A, B) = readl!(i64, i64);
    let (mut a, mut b) = (A, B);
    loop {
        if (a == 0) | (b == 0) { break; }
        else if a >= (2*b) {
            let num = a / (2*b);
            a -= num * (2*b);
        } else if b >= (2*a) {
            let num = b / (2*a);
            b -= num * (2*a);
        } else {
            break;
        }
    }
    println!("{} {}", a, b);
}


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

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

use std::cmp;

fn main() {
    let (n, k) = read_line!(i32, i32);
    let x = cmp::min(k * 2, n - k);
    let y = if k == 0 { 0 } else { cmp::min(1, n - k) };
    println!("{} {}", y, x);
}


fn main() {
  use std::io;
  use std::str::FromStr;
  use std::cmp::min;
  use std::cmp::max;

  let stdin = io::stdin();
  let mut line = String::new();
  stdin.read_line(&mut line).ok();
  let s_line : Vec<&str> = line.split(' ').collect();
  let n : i64 = i64::from_str(s_line[0].trim()).unwrap();
  let k : i64 = i64::from_str(s_line[1].trim()).unwrap();
  let mut ans_min = min(1, n-k);
  if k == 0 {
    ans_min = 0;
  }
  let mut ans_max = 2*min(n/3, k) - max((k-min(n/3, k)) - n%3, 0);
  if (k-min(n/3, k))==1 && n%3==2{
    ans_max += 1;
  }
  println!("{0} {1}", ans_min, ans_max);
}


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

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 gcd(a: u32, b: u32) -> u32 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

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

    let min_val = if k == 0 || k == n {
        0
    } else {
        1
    };

    let q = n / 3;
    let r = n % 3;

    let max_val = if k <= q {
        2 * k
    } else if k <= q + r {
        2 * q + if r == 2 && k == q + 1 {1} else {0}
    } else {
        n - k
    };

    println!("{} {}", min_val, max_val);
}


// ---------- begin ModInt ----------
const MOD: u32 = 998_244_353;

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

#[allow(dead_code)]
impl ModInt {
    pub fn new(n: u32) -> ModInt {
        ModInt(n % MOD)
    }
    pub fn zero() -> ModInt {
        ModInt(0)
    }
    pub fn one() -> ModInt {
        ModInt(1)
    }
    pub fn pow(self, mut n: u32) -> ModInt {
        let mut t = ModInt::one();
        let mut s = self;
        while n > 0 {
            if n & 1 == 1 {
                t *= s;
            }
            s *= s;
            n >>= 1;
        }
        t
    }
    pub fn inv(self) -> ModInt {
        self.pow(MOD - 2)
    }
}
// ---------- 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 ----------

fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let p: usize = it.next().unwrap().parse().unwrap();
    let s: usize = it.next().unwrap().parse().unwrap();
    let r: usize = it.next().unwrap().parse().unwrap();
    let pc = Precalc::new(s + p);
    let mut ans = ModInt::zero();
    for v in r..=s {
        if p * v == s {
            ans += pc.inv(p);
        }
        for k in 1..p {
            if k * v > s {
                break;
            }
            let rem = s - k * v;
            let q = p - k;
            let mut way = ModInt::zero();
            let mut sign = ModInt::one();
            for x in 0..=q {
                if x * v > rem {
                    break;
                }
                way += sign * pc.comb(rem - x * v + q - 1, q - 1) * pc.comb(q, x);
                sign = -sign;
            }
            ans += pc.comb(p - 1, k - 1) * way * pc.inv(k);
        }
    }
    ans *= pc.comb(s - r + p - 1, p - 1).inv();
    println!("{}", ans);
}

fn main() {
    run();
}


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

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

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

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

fn solve<R: io::BufRead, W: io::Write>(scan: &mut Scanner<R>, out: &mut W) {
    let n: u32 = scan.token();
    let ans = 3 * n / 2;
    writeln!(out, "{}", ans).ok();
}

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


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

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

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

// ここまで

fn run() {
    input! {
        n: u64,
    }
    let mut ans = 100;
    for k in 1.. {
        if k * k > n {
            break;
        }
        let a: Vec<_> = (k * k).to_string().chars().collect();
        let b: Vec<_> = n.to_string().chars().collect();
        let mut x = 0;
        let mut y = 0;
        let mut c = 0;
        while x < a.len() && y < b.len() {
            if a[x] == b[y] {
                x += 1;
                y += 1;
            } else {
                y += 1;
                c += 1;
            }
        }
        if x >= a.len() {
            c += b.len() - y;
            ans = std::cmp::min(ans, c);
        }
    }
    if ans >= 100 {
        println!("-1");
    } else {
        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 <= 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) {
            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");
    }
}


use std::io;

fn contains(n: &String, sub: &String) -> bool {
    let mut chars = sub.chars();
    let mut now = chars.next();
    for c in n.chars() {
        if let Some(nowc) = now {
            if nowc == c {
                now = chars.next();
            }
        } else {
            break;
        }
    }
    return now == None;
}

fn main() {
    let mut n = String::new();
    io::stdin().read_line(&mut n);
    n = n.trim().to_string();
    let n_len = n.chars().count();
    for k in (1..44722).rev() {
        let sub = (k * k).to_string();
        let sub_len = sub.chars().count();
        if n_len >= sub_len && contains(&n, &sub) {
            println!("{}", n_len - sub_len);
            return;
        }
    }
    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[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();
}


#![allow(unused_imports)]
use std::io;
use std::io::prelude::*;
use std::io::BufReader;
use std::str::FromStr;
use std::collections::{VecDeque, HashMap};

fn main() {
    let stdin = io::stdin();
    let mut input = stdin.lock();
    let mut line = String::new();
    input.read_line(&mut line).unwrap();
    let nums = get_numbers(&line);
    let shovel_price: i32 = nums[0];
    let change = nums[1];

    for i in 1..11 {
        let total = i * shovel_price;
        if total < 10 && total < change {
            continue;
        }

        if total % 10 == 0 || (total - change) % 10 == 0 {
            println!("{}", i);
            return;
        }
    }

    println!("-1");
}

/*
 * Utility Functions
 */

// get numbers from line seperated by spaces
fn get_numbers<T>(line: &str) -> Vec<T>
    where T: FromStr,
          <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    line.split_whitespace()
        .map(|chunk| chunk.parse::<T>().expect("failed to parse"))
        .collect()
}


use std::io;
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()
        }
    }
}

fn main1() {
    let stdin = io::stdin();
    let mut input = Scanner::new(stdin.lock());
    let k = input.next::<i64>();
    let r = input.next::<i64>();
    for i in 1..10 {
        if (i * k % 10) == r || (i * k % 10) == 0 {
            println!{"{}", i};
            return;
        }
    }
    println!["10"];
}

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


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

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

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

fn main() {
    let (n,r) = readln!(i32,i32);
    for i in 1..20 {
        if (n*i)%10 == r || (n*i)%10 == 0 {
            println!("{}",i);
            return;
        }
    }
}


fn main() {
    let (k, r): (u32, u32) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut ws = buf.split_whitespace();
        let k = ws.next().unwrap().parse().unwrap();
        let r = ws.next().unwrap().parse().unwrap();
        (k, r)
    };

    let c = std::char::from_digit(r, 10).unwrap();
    for i in 1..=10 {
        let s = format!("{}", i * k);
        let d = s.chars().last().unwrap();
        if d == c || d == '0' {
            println!("{}", i);
            break;
        }
    }
}


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

fn main() {
    let stdin = io::stdin();
    let kr: Vec<i32>;
    let line: String;
    let mut iterator = stdin.lock().lines();
    let mut min: i32;

    line = iterator.next().unwrap().unwrap();
    kr = line
        .split_whitespace()
        .map(|n| n.parse().unwrap())
        .collect();

    min = 1;
    while (kr[0]*min)%10 != 0 && (kr[0]*min)%10 != kr[1] {
        min += 1;
    }

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


fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).expect("failed");
    let mut iter = s.split_whitespace();
    let k = iter.next().unwrap().parse::<i32>().unwrap();
    let r = iter.next().unwrap().parse::<i32>().unwrap();
    for i in 1..10 {
        if k * i % 10 == 0 || k * i % 10 == r {
            println!("{}", i);
            break;
        }
    }
}


// {{{ by shik

use std::io;

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

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

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

#[allow(unused_macros)]
macro_rules! join {
    ($x:expr, $($xs:expr),*; $sep:expr) => { concat!($x, $($sep, $xs),*) }
}

#[allow(unused_macros)]
macro_rules! dump {
    ($($x:expr),*) => {
        eprintln!(join!($(concat!(stringify!($x), " = {:?}")),*; ", "), $($x),*);
    }
}

// }}}

fn main() {
    let (k, r) = R!(usize, usize);
    for i in 1.. {
        if k*i % 10 == 0 || k*i % 10 == r {
            println!("{}", i);
            break;
        }
    }
}


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

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

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

impl Scanner {

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

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

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

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

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

fn main() {
   let mut sin = Scanner::new();

   let k : usize = sin.next();
   let r = sin.next();

   for i in 1..10001 {
      let test = ((i*k) + 10) % 10;
      if test == r || test == 0 {
         println!("{}", i);
         break;
      }
   }
}


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

fn exec() {
    let mut sc = Scanner::new();
    let s: String = sc.ne();
    let t: String = sc.ne();
    fn f(s: &str) -> i32 {
        match s {
            "monday" => 0,
            "tuesday" => 1,
            "wednesday" => 2,
            "thursday" => 3,
            "friday" => 4,
            "saturday" => 5,
            "sunday" => 6,
            _ => panic!(">_<"),
        }
    }
    let s = f(&s);
    let t = f(&t);
    let mut ok = false;
    for &x in &[28, 30, 31] {
        if (s + x) % 7 == t {
            ok = true;
            break;
        }
    }
    println!("{}", if ok { "YES" } else { "NO" });
}

fn main() {
    const DEFAULT_STACK: usize = 16 * 1024 * 1024;
    let builder = thread::Builder::new();
    let th = builder.stack_size(DEFAULT_STACK);
    let handle = th.spawn(|| { exec(); }).unwrap();
    let _ = handle.join();
}

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

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


use std::io;

fn zeros_fac(n : u32) -> u32 {
    let mut i = 5;
    let mut count = 0;
    while i <= n {
        count += n / i;
        i *= 5;
    }
    count
}

fn bsearch(mut pi : u32, mut pf : u32, n : u32) -> Option<u32> {
    while pf >= pi {
        let pm = (pf + pi) / 2;
        let zeros_pm = zeros_fac(5 * pm);
        if zeros_pm < n {
            pi = pm + 1;
        } else if zeros_pm == n {
            return Some(5 * pm);
        } else {
            pf = pm - 1;
        }
    }
    return None;
}

fn main() {
    let mut buffer = String::new();
    io::stdin().read_line(&mut buffer).expect("failed to read input");
    let n: u32 = buffer.trim().parse().expect("invalid input");

    match bsearch(4 * n / 5, n, n) {
        Some(x) => {
            println!("5");
            println!("{} {} {} {} {}", x, x + 1, x + 2, x + 3, x + 4);
        },
        None => println!("0"),
    };
}


struct Time {
  hour: u8,
  min: u8
}

impl Time {
  fn add_minute(&mut self) {
    self.min += 1;
    if self.min == 60 {
      self.min = 0;
      self.hour += 1;
      if self.hour == 24 {
        self.hour = 0;
      }
    }
  }

  fn is_palindrome(&self) -> bool {
    let (h1, h2) = (self.hour / 10, self.hour % 10);
    let (m1, m2) = (self.min / 10, self.min % 10);

    h1 == m2 && h2 == m1
  }
}

fn main() {
  use std::io::{self, Read};

  let mut buf = [0; 5];
  io::stdin().read(&mut buf).unwrap();

  let mut time = Time {
    hour: {
      let h1 = buf[0] - b'0';
      let h2 = buf[1] - b'0';
      (h1 * 10) + h2
    },
    min: {
      let m1 = buf[3] - b'0';
      let m2 = buf[4] - b'0';
      (m1 * 10) + m2
    }
  };

  let mut mins = 0;
  while !time.is_palindrome() {
    time.add_minute();
    mins += 1;
  }

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


use std::io::{self};

fn is_paly(x: i32) -> bool {
    let h = (x / 60) % 24;
    let m = x % 60;
    h % 10 * 10 + h / 10 == m
}

fn find_paly(x: i32) -> i32 {
    for i in x..3000{
        if is_paly(i) {return i - x}
    }
    -1
}

fn read_time() -> Result<i32, String> {
    let mut str = String::new();
    try!(io::stdin().read_line(&mut str).map_err(|e| e.to_string()));
    let parts: Vec<&str> = str.split(':').collect();
    if parts.len() != 2  { return Err(String::from("wrong format, should have single : delimiter")) };
    let x = try!(parts[0].trim().parse::<i32>().map_err(|e|e.to_string()));
    let y = try!(parts[1].trim().parse::<i32>().map_err(|e|e.to_string()));
    Ok(x * 60 + y)
}

fn main() {
    let tt = read_time().unwrap();
    print!("{}", find_paly(tt));
}


use std::io;

fn solve(nums: &Vec<u8>) -> &str {
    let mut res = false;
    if nums[0] + nums[1] > nums[2] {
        return "TRIANGLE";
    } else if nums[0] + nums[1] == nums[2] {
        res = true;
    }
    if nums[1] + nums[2] > nums[3] {
        "TRIANGLE"
    } else if nums[1] + nums[2] == nums[3] || res {
        "SEGMENT"
    } else {
        "IMPOSSIBLE"
    }
}

fn main() {
    let mut input = String::with_capacity(7);
    io::stdin().read_line(&mut input).unwrap();
    let mut nums: Vec<u8> = input
        .trim()
        .split_whitespace()
        .map(|a| a.parse().unwrap())
        .collect();

    nums.sort_unstable();
    print!("{}", solve(&nums));
}


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

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

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

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

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

fn is_triangle(a: usize, b: usize, c: usize) -> bool {
    // parameters are passed sorted in increasing order
    return a + b > c;
}

fn is_collinear(a: usize, b: usize, c: usize) -> bool {
    // parameters are passed sorted in increasing order
    return a + b == c;
}

fn _main() {
    let mut scan = Scan::new();
    let mut arr: Vec<usize> = scan.next_n(4);
    arr.sort();
    if is_triangle(arr[0], arr[1], arr[2])
        || is_triangle(arr[0], arr[1], arr[3])
        || is_triangle(arr[0], arr[2], arr[3])
        || is_triangle(arr[1], arr[2], arr[3])
    {
        println!("TRIANGLE");
    } else if is_collinear(arr[0], arr[1], arr[2])
        || is_collinear(arr[0], arr[1], arr[3])
        || is_collinear(arr[0], arr[2], arr[3])
        || is_collinear(arr[1], arr[2], arr[3])
    {
        println!("SEGMENT");
    } else {
        println!("IMPOSSIBLE");
    }
}

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


use std::io::Read;

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

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


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

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let mut input = input.split_whitespace();
    macro_rules! read(
        ([$tt:tt; $n:expr]) => ((0..$n).map(|_| read!($tt)).collect::<Vec<_>>());
        ($ty:ty) => (input.next().unwrap().parse::<$ty>().unwrap());
    );

    let mut xs = read!([u64; 4]);
    xs.sort();
    if xs[0] + xs[1] > xs[2] || xs[1] + xs[2] > xs[3] {
        println!("TRIANGLE");
    } else if xs[0] + xs[1] == xs[2] || xs[1] + xs[2] == xs[3] {
        println!("SEGMENT");
    } else {
        println!("IMPOSSIBLE");
    }
}


use std::io;

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

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let mut buf = buf
        .trim()
        .split_whitespace()
        .map(|num| num.parse::<usize>().unwrap())
        .take(3);
    let (n, p, k) = (
        buf.next().unwrap(),
        buf.next().unwrap(),
        buf.next().unwrap(),
    );

    // Add begining (before 'p')
    if (1..=(k + 1)).contains(&p) {
        for i in 1..p {
            result.push_str(&format!("{} ", i));
        }
    } else {
        result.push_str("<< ");
        for i in (p - k)..p {
            result.push_str(&format!("{} ", i));
        }
    }

    result.push_str(&format!("({})", p));

    // Add ending (after 'p')
    if ((n - k)..=n).contains(&p) {
        for i in (p + 1)..=n {
            result.push_str(&format!(" {}", i));
        }
    } else {
        for i in (p + 1)..=(p + k) {
            result.push_str(&format!(" {}", i));
        }
        result.push_str(" >>");
    }

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


use std::cmp::{max, min};
use std::io::stdin;
fn main() {
    let (n, p, k) = {
        let mut buf = String::new();
        stdin().read_line(&mut buf).expect("Failed to read line");
        let nums: Vec<i32> = buf
            .trim()
            .split_ascii_whitespace()
            .map(|c| c.parse::<i32>().unwrap())
            .collect();
        (nums[0], nums[1], nums[2])
    };
    if p - k > 1 {
        print!("<< ");
    }
    for i in max(1, p - k)..(p) {
        print!("{} ", i);
    }
    print!("({}) ", p);
    for i in (p + 1)..min(p + k + 1, n + 1) {
        print!("{} ", i);
    }
    if p + k < n {
        println!(">>");
    } else {
        println!("");
    }
}


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

// Outline
// read in numberse first and parse

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

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

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

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

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

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

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


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

/**************************************************

    START OF TEMPLATE CODE

 *************************************************/
#[allow(unused_macros)]
macro_rules! dbg {
    ($first_val:expr, $($val:expr),+ $(,)?) => {
        eprint!("[{}:{}] {} = {:?}",
                    file!(), line!(), stringify!($first_val), &$first_val);
        ($(eprint!(", {} = {:?}", stringify!($val), &$val)),+,);
        eprintln!();
    };
    ($first_val:expr) => {
        eprintln!("[{}:{}] {} = {:?}",
                    file!(), line!(), stringify!($first_val), &$first_val);
    };
}

enum InputSource {
    Stdin,
    FromFile(Vec<String>),
}

struct Scanner {
    buffer: Vec<String>,
    input_source: InputSource,
}

impl Scanner {
    #[allow(dead_code)]
    fn new() -> Self {
        Self { buffer: vec![], input_source: InputSource::Stdin }
    }

    #[allow(dead_code)]
    fn new_file(filename: &str) -> Self {
        let file = std::fs::read_to_string(filename).unwrap();
        let mut lines: Vec<String> = file.lines().map(|line| String::from(line)).collect();
        lines.reverse();
        Self { buffer: vec![], input_source: InputSource::FromFile(lines) }
    }

    #[allow(dead_code)]
    fn i64(&mut self) -> i64 {
        self.next::<i64>()
    }

    #[allow(dead_code)]
    fn i32(&mut self) -> i32 {
        self.next::<i32>()
    }

    #[allow(dead_code)]
    fn usize(&mut self) -> usize {
        self.next::<usize>()
    }

    #[allow(dead_code)]
    fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.next::<T>()).collect()
    }

    fn parse_next_line(&mut self) -> bool {
        let mut input = String::new();
        match &mut self.input_source {
            | InputSource::Stdin => {
                if std::io::stdin().read_line(&mut input).expect("Failed read") == 0 {
                    return false;
                }
            }
            | InputSource::FromFile(lines) => {
                match lines.pop() {
                    Some(line) => input = line,
                    None => return false,
                }
            }
        }

        self.buffer = input.split_whitespace().rev().map(String::from).collect();
        return true;
    }

    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }

            self.parse_next_line();
        }
    }

    #[allow(dead_code)]
    fn has_more_elements(&mut self) -> bool {
        loop {
            if !self.buffer.is_empty() {
                return true;
            }
            if !self.parse_next_line() {
                return false;
            }
        }
    }

    #[allow(dead_code)]
    fn string(&mut self) -> Vec<u8> {
        self.next::<String>().into_bytes()
    }
}

/**************************************************

    END OF TEMPLATE CODE

 *************************************************/

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

    let n = sc.usize();
    let req_prob = sc.next::<f64>();
    for learn in 0..=n {
        let mut res = 0.0;
        let mut tot_prob = 0.0;
        for know1 in 0..=1 {
            for know2 in 0..=1 {
                for know3 in 0..=1 {
                    let mut prob_here = 1.0;
                    let mut more_know = learn;
                    let mut more_not_know = n - learn;
                    for &cur_know in [know1, know2, know3].iter() {
                        let tot_left = (more_know + more_not_know) as f64;
                        if cur_know == 0 {
                            prob_here *= more_not_know as f64;
                            if prob_here == 0.0 {
                                break;
                            }
                            more_not_know -= 1;
                        } else {
                            prob_here *= more_know as f64;
                            if prob_here == 0.0 {
                                break;
                            }
                            more_know -= 1;
                        }
                        prob_here /= tot_left as f64;

                    }
                    let know_cnt = min(2, know1 + know2 + know3);
                    let prob_know = (know_cnt as f64) / 2.0;
                    res += prob_here * prob_know;
                    tot_prob += prob_here;
                }
            }
        }
        if res >= req_prob {
            writeln!(out, "{}", learn).unwrap();
            return;
        }
    }
    unreachable!();
}


#![allow(dead_code, unused_macros, unused_imports)]
use std::{cell::{Cell, RefCell, UnsafeCell}, cmp::{Ordering, Reverse, max, min}, collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque, hash_map::{DefaultHasher, RandomState}}, error::Error, fmt::{Display, Write as FmtWrite}, hash::{BuildHasher, Hash, Hasher}, io::{BufWriter, Read, Stdin, Stdout, Write}, iter::{FromIterator, Peekable}, mem::swap, ops::*, process::exit, rc::Rc, str::{FromStr, from_utf8_unchecked}, time::{Duration, Instant}};

const IO_BUF_SIZE: usize = 1 << 16;
type Input = Scanner<Stdin>;
type Output = BufWriter<Stdout>;
fn _init_input() -> Input { Scanner::new(std::io::stdin()) }
fn _init_output() -> Output { BufWriter::with_capacity(IO_BUF_SIZE, std::io::stdout()) }

#[repr(transparent)] struct Unsync<T>(T);
unsafe impl<T> Sync for Unsync<T> {}

type BadLazy<T> = Unsync<UnsafeCell<Option<T>>>;
impl<T> BadLazy<T> {
    const fn new() -> Self { Self(UnsafeCell::new(None)) }
}

static INPUT: BadLazy<Input> = BadLazy::new();
static OUTPUT: BadLazy<Output> = BadLazy::new();

fn inp<F: FnOnce(&mut Input) -> R, R>(f: F) -> R {
    unsafe { f((&mut *INPUT.0.get()).get_or_insert_with(_init_input)) }
}
fn out<F: FnOnce(&mut Output) -> R, R>(f: F) -> R {
    unsafe { f((&mut *OUTPUT.0.get()).get_or_insert_with(_init_output)) }
}

macro_rules! read {
    () => { read(); };
    ($t: ty) => { read::<$t>(); };
    ($t: ty, $($tt: ty),*) => { (read::<$t>(), $(read::<$tt>(),)*) };
    [$t: ty; $n: expr] => { read_vec::<$t>($n); };
}
macro_rules! println {
    () => { out(|x| { let _ = writeln!(x); }); };
    ($exp: expr) => { out(|x| { let _ = writeln!(x, "{}", $exp); }); };
    ($fmt: expr, $($arg : tt )*) => { out(|x| { let _ = writeln!(x, $fmt, $($arg)*); }); }
}
macro_rules! print {
    ($exp: expr) => { out(|x| { let _ = write!(x, "{}", $exp); }); };
    ($fmt: expr, $($arg : tt )*) => { out(|x| { let _ = write!(x, $fmt, $($arg)*); }); }
}

fn out_flush() { out(|x| { let _ = x.flush(); }); }

fn input_is_eof() -> bool { inp(|x| x.eof()) }
fn read_byte() -> u8 { inp(|x| x.byte()) }
fn read_bytes_no_skip(n: usize) -> Vec<u8> { inp(|x| x.bytes_no_skip(n)) }
fn read_bytes(n: usize) -> Vec<u8> { inp(|x| x.bytes(n)) }
fn read_bytes2(n: usize, m: usize) -> Vec<Vec<u8>> { inp(|x| x.bytes2(n, m)) }
fn read_token() -> Vec<u8> { inp(|x| x.token_bytes()) }
fn read_token_str() -> String { unsafe { String::from_utf8_unchecked(read_token()) } }
fn read_line() -> Vec<u8> { inp(|x| x.line_bytes()) }
fn read_line_str() -> String { unsafe { String::from_utf8_unchecked(read_line()) } }
fn read<T: FromStr>() -> T { read_token_str().parse::<T>().ok().expect("failed parse") }
fn read_vec<T: FromStr>(n: usize) -> Vec<T> { (0..n).map(|_| read()).collect() }
fn read_vec2<T: FromStr>(n: usize, m: usize) -> Vec<Vec<T>> { (0..n).map(|_| read_vec(m)).collect() }

struct Scanner<R: Read> {
    src: R,
    _buf: Vec<u8>,
    _pt: usize, // pointer
    _rd: usize, // bytes read
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(src: R) -> Scanner<R> {
        Scanner { src, _buf: vec![0; IO_BUF_SIZE], _pt: 1, _rd: 1 }
    }

    fn _check_buf(&mut self) {
        if self._pt == self._rd {
            self._rd = self.src.read(&mut self._buf).unwrap_or(0);
            self._pt = (self._rd == 0) as usize;
        }
    }

    // returns true if end of file
    fn eof(&mut self) -> bool {
        self._check_buf();
        self._rd == 0
    }

    // filters \r, returns \0 if eof
    fn byte(&mut self) -> u8 {
        loop {
            self._check_buf();
            if self._rd == 0 { return 0; }
            let res = self._buf[self._pt];
            self._pt += 1;
            if res != b'\r' { return res; }
        }
    }

    fn bytes_no_skip(&mut self, n: usize) -> Vec<u8> { (0..n).map(|_| self.byte()).collect() }
    fn bytes(&mut self, n: usize) -> Vec<u8> {
        let res = self.bytes_no_skip(n);
        self.byte();
        res
    }
    fn bytes2(&mut self, n: usize, m: usize) -> Vec<Vec<u8>> { (0..n).map(|_| self.bytes(m)).collect() }

    fn token_bytes(&mut self) -> Vec<u8> {
        let mut res = Vec::new();
        let mut c = self.byte();
        while c <= b' ' {
            if c == b'\0' { return res; }
            c = self.byte();
        }
        loop {
            res.push(c);
            c = self.byte();
            if c <= b' ' { return res; }
        }
    }

    fn line_bytes(&mut self) -> Vec<u8> {
        let mut res = Vec::new();
        let mut c = self.byte();
        while c != b'\n' && c != b'\0' {
            res.push(c);
            c = self.byte();
        }
        res
    }
}

trait JoinToStr {
    fn join_to_str(self, sep: &str) -> String;
    fn concat_to_str(self) -> String;
}
impl<T: Display, I: Iterator<Item = T>> JoinToStr for I {
    fn join_to_str(mut self, sep: &str) -> String {
        match self.next() {
            Some(first) => {
                let mut res = first.to_string();
                while let Some(item) = self.next() {
                    res.push_str(sep);
                    res.push_str(&item.to_string());
                }
                res
            }
            None => { String::new() }
        }
    }

    fn concat_to_str(self) -> String {
        let mut res = String::new();
        for item in self { res.push_str(&item.to_string()); }
        res
    }
}
trait AsStr { fn as_str(&self) -> &str; }
impl AsStr for [u8] { fn as_str(&self) -> &str {std::str::from_utf8(self).expect("attempt to convert non-UTF8 byte string.")} }

macro_rules! veci {
    ($n:expr , $i:ident : $gen:expr) => {{
        let _veci_n = $n;
        let mut _veci_list = Vec::with_capacity(_veci_n);
        for $i in 0.._veci_n {
            _veci_list.push($gen);
        }
        _veci_list
    }};
    ($n:expr , $gen:expr) => { veci!($n, _veci_: $gen); }
}

fn abs_diff<T: Sub<Output = T> + PartialOrd>(x: T, y: T) -> T {
    if x < y { y - x } else { x - y }
}

trait CommonNumExt {
    fn div_ceil(self, b: Self) -> Self;
    fn div_floor(self, b: Self) -> Self;
    fn gcd(self, b: Self) -> Self;
    fn highest_one(self) -> Self;
    fn lowest_one(self) -> Self;
}

macro_rules! impl_common_num_ext {
    ($($ix:tt = $ux:tt),*) => {
        $(
            impl CommonNumExt for $ux {
                fn div_ceil(self, b: Self) -> Self {
                    let q = self / b; let r = self % b;
                    if r != 0 { q + 1 } else { q }
                }
                fn div_floor(self, b: Self) -> Self { self / b }
                fn gcd(self, mut b: Self) -> Self {
                    let mut a = self; while a != 0 { swap(&mut a, &mut b); a %= b; }
                    b
                }
                #[inline] fn highest_one(self) -> Self {
                    if self == 0 { 0 } else { const ONE: $ux = 1; ONE.rotate_right(1) >> self.leading_zeros() }
                }
                #[inline] fn lowest_one(self) -> Self { self & self.wrapping_neg() }
            }

            impl CommonNumExt for $ix {
                fn div_ceil(self, b: Self) -> Self {
                    let q = self / b; let r = self % b;
                    if self ^ b >= 0 && r != 0 { q + 1 } else { q }
                }
                fn div_floor(self, b: Self) -> Self {
                    let q = self / b; let r = self % b;
                    if self ^ b < 0 && r != 0 { q - 1 } else { q }
                }
                fn gcd(self, mut b: Self) -> Self {
                    let mut a = self; while a != 0 { swap(&mut a, &mut b); a %= b; }
                    b.abs()
                }
                #[inline] fn highest_one(self) -> Self { (self as $ux).highest_one() as _ }
                #[inline] fn lowest_one(self) -> Self { self & self.wrapping_neg() }
            }
        )*
    }
}
impl_common_num_ext!(i8 = u8, i16 = u16, i32 = u32, i64 = u64, i128 = u128, isize = usize);

trait ChMaxMin<T> {
    fn set_max(&mut self, v: T) -> bool;
    fn set_min(&mut self, v: T) -> bool;
}
impl<T: PartialOrd> ChMaxMin<T> for T {
    fn set_max(&mut self, v: T) -> bool { if v > *self { *self = v; true } else { false } }
    fn set_min(&mut self, v: T) -> bool { if v < *self { *self = v; true } else { false } }
}

// * end commons * //

pub trait BinarySearchExt<T> {
    fn binary_search_by<F: FnMut(T) -> Ordering>(&self, f: F) -> Result<T, T>;

    fn partition_point<F: FnMut(T) -> bool>(&self, mut f: F) -> T {
        self.binary_search_by(|x| if f(x) { Ordering::Less } else { Ordering::Greater }).err().unwrap()
    }
}
macro_rules! impl_binary_search_ext_integer {
    ($($ty:tt),*) => {
        $(
            impl BinarySearchExt<$ty> for std::ops::Range<$ty> {
                fn binary_search_by<F: FnMut($ty) -> Ordering>(&self, mut f: F) -> Result<$ty, $ty> {
                    let mut low = self.start;
                    let mut high = self.end;

                    while low < high {
                        let mid = (low & high) + ((low ^ high) >> 1);
                        let cmp = f(mid);
                        if cmp == Ordering::Less {
                            low = mid + 1;
                        } else if cmp == Ordering::Greater {
                            high = mid;
                        } else {
                            return Ok(mid);
                        }
                    }
                    Err(low)
                }
            }
        )*
    }
}
impl_binary_search_ext_integer!(u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize);

#[allow(non_snake_case, non_upper_case_globals)]
fn main() {
    let num_cases: usize = 1;//read();

    for _case_num in 1..=num_cases {
        const SCALE: i64 = 10_000;

        let n = read!(i64);
        let p = (read!(f64) * SCALE as f64).round() as i64;

        let den = n * (n-1) * (n-2) * 2;

        let ans = (0..n).partition_point(|x| {
            let mut num = 0i64;

            for ng in 0..=3 {
                let mut chance = 1i64;
                for i in 0..ng {
                    chance *= x-i;
                }
                for i in 0..3-ng {
                    chance *= n-x-i;
                }

                if ng == 1 || ng == 2 { chance *= 3; }

                chance *= min(ng, 2);
                num += chance;
            }

            //dbg!(x, num * SCALE / den);
            num * SCALE / den < p
        });

        println!(ans);
    }

    out_flush();
}


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

fn read_line<T: FromStr>() -> Vec<T>
    where
        T::Err: std::fmt::Debug
{
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    input.trim()
        .split(' ')
        .map(|x| x.parse::<T>().unwrap())
        .collect()
}

fn c(n: i64, k: i64) -> i64 {
    if k > n {
        return 0;
    }
    let mut result = 1;
    if k > n - k {
        for i in k + 1..n + 1 {
            result *= i;
        }
        for i in 1..n - k + 1 {
            result /= i;
        }
    }
    if k <= n - k {
        for i in n - k + 1..n + 1 {
            result *= i;
        }
        for i in 1..k + 1 {
            result /= i;
        }
    }
    return result;
}

fn main() {
    let input = read_line::<String>();
    let n = input[0].parse::<i64>().unwrap();
    let p = input[1].parse::<f64>().unwrap();
    let p_int = (p * 10000.0).round() as i64;
    for k in 0..n + 1 {
        let numerator = 2 * (c(k, 3) + c(k, 2) * c(n - k, 1)) + c(k, 1) * c(n - k, 2);
        if numerator * 10000 >= p_int * 2 * c(n, 3) {
            println!("{}", k);
            return
        }
    }
}


#![allow(unused_imports)]
use std::io::{ self, Write };
use std::str::FromStr;
use std::cmp::{ min, max };
use std::collections::{ BinaryHeap, VecDeque };

macro_rules! trace {
    ($var:expr) => ({
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($var), $var);
    })
}
macro_rules! swap { ($a:expr, $b:expr) => ({ let t = $b; $b = $a; $a = t; }) }

fn main() {
    let mut sc = Scanner::new();
    let mut cost = vec![vec![0; 3]; 3];
    let mut memo = vec![vec![vec![0; 3]; 3]; 42];

    for i in 0..3 {
        for j in 0..3 {
            cost[i][j] = sc.cin::<i64>();
        }
    }

    for i in 0..3 {
        for j in 0..3 {
            if i == j { continue }
            let k = 3 - i - j;
            memo[1][i][j] = min(cost[i][k] + cost[k][j], cost[i][j]);
        }
    }

    let n: usize = sc.cin();

    for m in 2..(n+1) {
        for i in 0..3 {
            for j in 0..3 {
                if i == j { continue }
                let k = 3 - i - j;
                memo[m][i][j] =
                    min(
                    memo[m-1][i][k] + memo[m-1][k][j] + cost[i][j],
                    memo[m-1][i][j] + cost[i][k] + memo[m-1][j][i] + cost[k][j] + memo[m-1][i][j]);
            }
        }
        // trace!(m);
        // for i in 0..3 {
        //     for j in 0..3 {
        //         print!("{} ", memo[m][i][j]);
        //     }
        //     println!("");
        // }
    }

    println!("{}", memo[n][0][2]);

}

#[allow(dead_code)]
struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn reserve(&mut self) {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        self.reserve();
        match self.buffer.pop_front().unwrap().parse::<T>() {
            Ok(a) => a,
            Err(_) => panic!("parse err")
        }
    }
    fn get_char(&mut self) -> char {
        self.reserve();
        let head = self.buffer[0].chars().nth(0).unwrap();
        let tail = String::from( &self.buffer[0][1..] );
        if tail.len()>0 { self.buffer[0]=tail } else { self.buffer.pop_front(); }
        head
    }
}


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

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

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

impl<'a> Scanner<'a> {
    #[allow(dead_code)]
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }

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

    #[allow(dead_code)]
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

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

    let n: i32 = sc.read();
    let m: i32 = sc.read();
    let h = min(n, m);
    let w = max(n, m);
    if h == 1 {
        println!("{}", w);
    } else if h == 2 {
        let ans = w / 4 * 4 + min(w % 4, 2) * 2;
        println!("{}", ans);
    } else {
        println!("{}", (n * m + 1) / 2);
    }
}


use std::io;
use std::str::FromStr;
use std::io::prelude::*;

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

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

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

    let get_beautiful = |i: u64| -> u64 {
        ((1 << i) - 1) << (i - 1)
    };

    let ans = (1..).map(|i| get_beautiful(i)).take_while(|&i| i <= n)
        .filter(|&i| n % i == 0).max().unwrap();

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

struct Solver {

}

impl Solver {

}


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

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

fn ok(x: u64) -> bool {
    let test = x | (x - 1);
    test & (test + 1) == 0
}

fn solve() {
    let n = parse_line!(u64);
    let mut result = 1;
    for i in 1..16 {
        let cur = ((1 << (i + 1)) - 1) << i;
        if n % cur == 0 {
            result = cur;
        }
    }
    println!("{}", result)
}

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


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

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

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

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

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

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

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

    let ans = (1..)
        .map(|k| (2u64.pow(k as u32) - 1) * (2u64.pow(k as u32 - 1)))
        .take_while(|&x| x <= n)
        .filter(|&x| n % x == 0)
        .last()
        .unwrap();

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


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

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

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

//

fn run() {
    input! {
        n: u64,
    }
    let mut ans = 1;
    for k in 1u64.. {
        let d = 2u64.pow(k as u32 - 1) * (2u64.pow(k as u32) - 1);
        if d > n {
            break;
        }
        if n % d == 0 {
            ans = d;
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

const MOD: i64 = 1000000007;

// assume a, b positive
fn gcd(a: i64, b: i64) -> (i64, i64, i64) {
    if b == 0 {
        (1, 0, a)
    }
    else {
        let (x, y, d) = gcd(b, a%b); // xb + y(a-qb) = d   where q = a/b
        (y, x-y*(a/b), d)
    }
}

fn factorial_mod(a: i64) -> i64 {
    if a == 0 {
        1
    }
    else {
        a * factorial_mod(a-1) % MOD
    }
}

fn binomial_mod(n: i64, k: i64) -> i64 {
    let a = factorial_mod(k);
    let b = factorial_mod(n-k);
    let (inv_a, _, _) = gcd(a, MOD);
    let (inv_b, _, _) = gcd(b, MOD);
    let result = factorial_mod(n) * inv_a % MOD * inv_b % MOD;
    if result < 0 { result + MOD } else { result }
}

fn main() {
    let stdin = std::io::stdin();
    let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
    let mut next = move || -> String{
        bytes
            .by_ref()
            .map(|r|r.unwrap() as char)
            .skip_while(|c|c.is_whitespace())
            .take_while(|c|!c.is_whitespace())
            .collect()
    };
    input! {next,
        n: i64,
        m: i64,
        k: i64,
    }
    if 2*k > n-1 || 2*k > m-1 {
        println!("0");
    }
    else {
        println!("{}", binomial_mod(n-1,2*k)*binomial_mod(m-1,2*k) % MOD);
    }
}


// https://codeforces.com/contest/1271/problem/A
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

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

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

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

    ($iter:expr, switch) => {
        {
            let ty = read_value!($iter, i32);
            if ty == 1 {
                vec![ty, read_value!($iter, i32), read_value!($iter, i32)]
            } else if ty == 2 {
                vec![ty, read_value!($iter, i32)]
            } else {
                vec![ty, read_value!($iter, i32)]
            }
        }
    };

    ($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)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! join {
    ($t:expr, $glue:expr) => {
        $t.into_iter().map(|w| w.to_string()).collect::<Vec<_>>().join($glue)
    };
}

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

fn main() {
    input! {
        a: i64, b: i64, c: i64, d: i64,
        t1: i64, t2: i64
    };

    let mut best = 0;
    for i in 0..d+1 {
        best = max(best, t1*min(a, i)+t2*(min(min(b,c),d-i)));
    }

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


//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 std::cmp::*;

fn run() {
    input! {
        a: i32,
        b: i32,
        c: i32,
        d: i32,
        e: i32,
        f: i32,
    }
    let mut ans = 0;
    for x in 0..=min(a, d) {
        let mut val = 0;
        val += e * x;
        val += f * min(b, min(c, d - x));
        ans = max(ans, val);
    }
    println!("{}", ans);
}

fn main() {
    run();
}


fn read_u32() -> u32 {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().parse().unwrap()
}

fn convert_a(a: &mut u32, d: &mut u32, cost: u32) -> u32 {

    let a_amount = *a.min(d);
    *a -= a_amount;
    *d -= a_amount;

    a_amount * cost
}

fn convert_b(b: &mut u32, c: &mut u32, d: &mut u32, cost: u32) -> u32 {

    let b_amount = *b.min(c).min(d);
    *b -= b_amount;
    *c -= b_amount;
    *d -= b_amount;

    b_amount * cost
}

fn main() {
    let mut a = read_u32();
    let mut b = read_u32();
    let mut c = read_u32();
    let mut d = read_u32();

    let cost_a = read_u32();
    let cost_b = read_u32();

    let mut rev = 0;

    if cost_a > cost_b {

        rev += convert_a(&mut a, &mut d, cost_a);
        rev += convert_b(&mut b, &mut c, &mut d, cost_b);

    } else {

        rev += convert_b(&mut b, &mut c, &mut d, cost_b);
        rev += convert_a(&mut a, &mut d, cost_a);

    }

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


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

fn main() {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut a: i64 = str.trim().parse().unwrap();
    str.clear();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut b: i64 = str.trim().parse().unwrap();
    str.clear();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut c: i64 = str.trim().parse().unwrap();
    str.clear();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut d: i64 = str.trim().parse().unwrap();
    str.clear();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut e: i64 = str.trim().parse().unwrap();
    str.clear();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut f: i64 = str.trim().parse().unwrap();
    str.clear();
    b = min (b, c);
    if e > f {
        println!("{}", min(d, a) * e + min(d - min(d,a) ,b) * f);
    }
    else {
        println!("{}", min(d, b) * f + min(d - min(d,b) ,a) * e);
    }

}


#![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 main() {
    let a = read::<i64>();
    let b = read::<i64>();
    let c = read::<i64>();
    let b = min(b, c);
    let mut d = read::<i64>();
    let e = read::<i64>();
    let f = read::<i64>();
    if e > f {
        let eset = min(a, d);
        d -= eset;
        let fset = min(b, d);
        println!("{}", e * eset + f * fset);
    } else {
        let fset = min(b, d);
        d -= fset;
        let eset = min(a, d);
        println!("{}", e * eset + f * fset);
    }
}

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


#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;
mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ;; ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { println ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }

use std::cmp::Reverse;

fn main() {
    let mut aa: Vec<char> = util::line().chars().collect();
    let bb: Vec<char> = util::line().chars().collect();

    let mut amap = HashMap::new();
    let mut bmap = HashMap::new();

    for &a in &aa {
        *amap.entry(a).or_insert(0) += 1;
    }

    for &b in &bb {
        *bmap.entry(b).or_insert(0) += 1;
    }

    if amap == bmap {
        println!(
            "{}",
            bb.iter()
                .map(|x| x.to_string())
                .collect::<Vec<_>>()
                .join("")
        );
        return;
    }

    if aa.len() < bb.len() {
        aa.sort_by_key(|&x| Reverse(x));
        println!(
            "{}",
            aa.iter()
                .map(|x| x.to_string())
                .collect::<Vec<_>>()
                .join("")
        );
        return;
    }

    let ans = (0..aa.len())
        .filter_map(|i| {
            let mut res = Vec::new();
            let mut amap = amap.clone();

            for &b in &bb[..i] {
                let c = amap.entry(b).or_insert(0);
                if *c > 0 {
                    *c -= 1;
                    res.push(b);
                } else {
                    return None;
                }
            }

            if let Some((&x, _)) = amap.iter().filter(|&(&k, &v)| v > 0 && k < bb[i]).max() {
                res.push(x);
                *amap.entry(x).or_insert(0) -= 1;
            } else {
                return None;
            }

            let mut rest = Vec::new();
            for (&k, &v) in amap.iter() {
                for _ in 0..v {
                    rest.push(k);
                }
            }

            rest.sort_by_key(|&x| Reverse(x));

            res.append(&mut rest);

            Some(res)
        })
        .max()
        .unwrap();

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


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

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

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

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

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