use std::io;
use std::io::prelude::*;

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

    io::stdin().read_line(&mut input).expect("fail read!");
    let words: Vec<&str> = input.split_whitespace().collect();
    let mut n: usize = words[0].trim().parse().unwrap();
    let k: usize = words[1].trim().parse().unwrap();
    println!("{}", div(n, k));
    Ok(())
}

fn div(mut n: usize, mut k: usize) -> usize {
    while k > 0 {
        let rem = n % 10;
        if rem < k {
            k = k - rem - 1;
            n = n / 10;
        } else {
            n = n - k;
            k = 0;
        }
    }
    n
}


use std::io::stdin;

fn main() {
    let line = String::new();
    stdin().read_line(&mut line).unwrap();
    let n: u8 = line.trim().parse().unwrap();

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


use std::io;

fn main() {
    let mut stdin = io::stdin();
    let mut stdin = stdin.lock();

    let mut line = String::new();
    stdin::read_line(&mut line);

    let parsed: usize = line.parse().unwrap();

    if parsed & 1 == 1 {
        println!("YES");
    } else {
        println!("NO");
    }
}


extern crate utils;
use utils::*;

fn main() {
    let input = read_line().parse::<i32>().unwrap();
    if input <= 2 { println!("NO"); }
    else if input % 2 == 0 { println!("YES"); }
    else { println!("NO"); }
}


fn even_parts(w: i32) -> &'static str {

    for k in 0..101 {
        if w/2 == 2*k {
            return "YES";
        }
        if w/2 == 2*k+1 {
            return "NO";
        }
        if w == 2 {
            return "NO";
        }
    }
    return "WTF";

}

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

    io::stdin()
        .read_line(&mut input)
        .expect("Failed to read input");
    let rinput: i32 = input.trim_end().parse().unwrap();
    even_parts(rinput);
}


// https://codeforces.com/problemset/problem/4/A

use std::{
    io::{
        stdin,
        stdout,
    },
    vec::Vec,
};

fn main() {
    let inp = stdin();
    let mut num_str = String::new();
    inp.read_to_string(&mut num_str);

    let num = num_str.parse::<i32>().unwrap();

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


use std::io;

fn is_splittable(weight: u32) {
    weight > 2 && weight % 2 == 0;
}

fn main() {
    let mut weight = String::new();
    io::stdin().read_line(&mut weight).unwrap();
    let weight: u32 = weight.trim().parse().unwrap();
    println!("{}", if is_splittable(weigth) {"YES"} else {"NO"});
}


use std::io;

fn main() {

    let mut x = String::new();

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

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

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

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

}


use std::io;

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


    use std::io;

    fn main() {
        let mut stdin = io::stdin();
        let mut stdin = stdin.lock();

        let mut line = String::new();
        stdin.read_line(&mut line);

        let parsed: usize = line.parse().unwrap();

        if parsed & 1 == 1 {
            println!("YES");
        } else {
            println!("NO");
        }
    }


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

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

        let mut a :u32 = int_vec[0];

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

}


// ---------- begin scannner ----------
#[allow(dead_code)]
mod scanner {
	use std::str::FromStr;
	pub struct Scanner<'a> {
		it: std::str::SplitWhitespace<'a>,
	}
	impl<'a> Scanner<'a> {
		pub fn new(s: &'a String) -> Scanner<'a> {
			Scanner {
				it: s.split_whitespace(),
			}
		}
		pub fn next<T: FromStr>(&mut self) -> T {
			self.it.next().unwrap().parse::<T>().ok().unwrap()
		}
		pub fn next_bytes(&mut self) -> Vec<u8> {
			self.it.next().unwrap().bytes().collect()
		}
		pub fn next_chars(&mut self) -> Vec<char> {
			self.it.next().unwrap().chars().collect()
		}
		pub fn next_vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
			(0..len).map(|_| self.next()).collect()
		}
	}
}
// ---------- end scannner ----------
use std::io::Write;
fn main() {
	use std::io::Read;
	let mut s = String::new();
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut sc = scanner::Scanner::new(&s);
	let out = std::io::stdout();
	let mut out = std::io::BufWriter::new(out.lock());
	let t: usize = sc.next();
	for _ in 0..t {
		solve(&mut sc, &mut out);
	}
}
const MOD: i64 = 10_i64.pow(9) + 7;
fn binary_exponentiation(a: i32, b: i32) -> i32 {
	let mut ans: i64 = 1;
	let mut a: i64 = a as i64 % MOD;
	let mut b = b;
	while b != 0 {
		if 1 == (b & 1) {
			ans = (ans * a as i64) % MOD;
		}
		a = (a * a) % MOD;
		b >>= 1;
	}
	return ans as i32;
}
fn solve<W: Write>(sc: &mut scanner::Scanner, out: &mut std::io::BufWriter<W>) {
	let (n, k): (i32, i8) = (sc.next(), sc.next());
	let ans = binary_exponentiation(n.into(), k.into());
	writeln!(out, "{}", ans).ok();
}


use std::io;

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

    let vowels = "aeiouyAEIOUY";

    for ch in input.trim().chars() {
        if vowels.find(ch) != None {
            continue;
        } else {
            print!(".{}", ch.to_lowercase().to_string());
        }
    }
    println!();
}


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

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

	let nums : Vec<u32> = nums.split_ascii_whitespace()
		.take(3)
		.map(|x| x.parse().unwrap())
		.collect();

	let (n, m, a) = (nums[0], nums[1], nums[2]);
	let mut res = n / a + ((n % a > 0) as u32);
	res *= m / a + ((m % a > 0) as u32);

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


use std::io;

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

    io::stdin().read_line(&mut buffer).unwrap();
    let mut it = buffer.trim().split_whitespace()
                                .map(|x| {x.parse::<f64>().unwrap()});

    let n = it.next().unwrap();
    let m = it.next().unwrap();
    let a = it.next().unwrap();
    let number_of_squares_required: = ((n/a).ceil() * (m/a).ceil());
    println!("{:?}", number_of_squares_required);
}


pub fn read_word() -> String {
	use std::io::prelude::*;
	let mut word: Vec<u8> = vec![];

	for c in ::std::io::stdin().bytes() {
		let c = c.unwrap();
		if (c as char).is_whitespace() {
			if !word.is_empty() {
				break;
			}
		} else {
			word.push(c);
		}
	}
	::std::str::from_utf8(&word).unwrap().to_string()
}

macro_rules! read {
	() => { read!("") };
	($msg:expr) => {{
		use std::io::Write;
		print!("{}", $msg);
		std::io::stdout().flush().unwrap();
		std::str::FromStr::from_str(&read_word()).unwrap()
	}};
}

fn main() {
	lets!{ n: f32, m: f32, a: f32 = read!() };
	println!("{:?}", (n/a).ceil() * (m/a).ceil());
}


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

fn main() -> Result<(), Box<dyn Error>> {
    let mut stdin = io::stdin();
    let mut line = String::new();
    stdin.read_line(&mut line)?;
    let num_digits: usize = line.trim().parse()?;
    let mut digits = vec![0u8; num_digits];
    stdin.read_exact(&mut digits)?;
    let num_eights = digits.iter().filter(|c| **c == b'8').count();
    println!("{}", cmp::min(num_digits / 11, num_eights));
    Ok(())
}


use std::io;

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

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

    for ch in s.chars() {
        if ch == '4' || ch == '7' {
            x += 1;
        }
    }

    if x == 4 || x == 7 {
        println!("YES");
    } else {
        println!("NO");
    }
}


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

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

fn solve() {
    let n: usize = get();
    let k = get();
    let m: i64 = get();
    let mut t: Vec<i64> = (0 .. k).map(|_| get()).collect();
    t.sort();
    let tsum: i64 = t.iter().sum();
    let mut ma = 0;
    for comp in 0 .. n + 1 {
        let rem = m - comp as i64 * tsum;
        if rem < 0 {
            break;
        }
        let mut remtask = Vec::new();
        for _ in 0 .. n - comp {
            remtask.append(&mut t.clone());
        }
        remtask.sort();
        let mut tot = 0;
        let mut pos = 0;
        while pos < remtask.len() {
            tot += remtask[pos];
            if tot > rem {
                break;
            }
            pos += 1;
        }
        ma = max(ma, comp * (t.len() + 1) + pos);
    }
    println!("{}", ma);
}

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


use std::io::prelude::*;
use std::io;

fn main() {
    let stdin = io::stdin();
    let mut s = stdin.lock().lines().next().unwrap().unwrap();

    is_nice_word(&s);
}

fn is_nice_word(s: &String) {

    // list of the last position each letter A-Z was seen
    let mut laspos = [-1; 26];
    //how many wildcards '?' there were in the last 26 characters
    let mut wildcd = 0;

    for i in 0..(s.len()) {
        match s.chars().skip(i).next().unwrap() {
            '?' => {
                wildcd += 1;
            },
            chr => {
                laspos[((chr as u8) - ('A' as u8)) as usize] = i;
            }
        }

        if i > 26 {
            match s.chars().skip(i-26).next().unwrap() {
                '?' => {
                    wildcd -= 1;
                },
                _ => ()
            }
        }

        // count how many letters occur in the last 26 characters and remember the ones that didn't
        // also keep track of how many wildcards we have seen
        let mut count = 0;
        let mut letters : Vec<char>= vec![];
        for j in 0..26 {
            if i - laspos[j] < 26 {
                count += 1;
            } else {
                letters.push((('A' as u8) + j as u8) as char);
            }
        }

        //If we have seen enough characters and wildcards, print out the string.
        if count + wildcd >= 26 {
            for chr in s.chars().skip(i-25).take(26) {
                match chr {
                    '?' => {
                        print!("{}", letters.pop().unwrap_or('?'));
                    },
                    c => {
                        print!("{}", c);
                    }
                }
            }
            println!("");
            return;
        }

    }

    println!("-1");
}


use std::io;

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

    let words = s
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    for i in 1..10 {
        if i * words[0] % 10 == words[1] || i * words[0] % 10 == 0 {
            println!("{}", i);
            break;
        }
    }
}


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

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

fn main() {
    read_line!(even;u64, odd;u64);
    if odd == even || odd = even + 1 {
        println!("YES")
    } else {
        println!("NO")
    }
}


fn calcular_white(c:char) -> i32{
    match c{
        'Q'=> 9,
        'R'=> 5,
        'B'=> 3,
        'N'=> 3,
        'P'=> 1,
         _  => 0,
    }

}
fn calcular_black(c:char) -> i32{
    match c{
        'q'=> 9,
        'r'=> 5,
        'b'=> 3,
        'n'=> 3,
        'p'=> 1,
        _  => 0,
    }

}

fn main(){
    let mut i = 1;
    let mut whiteCount = 0;
    let mut blackCount = 0;
    while i <= 8{
        let mut input1 = String::new();
        let a = std::io::stdin().read_line(&mut input1).unwrap();

        for c in input1.chars(){
            blackCount += calcular_black(c);
            whiteCount += calcular_white(c);

        }
        i =i+ 1;
    }

    if whiteCount <  blackCount
        println!("Black");
    }
    else if whiteCount > blackCount{
        println!("White");
    }
    else{
        println!("Draw");
    }
}


fn calcular_white(c:char) -> i32{
    match c{ 'Q'=> 9,
             'R'=> 5,
             'B'=> 3,
             'N'=> 3,
             'P'=> 1,
              _  => 0,}

}
fn calcular_black(c:char) -> i32{
    match c{ 'q'=> 9,
             'r'=> 5,
             'b'=> 3,
             'n'=> 3,
             'p'=> 1,
             _  => 0, }

}

fn main(){
    let mut input = 1;  let mut whiteCount = 0; let mut blackCount = 0;
    while i <= 8{
        let mut input1 = String::new();
        let b1 = std::io::stdin().read_line(&mut input1).unwrap();

        for contC in input.chars(){
            blackCount += calcular_black(contC); whiteCount += calcular_white(contC);

        }
        i += 1;
    }

    if whiteCount <  blackCount
        println!("Black");
    }
    else if whiteCount > blackCount{
        println!("White");
    }
    else{
        println!("Draw");
    }
 }


pub fn get_digits_len(mut k: usize) -> usize {
    let mut n: usize = 1;

    loop {
        k /= 10;

        if k > 0 {
            n+=1;
        }else{
            break n;
        }
    }
}

pub fn get_nth_right_digit(n: usize, k: usize) -> usize {

    (k/usize::pow(10, n as u32)) % 10
}

pub fn get_kth(mut k: usize) -> usize {
    let mut x: usize = 1;

    'outer: loop {
        let n = get_digits_len(x);

        if n > k {
            break get_nth_right_digit(n-k, x);
        } else if (k - n) == 0 {
            break get_nth_right_digit(0, x);
        } else {
            k -= n;
        }

        x += 1;
    }
}

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

fn main() {
    println!("{}", io::stdin().lock().lines().take(1).map(|l| str::parse::<usize>(&l.unwrap()).unwrap()).map(|k| get_kth(k)).last().unwrap())
}


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

// Extended Euclidean GCD {{{
fn extended_euclid(a: i64, b: i64) -> (i64,i64,i64) {
	if b == 0 {
		(a,1,0)
	} else {
		let q = a.div_euclid(b);
		let r = a.rem_euclid(b);
		let (d,x,y) = extended_euclid(b, r);
		(d, y, x-q*y)
	}
}//}}}
fn div_floor(a: i64, b: i64) -> i64 {
	assert!(b != 0);
	let (a,b) = if b < 0 {(-a,-b)} else {(a,b)};
	if a % b == 0 || a >= 0 {
		a / b
	} else {
		a / b - 1
	}
}
fn div_ceil(a: i64, b: i64) -> i64 {
	assert!(b != 0);
	let (a,b) = if b < 0 {(-a,-b)} else {(a,b)};
	if a % b == 0 || a <= 0 {
		a / b
	} else {
		a / b + 1
	}
}

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

	l!(n,p,a,b = rin.l());
	let (g,x0,y0) = extended_euclid(a,b);
	if p % g == 0 {
		let e = p / g;
		let x = x0 * e;
		let y = y0 * e;
		let ca = -b / g;
		let cb = a / g;
		let kx0 = div_ceil(n - x, ca);
		let kx1 = div_floor(-x, ca);
		let ky0 = div_ceil(-y, cb);
		let ky1 = div_floor(n - y, cb);
		let k0 = kx0.max(ky0);
		let k1 = kx1.min(ky1);
		if k0 <= k1 {
			for k in vec![k0,k1] {
				let xx = x + k * ca;
				let yy = y + k * cb;
				if xx + yy <= n {
					writeln!(rout, "{} {} {}", xx, yy, n - xx - yy).ok();
					return;
				}
			}
		}
	}
	writeln!(rout, "-1").ok();
}


use std::io;
use std::io::prelude::*;
use std::cmp;
macro_rules! scan {
    (  $( $x:ty ),+ ) => {{
    let mut s =String::new();
        io::stdin().read_line(& mut s);

        let mut iter = s.split_whitespace();
        ($(iter.next().and_then(|word| word.parse::<$x>().ok()).unwrap(),)*)
    }}
}

fn main(){

    let (k,n,w,z)= scan!(i64,i64,i64);

    let r =cmp::max(0i64, (w*(w+1))/2 *k -n);
    print!("{}",r);

}


fn main() -> std::io::Result<()> {
    let mut contents = String::new();
	std::io::stdin().read_line(&mut contents)?;
	let contents: Vec<&str> = contents.split("\r\n").collect();
	let contents: &str = contents[0];
	let _num:u32 = contents.parse().unwrap();
    let mut contents = String::new();
	std::io::stdin().read_line(&mut contents)?;
	let contents: Vec<&str> = contents.split("\r\n").collect();
	let contents: Vec<&str> = contents[0].split_whitespace().collect();
	let mut numbers: Vec<u32> = Vec::new();
	for number in contents {
		numbers.push(number.parse().unwrap());
	}
	let mut check: std::collections::HashMap<u32,u32> = std::collections::HashMap::new();
	for &number in &numbers {
		let current = check.get(&number);
		//println!("{:?}", current);
		match current {
			None => check.insert(number, 1),
			Some(numbera) => {
				let new = *numbera+1;
				check.insert(number, new)
			}
		};
	}
	let mut max: u32 = 0;
	for number in &numbers {
		let cur = *check.get(number).unwrap();
		if cur > max{
			max = cur;
		}
	}
	println!("{}",max);
	Ok(())
}


use std::fs::File;
use std::io::prelude::*;
use std::path::Path;

fn main() -> std::io::Result<()> {
    let mut contents = String::new();
	std::io::stdin().read_line(&mut contents)?;
	let contents: Vec<&str> = contents.split("\r\n").collect();
	let contents: &str = contents[0];
	let num:u32 = contents.parse().unwrap();
    let mut contents = String::new();
	std::io::stdin().read_line(&mut contents)?;
	let contents: Vec<&str> = contents.split("\r\n").collect();
	let contents: Vec<&str> = contents[0].split_whitespace().collect();
	let mut numbers: Vec<u32> = Vec::new();
	for number in contents {
		numbers.push(number.parse().unwrap());
	}
	let mut check: std::collections::HashMap<u32,u32> = std::collections::HashMap::new();
	for number in &numbers {
		let current = check.get(number);
		//println!("{:?}", current);
		match current {
			None => check.insert(*number, 1),
			Some(numbera) => check.insert(*number, *numbera+1)
		};
	}
	let mut max: u32 = 0;
	for number in &numbers {
		let cur = *check.get(number).unwrap();
		if cur > max{
			max = cur;
		}
	}
	println!("{}",max);
	Ok(())
}


use std::io;

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

    let mut t = String::new();
    io::stdin()
        .read_line(&mut t)
        .unwrap()
        .graphemes(true)
        .rev()
        .collect();

    if s == t {
        println!("YES");
    } else {
        println!("NO");
    }
}


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

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

fn main() {
    read_line!(usize);
    enum State {
        Up,
        Hold,
        Down,
    }
    use State::*;
    let mut state = Up;
    let mut prev = 0;
    let mut ans = true;
    for x in read_line!([u16]) {
        match state {
            Hold => {
                if x > prev {
                    ans = false;
                    break;
                }
            }
            Down => {
                if x >= prev {
                    ans = false;
                    break;
                }
            }
            Up => {}
        }
        state = if x < prev {
            Down
        } else if x > prev {
            Up
        } else {
            Hold
        };
        prev = x;
    }
    println!("{}", if ans { "YES" } else { "NO" });
}


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

struct IO {
    buffer: Vec<String>,
    out: BufWriter<Stdout>,
}
impl IO {
    fn new() -> Self {
        Self {
            buffer: vec![],
            out: BufWriter::new(stdout()),
        }
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
    fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }
}

const MOD: u64 = 998244353;

fn fastpow(mut a: u64, mut x: u64) -> u64 {
    let mut r = 1;
    while x != 0 {
        if x & 1 != 0 {
            r = (r * a) % MOD;
        }

        a = (a * a) % MOD;
        x >>= 1;
    }
    r
}

fn modinv(x: u64) -> u64 {
    fastpow(x, MOD - 2)
}

fn solve(io: &mut IO) -> Result<()> {
    let (n, x): (usize, usize) = (io.read(), io.read());
    let mut comb = vec![vec![1; n + 1]; n + 1];
    let mut fact = vec![1; n + 1];

    for i in 1..=n {
        fact[i] = (fact[i - 1] * (i as u64)) % MOD;

        for j in 1..=i {
            let rem = (fact[j] * fact[i - j]) % MOD;
            let rinv = modinv(rem);

            comb[i][j] = (fact[i] * rinv) % MOD;
        }
    }

    let mut dp = vec![vec![0; x + 1]; n + 1];
    dp[0].fill(1);

    for k in 2..=n {
        let mut sum = 0u64;
        for y in 1..=min(k - 1, x) {
            dp[k][y] = (fastpow(y as u64, k as u64) + MOD - sum) % MOD;
            sum = (sum + dp[k][y]) % MOD
        }

        for y in k..=x {
            for i in 0..k {
                let mut a = dp[k - i][y - (k - 1)] * fastpow((k - 1) as u64, i as u64) % MOD;
                a = (a * comb[k][i]) % MOD;

                dp[k][y] = (dp[k][y] + a) % MOD;
            }
        }
    }

    let mut cnt = 0;
    for y in 1..=x {
        cnt = (cnt + dp[n][y]) % MOD;
    }

    writeln!(io.out, "{}", cnt % MOD)
    //Ok(())
}

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

    //for _ in 0..tc {
    solve(&mut io)
    //}
    //Ok(())
}


use std::io;

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

fn main() {

    let line = read_line();
    let is_cap = line.trim().chars().skip(1).all(|ch| ch.is_uppercase());

    if !is_cap {
        print!("{}", line);
    } else {
        print!("{}", line.trim().chars().map(|ch| if ch.is_uppercase() { ch.to_ascii_lowercase() } else { ch.to_ascii_uppercase() }).collect::<String>());
    }
}


use std::io;

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

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

    let a = words[0];
    let b = words[1];
    let years = 0;

    loop {
        if a > b {
            println!("{}", years);
        }
        a *= 3;
        b *= 2;
    }
}


use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    let mut arr : Vec<i32> = s.split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = arr[0];
    let k = arr[1];
    arr = s.split_whitespace().map(|s| s.parse().unwrap());
    let mut ans = 0;
    let mut reff : i32 = 0;
    for (i, x) in arr.enumerate() {
        if i == k-1 {
            reff = x;
        }
        if i < k || x == reff {
            ans ++;
        }
    }
    println!("{}", ans);
}


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

type Mint = ModInt1000000007;

fn main() {
    inputv! {
        n:usize,x:usize,pos:usize
    }
    let mut f = vec![Mint::new(1)];
    for i in 1..1000 {
        let l = *f.last().unwrap();
        f.push(l * Mint::new(i));
    }
    let mut r_count = 0;
    let mut l_count = 0;
    let mut left = 0;
    let mut right = n;
    loop {
        let mid = (left + right) / 2;
        if mid == pos {
            break;
        } else if mid > pos {
            r_count += 1;
            right = mid;
        } else {
            l_count += 1;
            left = mid + 1;
        }
    }
    //dbg!(l_count, r_count);
    if n - x < r_count || x - 1 < l_count {
        println!("0");
        return;
    }
    let mut ans = f[n - x] / f[n - x - r_count] * f[x - 1] / f[x - 1 - l_count]
        * f[n - l_count - r_count - 1];
    println!("{}", ans);
}

//https://github.com/manta1130/competitive-template-rs

use input::*;

pub mod input {
    use std::cell::RefCell;
    use std::io;
    pub const SPLIT_DELIMITER: char = ' ';
    pub use std::io::prelude::*;

    #[macro_export]
    thread_local! {
        pub static INPUT_BUFFER:RefCell<std::collections::VecDeque<String>>=RefCell::new(std::collections::VecDeque::new());
    }

    #[macro_export]
    macro_rules! input_internal {
        ($x:ident : $t:ty) => {
            INPUT_BUFFER.with(|p| {
                if p.borrow().len() == 0 {
                    let temp_str = input_line_str();
                    let mut split_result_iter = temp_str
                        .split(SPLIT_DELIMITER)
                        .map(|q| q.to_string())
                        .collect::<std::collections::VecDeque<_>>();
                    p.borrow_mut().append(&mut split_result_iter)
                }
            });
            let mut buf_split_result = String::new();
            INPUT_BUFFER.with(|p| buf_split_result = p.borrow_mut().pop_front().unwrap());
            let $x: $t = buf_split_result.parse().unwrap();
        };
        (mut $x:ident : $t:ty) => {
            INPUT_BUFFER.with(|p| {
                if p.borrow().len() == 0 {
                    let temp_str = input_line_str();
                    let mut split_result_iter = temp_str
                        .split(SPLIT_DELIMITER)
                        .map(|q| q.to_string())
                        .collect::<std::collections::VecDeque<_>>();
                    p.borrow_mut().append(&mut split_result_iter)
                }
            });
            let mut buf_split_result = String::new();
            INPUT_BUFFER.with(|p| buf_split_result = p.borrow_mut().pop_front().unwrap());
            let mut $x: $t = buf_split_result.parse().unwrap();
        };
    }

    #[macro_export]
    macro_rules! inputv {
    ($i:ident : $t:ty) => {
        input_internal!{$i : $t}
    };
    (mut $i:ident : $t:ty) => {
        input_internal!{mut $i : $t}
    };
    ($i:ident : $t:ty $(,)*) => {
            input_internal!{$i : $t}
    };
    (mut $i:ident : $t:ty $(,)*) => {
            input_internal!{mut $i : $t}
    };
    (mut $i:ident : $t:ty,$($q:tt)*) => {
            input_internal!{mut $i : $t}
            inputv!{$($q)*}
    };
    ($i:ident : $t:ty,$($q:tt)*) => {
            input_internal!{$i : $t}
            inputv!{$($q)*}
    };
}

    pub fn input_all() {
        INPUT_BUFFER.with(|p| {
            if p.borrow().len() == 0 {
                let mut temp_str = String::new();
                std::io::stdin().read_to_string(&mut temp_str).unwrap();
                let mut split_result_iter = temp_str
                    .split_whitespace()
                    .map(|q| q.to_string())
                    .collect::<std::collections::VecDeque<_>>();
                p.borrow_mut().append(&mut split_result_iter)
            }
        });
    }

    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(clippy::match_wild_err_arm)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error",),
            };
            v.push(buf);
        }
        v
    }

    #[allow(clippy::match_wild_err_arm)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error",),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}


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

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

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

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

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

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

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

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

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

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

use std::io::*;
use std::str::FromStr;
use std::char::*;
macro_rules! debug {($($a:expr),*) => {eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}

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

use std::f64;

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

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

const MAX:i64 = 1000000009;
const INF:i64 = std::i64::MAX;
const MOD:i64 = 1e9 as i64 + 7;

struct Graph {
    e: Vec<Vec<usize>>,
    v: Vec<usize>,
    u: Vec<usize>,
    f: Vec<bool>,
    c: i64,
    flag: bool,
    vc: Vec<i64>,
}

impl Graph {
    fn new(n:usize) -> Self {
        Graph {
            e: vec![vec![];n],
            v: vec![],
            u: vec![n;n],
            f: vec![false;n],
            c: 0,
            flag: true,
            vc: vec![0;n],
        }
    }

    fn dfs(&mut self, crt: usize) {
        self.f[crt] = true;
        self.c = self.e[crt].len() as i64;
        if self.c != 2 {
            self.flag = false;
        }

        for i in 0..self.e[crt].len() {
            let v = self.e[crt][i];
            if self.f[v] { continue; }
            self.dfs(v);
        }
    }
}

fn binary_search(s: &Vec<i64>, v:i64) -> usize {
    let mut left = 0;
    let mut right = s.len();

    while right-left > 1 {
        let mid = (right+left)/2;
        //debug!(left,mid,right,s[mid]);
        if s[mid] < v { left = mid; }
        else { right = mid; }
    }
    left
}

fn neighbors(tree: &BTreeSet<usize>, val: usize) -> (Option<&usize>, Option<&usize>) {
    use std::ops::Bound::*;

    let mut before = tree.range((Unbounded, Excluded(val)));
    let mut after = tree.range((Excluded(val), Unbounded));

    (before.next_back(), after.next())
}

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

const MAX_A:i64 = 1e16 as i64;

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

struct BIT {
    n: usize,
    bit: Vec<i64>,
}

impl BIT {
    fn new(n:usize) -> BIT {
        BIT {
            n,
            bit: vec![0;n+1],
        }
    }

    fn add(&mut self, a:usize, w:i64) {
        let mut x = a;
        while x <= self.n {
            self.bit[x] += w;
            x += (x as i64 & -(x as i64)) as usize;
        }
    }

    fn sum(&self, a:usize) -> i64 {
        let mut ret = 0;
        let mut x = a as i64;
        while x > 0 {
            ret += self.bit[x as usize];
            x -= x & -x;
        }
        ret
    }
}

fn prime_factor(n: i64) -> BTreeMap<i64,i64> {
    let mut n = n;
    let mut map = BTreeMap::new();
    let mut i = 2;
    while i*i <= n {
        while n%i == 0 {
            let count = map.entry(i).or_insert(0);
            *count += 1;
            n /= i;
        }
        i += 1;
    }
    if n!=1 { map.insert(n,1); }
    map
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }

    input! {
        n: i64,
    }

    let fac = prime_factor(n);
    let d = *fac.iter().next().unwrap().0;
    //debug!(d);
    puts!("{}\n", n/d);
}

/*

n から最小の素数の約数を引いていく、何回操作ができるか。

34, 32, 30, 28, .., 2, 0
31, 0
6, 4, 2, 0
10, 8, 6, 4,

約数列挙、最小の素数見つける、それで割る？

*


use std::cmp;
use std::io;
use std::str::SplitWhitespace;

fn main() {
    let size = read_size();

    let mut v: Vec<i32> = vec![0; size as usize];

    let array_str = read_line();
    let mut iter = array_str.split_whitespace();

    for i in 0..size {
        v[i as usize] = read_split(&mut iter);
    }

    v.sort();

    let mut total = 0;
    for el in v.iter() {
        total += el;
    }

    let mut answer = total;

    for el in v.iter() {
        total -= el;
        answer = cmp::max(answer, total - el);
    }

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

fn read_size() -> i32 {
    let size_str = read_line();
    let mut iter = size_str.split_whitespace();
    read_split(&mut iter)
}

fn read_split(iter: &mut SplitWhitespace) -> i32 {
    iter.next().unwrap_or("-1").parse::<i32>().unwrap_or(-1)
}

fn read_line() -> String {
    let mut first_line = String::new();
    io::stdin()
        .read_line(&mut first_line)
        .expect("stdin read error");
    first_line
}


def main():
    n = int(input())
    a = list(map(int, input().split(' ')))
    sum = 0
    for x in a:
        sum += x
    one = (2 * sum) // n
    used = [False] * n
    for i, x in enumerate(a):
        if not used[i]:
            used[i] = True
            for j, y in enumerate(a):
                if not used[j] and y == one - x:
                    used[j] = True
                    print(i + 1, j + 1, end = '\n')
                    break

if __name__ == "__main__":
    main()


use std::{cell::Cell, cmp::{Reverse, max, min}, collections::{BTreeMap, HashMap, HashSet}, error::Error, fmt::Display, io::{BufWriter, Read, Write}, iter::Peekable, mem::swap, ops::{Not, Range, RangeInclusive, Sub}, process::exit, rc::Rc, str::{FromStr, from_utf8, from_utf8_unchecked}};

const IO_BUF_SIZE: usize = 1 << 16;
struct Scanner<'a, R: Read> {
    src: &'a mut R,
    _buf: Vec<u8>,
    _pt: usize, // pointer
    _rd: usize, // bytes read
}

#[allow(dead_code)]
impl<'a, R: Read> Scanner<'a, R> {
    fn new(src: &'a mut R) -> Scanner<'a, 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 char(&mut self) -> char { self.byte() as char }
    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 token(&mut self) -> String { unsafe { String::from_utf8_unchecked(self.token_bytes()) } }

    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
    }
    fn line(&mut self) -> String { unsafe { String::from_utf8_unchecked(self.line_bytes()) } }

    fn read<T: FromStr>(&mut self) -> T {
        let token = self.token_bytes();
        unsafe { from_utf8_unchecked(&token).parse::<T>().ok().unwrap()  }
    }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.read()).collect() }
    fn vec2<T: FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> { (0..n).map(|_| self.vec(m)).collect() }
}

trait ToCharVec { fn to_char_vec(&self) -> Vec<char>; }
impl ToCharVec for &str { fn to_char_vec(&self) -> Vec<char> { self.chars().collect() } }
impl ToCharVec for String { fn to_char_vec(&self) -> Vec<char> { self.chars().collect() } }
trait JoinToStr {
    fn join_to_str(&mut self, sep: &str) -> String;
    fn concat_to_str(&mut self) -> String;
}
impl<T: ToString, I: Iterator<Item = T>> JoinToStr for I {
    fn join_to_str(&mut self, sep: &str) -> String {
        let mut res = String::new();
        match self.next() {
            None => res,
            Some(first) => {
                res.push_str(&first.to_string());
                loop {
                    match self.next() {
                        None => break,
                        Some(item) => {
                            res.push_str(sep);
                            res.push_str(&item.to_string())
                        }
                    }
                }
                res
            }
        }
    }

    fn concat_to_str(&mut self) -> String {
        let mut res = String::new();
        for item in self { res.push_str(&item.to_string()); }
        res
    }
}

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

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

// * end commons * //

mod modint {

    use std::{convert::Infallible, iter::Sum, mem::swap, ops::AddAssign};

    pub trait RemEuclidU32: Copy {
        /// Calculates `self` _mod_ `modulus` losslessly.
        fn rem_euclid_u32(self, modulus: u32) -> u32;

        fn pow_mod(self, exponent: u64, modulus: u32) -> u32 {
            pow_mod_raw(self.rem_euclid_u32(modulus), exponent, modulus)
        }
        fn mul_mod<Rhs: RemEuclidU32>(self, rhs: Rhs, modulus: u32) -> u32 {
            mul_mod_u32(self.rem_euclid_u32(modulus), rhs.rem_euclid_u32(modulus), modulus)
        }

        fn mod_pow_vec(self, n: usize, modulus: u32) -> Vec<u32> {
            let a = self.rem_euclid_u32(modulus);
            let mut res = vec![0u32; n+1];
            if modulus == 1 { return res; }
            res[0] = 1;
            for i in 1..=n {
                res[i] = mul_mod_u32(a, res[i-1], modulus);
            }
            res
        }
    }

    macro_rules! impl_rem_euclid_u32_for_small_signed {
        ($($ty:tt),*) => {
            $(
                impl RemEuclidU32 for $ty {
                    #[inline]
                    fn rem_euclid_u32(self, modulus: u32) -> u32 {
                        (self as i64).rem_euclid(i64::from(modulus)) as _
                    }
                }
            )*
        }
    }

    impl_rem_euclid_u32_for_small_signed!(i8, i16, i32, i64, isize);

    impl RemEuclidU32 for i128 {
        #[inline]
        fn rem_euclid_u32(self, modulus: u32) -> u32 {
            self.rem_euclid(i128::from(modulus)) as _
        }
    }

    macro_rules! impl_rem_euclid_u32_for_small_unsigned {
        ($($ty:tt),*) => {
            $(
                impl RemEuclidU32 for $ty {
                    #[inline]
                    fn rem_euclid_u32(self, modulus: u32) -> u32 {
                        self as u32 % modulus
                    }
                }
            )*
        }
    }

    macro_rules! impl_rem_euclid_u32_for_large_unsigned {
        ($($ty:tt),*) => {
            $(
                impl RemEuclidU32 for $ty {
                    #[inline]
                    fn rem_euclid_u32(self, modulus: u32) -> u32 {
                        (self % (modulus as $ty)) as _
                    }
                }
            )*
        }
    }

    impl_rem_euclid_u32_for_small_unsigned!(u8, u16, u32);
    impl_rem_euclid_u32_for_large_unsigned!(u64, u128);

    #[cfg(target_pointer_width = "32")]
    impl_rem_euclid_u32_for_small_unsigned!(usize);

    #[cfg(target_pointer_width = "64")]
    impl_rem_euclid_u32_for_large_unsigned!(usize);
    #[inline]
    pub fn mul_mod_u32(a: u32, b: u32, m: u32) -> u32 {
        ((a as u64) * (b as u64) % (m as u64)) as u32
    }

    #[inline]
    fn norm(a: u32, m: u32) -> u32 {
        (((a as i32) >> 31) as u32 & m) + a
    }
    // for a, b < m < 2^31, undefined otherwise
    #[inline]
    pub fn add_mod_raw(a: u32, b: u32, m: u32) -> u32 {
        sub_mod_raw(a, m-b, m)
        //norm(a.wrapping_add(b).wrapping_sub(m), m)
    }
    #[inline]
    pub fn sub_mod_raw(a: u32, b: u32, m: u32) -> u32 {
        let (r, c) = a.overflowing_sub(b);
        if c { r + m } else { r }
        //norm(a.wrapping_sub(b), m)
    }
    pub fn pow_mod_raw(a: u32, mut k: u64, m: u32) -> u32 {
        if m == 1 { return 0; }
        let mut a= a as u64;
        let m = m as u64;
        let mut r: u64 = 1;
        while k > 0 {
            if k & 1 == 1 {
                r = r * a % m;
            }
            k >>= 1;
            a = a * a % m;
        }
        return r as u32;
    }

    /// # Parameters
    /// * `b` `1 <= b`
    /// # Returns
    /// (x, g) s.t. g = gcd(a, b), xa = g (mod b), 0 <= x < b/g
    pub fn inv_gcd(a: i64, b: i64) -> (i64, i64) {
        let a = a.rem_euclid(b);
        if a == 0 { return (0, b); }
        let mut s = b;
        let mut t = a;
        let mut m0 = 0;
        let mut m1 = 1;

        while t != 0 {
            let u = s / t;
            s -= t * u;
            m0 -= m1 * u;
            std::mem::swap(&mut s, &mut t);
            std::mem::swap(&mut m0, &mut m1);
        }

        if m0 < 0 { m0 += b / s; }
        (m0, s)
    }

    #[derive(Clone, Copy, PartialEq, Eq, Hash, Default)]
    #[repr(transparent)]
    pub struct ModInt { pub val: u32 }

    impl ModInt {
        #[inline(always)]
        pub fn modulus() -> u32 { crate::get_modulus() }
        pub fn new<I: RemEuclidU32>(val: I) -> Self { Self::raw(val.rem_euclid_u32(Self::modulus())) }
        #[inline]
        pub fn raw(val: u32) -> Self { Self { val } }
        pub fn inv(self) -> Self {
            let (x, gcd) = inv_gcd(self.val.into(), Self::modulus().into());
            if gcd != 1 { panic!("the multiplicative inverse {}^-1 mod {} does not exist", self.val, Self::modulus()) }
            Self::raw(x as u32)
        }
        pub fn pow(self, k: u64) -> Self {
            Self::raw(pow_mod_raw(self.val, k, Self::modulus()))
        }
        pub fn pow_vec(self, n: usize) -> Vec<Self> {
            let mut res = vec![Self::raw(0); n+1];
            res[0] += 1;
            for i in 1..=n {
                res[i] = res[i-1] * self;
            }
            res
        }
    }

    #[inline]
    pub fn mi<I: RemEuclidU32>(val: I) -> ModInt { ModInt::new(val) }

    impl<V: RemEuclidU32> From<V> for ModInt {
        #[inline]
        fn from(from: V) -> Self { Self::new(from) }
    }
    impl std::str::FromStr for ModInt {
        type Err = std::convert::Infallible;
        #[inline]
        fn from_str(s: &str) -> Result<Self, Self::Err> {
            Ok(s.parse::<i64>()
            .map(Self::new)
            .unwrap_or_else(|_| todo!("parsing as an arbitrary precision integer?")))
        }
    }
    impl std::fmt::Display for ModInt {
        #[inline]
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            std::fmt::Display::fmt(&self.val, f)
        }
    }
    impl std::fmt::Debug for ModInt {
        #[inline]
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            std::fmt::Debug::fmt(&self.val, f)
        }
    }
    impl std::ops::Neg for ModInt {
        type Output = ModInt;

        #[inline]
        fn neg(self) -> Self::Output {
            Self::raw(0) - self
            //Self::raw(norm(self.val.wrapping_neg(), Self::modulus()))
        }
    }

    impl std::ops::Add for ModInt {
        type Output = ModInt;
        #[inline]
        fn add(self, rhs: Self) -> Self::Output {
            Self::raw(add_mod_raw(self.val, rhs.val, Self::modulus()))
        }
    }
    impl std::ops::Sub for ModInt {
        type Output = ModInt;
        #[inline]
        fn sub(self, rhs: Self) -> Self::Output {
            Self::raw(sub_mod_raw(self.val, rhs.val, Self::modulus()))
        }
    }
    impl std::ops::Mul for ModInt {
        type Output = ModInt;
        #[inline]
        fn mul(self, rhs: Self) -> Self::Output {
            Self::raw(mul_mod_u32(self.val, rhs.val, Self::modulus()))
        }
    }
    impl std::ops::Div for ModInt {
        type Output = ModInt;
        #[inline]
        fn div(self, rhs: Self) -> Self::Output { self * rhs.inv() }
    }

    impl <I: RemEuclidU32> std::ops::Add<I> for ModInt {
        type Output = ModInt;
        #[inline]
        fn add(self, rhs: I) -> Self::Output { self + Self::new(rhs) }
    }
    impl <I: RemEuclidU32> std::ops::Sub<I> for ModInt {
        type Output = ModInt;
        #[inline]
        fn sub(self, rhs: I) -> Self::Output { self - Self::new(rhs) }
    }
    impl <I: RemEuclidU32> std::ops::Mul<I> for ModInt {
        type Output = ModInt;
        #[inline]
        fn mul(self, rhs: I) -> Self::Output { self * Self::new(rhs) }
    }
    impl <I: RemEuclidU32> std::ops::Div<I> for ModInt {
        type Output = ModInt;
        #[inline]
        fn div(self, rhs: I) -> Self::Output { self / Self::new(rhs) }
    }

    impl std::ops::AddAssign for ModInt {
        #[inline]
        fn add_assign(&mut self, rhs: Self) { *self = *self + rhs; }
    }
    impl std::ops::SubAssign for ModInt {
        #[inline]
        fn sub_assign(&mut self, rhs: Self) { *self = *self - rhs; }
    }
    impl std::ops::MulAssign for ModInt {
        #[inline]
        fn mul_assign(&mut self, rhs: Self) { *self = *self * rhs; }
    }
    impl std::ops::DivAssign for ModInt {
        #[inline]
        fn div_assign(&mut self, rhs: Self) { *self = *self / rhs; }
    }
    impl <I: RemEuclidU32> std::ops::AddAssign<I> for ModInt {
        #[inline]
        fn add_assign(&mut self, rhs: I) { *self = *self + rhs; }
    }
    impl <I: RemEuclidU32> std::ops::SubAssign<I> for ModInt {
        #[inline]
        fn sub_assign(&mut self, rhs: I) { *self = *self - rhs; }
    }
    impl <I: RemEuclidU32> std::ops::MulAssign<I> for ModInt {
        #[inline]
        fn mul_assign(&mut self, rhs: I) { *self = *self * rhs; }
    }
    impl <I: RemEuclidU32> std::ops::DivAssign<I> for ModInt {
        #[inline]
        fn div_assign(&mut self, rhs: I) { *self = *self / rhs; }
    }

    impl std::iter::Sum for ModInt {
        #[inline]
        fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
            iter.fold(Self::raw(0), std::ops::Add::add)
        }
    }
    impl std::iter::Product for ModInt {
        #[inline]
        fn product<I: Iterator<Item = Self>>(iter: I) -> Self {
            iter.fold(1.into(), std::ops::Mul::mul)
        }
    }
}

const MODULUS: u32 = 998_244_353;
//const MODULUS: u32 = 1_000_000_007;
#[inline(always)]
fn get_modulus() -> u32 { MODULUS }

// static mut MODULUS: u32 = 998244353;
// #[inline] fn get_modulus() -> u32 { unsafe { MODULUS } }
// #[inline] fn set_modulus(value: u32) { unsafe { MODULUS = value; } }

use crate::modint::*;

#[allow(non_snake_case, unused_macros)]
fn main() -> Result<(), Box<dyn Error>> {
    let mut INPUT = std::io::stdin();
    let OUTPUT = std::io::stdout();

    let mut inp = Scanner::new(&mut INPUT);
    let mut out = BufWriter::with_capacity(IO_BUF_SIZE, OUTPUT);

    macro_rules! inp {
        () => { inp.read(); };
        ($t: ty) => { inp.read::<$t>(); };
        ($t: ty, $($tt: ty),*) => { (inp.read::<$t>(), $(inp.read::<$tt>(),)*); };
        [$t: ty; $n: expr] => { inp.vec::<$t>($n); };
    }
    macro_rules! println {
        () => { writeln!(out).unwrap(); };
        ($exp: expr) => { writeln!(out, "{}", $exp).unwrap(); };
        ($fmt: expr, $($arg : tt )*) => { writeln!(out, $fmt, $($arg)*).unwrap(); }
    }
    macro_rules! print {
        ($exp: expr) => { write!(out, "{}", $exp).unwrap(); };
        ($fmt: expr, $($arg : tt )*) => { write!(out, $fmt, $($arg)*).unwrap(); }
    }

    { // solution start
        let num_cases = 1;//inp!(usize);

        for _case_num in 1..=num_cases {
            let n = inp!(usize);
            set_modulus(inp!());

            let mut dp = vec![mi(0); n+1];
            dp[1] = mi(1);
            dp[2] = mi(2);
            for i in 2..n {
                let d = dp[i];
                dp[i+1] += d + d + 1;
                let d = d - dp[i-1];
                for j in (i*2..=n).step_by(i) {
                    dp[j] += d;
                }
            }

            let ans = dp[n];
            println!(ans);
        }
    } // solution end

    out.flush()?;
    Ok(())
}


fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let s: Vec<char> = it.next().unwrap().chars().collect();
    let mut dp = vec![vec![0; n]; n];
    for len in 1..=n {
        for l in 0..=(n - len) {
            let r = l + len - 1;
            dp[l][r] = len;
            if l + 1 < n {
                dp[l][r] = dp[l + 1][r] + 1;
            }
            for k in (l + 1)..=r {
                if s[l] == s[k] {
                    dp[l][r] = std::cmp::min(dp[l][r], dp[l + 1][k - 1] + dp[k][r]);
                }
            }
        }
    }
    println!("{}", dp[0][n - 1]);
}

fn main() {
    run();
}


use std::io;
use std::cmp;
use std::collections::HashMap;
fn read_i32s() -> io::Result<Vec<i32>> {
	let mut input = String::new();
	io::stdin().read_line(&mut input)?;
	let mut vec: Vec<i32> = Vec::new();
	for num in input.split_whitespace() {
		vec.push(num.parse::<i32>().unwrap());
	}
	return Ok(vec);
}

fn main() {
	let vec = read_i32s().unwrap();
	let _n = vec[0];
	let vec = read_i32s().unwrap();
	let mut cnt = HashMap::new();
	let mut mx = 0;
	for num in vec {
		let count = cnt.entry(num).or_insert(0);
		*count += 1;
		mx = cmp::max(mx, num);
	}
	let ans1 = mx;
	let mut t = 1;
	loop {
		if t*t > mx {
			break;
		}
		if mx % t == 0 {
			let count = cnt.entry(t).or_insert(0);
			if t*t == mx {
				break;
			}
			*count -= 1;
			{
				let count = cnt.entry(mx/t).or_insert(0);
				*count -= 1;
			}
		}
		t += 1;
	}
	mx = 0;
	for (key, value) in cnt.iter() {
		if *value != 0 {
			mx = cmp::max(mx, *key);
		}
	}
	let ans2 = mx;
	println!("{} {}", ans1, ans2);
}


use std::io;
use std::io::BufRead;
use std::f64::consts::PI;

#[derive(Debug, Copy, Clone)]
struct Point {
    x: f64,
    y: f64,
}

#[derive(Debug, Copy, Clone)]
struct LinearEquation {
    a: f64,
    b: f64,
    c: f64
}

fn parse_point(s: String) -> Point {
    let split = s.split(' ').collect::<Vec<&str>>();
    assert!(split.len() == 2);
    let x: f64 = split[0].parse().unwrap();
    let y: f64 = split[1].parse().unwrap();
    Point { x, y }
}

fn sqr(x: f64) -> f64 {
    x * x
}

fn find_line_equation(a: Point, b: Point) -> LinearEquation {
    LinearEquation {
        a: 2. * (b.x - a.x),
        b: 2. * (b.y - a.y),
        c: sqr(a.x) + sqr(a.y) - sqr(b.x) - sqr(b.y)
    }
}

fn find_center(a: Point, b: Point, c: Point) -> Point {
    let eq1 = find_line_equation(a, b);
    let eq2 = find_line_equation(a, c);
    let da = eq1.c * eq2.b - eq1.b * eq2.c;
    let db = eq1.a * eq2.c - eq1.c * eq2.a;
    let dc = eq1.a * eq2.b - eq1.b * eq2.a;
    Point { x: -da / dc, y: -db / dc }
}

fn find_angle(p: Point, o: Point) -> f64 {
    let x = p.x - o.x;
    let y = p.y - o.y;
    (y.atan2(x) / (2. * PI) + 1.) % 1.
}

fn is_n_poly(a: f64, n: i32) -> bool {
    let d = 1. / (n as f64);
    let r = ((a / d).round() - a / d).abs();
    r < 0.0001
}

fn find_first_n(a1: f64, a2: f64) -> i32 {
    (1..101).find(|&n| is_n_poly(a1, n) && is_n_poly(a2, n)).unwrap()
}

fn find_area(a: Point, b: Point, c: Point) -> f64 {
    let o = find_center(a, b, c);
    let mut angles = [find_angle(a, o), find_angle(b, o), find_angle(c, o)];
    angles.sort_by(|a, b| a.partial_cmp(b).unwrap());
    let n = find_first_n(angles[1] - angles[0], angles[2] - angles[0]);
    let r_sqr = sqr(a.x - o.x) + sqr(a.y - o.y);
    let half_angle = PI / (n as f64);
    let triangle_size = r_sqr * f64::sin(half_angle) * f64::cos(half_angle);
    triangle_size * (n as f64)
}

fn main() {
    let stdin = io::stdin();
    let points = stdin.lock().lines().take(3).map(|s| parse_point(s.unwrap())).collect::<Vec<_>>();
    assert!(points.len() == 3);
    print!("{}", find_area(points[0], points[1], points[2]));
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(x, y, z) for (int x = y; x <= (z); x++)
#define rep1(x, y, z) for (int x = y; x < (z); x++)
#define dep(x, y, z) for (int x = y; x >= (z); x--)
#define dep1(x, y, z) for (int x = y; x > (z); x--)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof a)
#define endl '\n'

typedef vector<int> vi;
typedef unsigned long long ull;
typedef pair<int, int> pii;

template<class T> void minn(T& a, T b) {if (a > b) a = b;}
template<class T> void maxx(T& a, T b) {if (a < b) a = b;}

const int mod = 998244353;
const int N = 2e5 + 5;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
int n;
int norm(int x) {
    if (x < 0) {
        x += mod;
    }
    if (x >= mod) {
        x -= mod;
    }
    return x;
}
template<class T>
T mfast(T a, int b) {
    T res = 1;
    for (; b; b /= 2, a *= a) {
        if (b % 2) {
            res *= a;
        }
    }
    return res;
}
struct Z {
    int x;
    Z(int x = 0) : x(norm(x)) {}
    int val() const {
        return x;
    }
    Z operator-() const {
        return Z(norm(mod - x));
    }
    Z inv() const {
        assert(x != 0);
        return mfast(*this, mod - 2);
    }
    Z &operator*=(const Z &rhs) {
        x = ll(x) * rhs.x % mod;
        return *this;
    }
    Z &operator+=(const Z &rhs) {
        x = norm(x + rhs.x);
        return *this;
    }
    Z &operator-=(const Z &rhs) {
        x = norm(x - rhs.x);
        return *this;
    }
    Z &operator/=(const Z &rhs) {
        return *this *= rhs.inv();
    }
    Z &operator++() {
        this->x = norm(this->x + 1);
        return *this;
    }
    Z &operator--() {
        this->x = norm(this->x - 1);
        return *this;
    }
    friend Z operator*(const Z &lhs, const Z &rhs) {
        Z res = lhs;
        res *= rhs;
        return res;
    }
    friend Z operator+(const Z &lhs, const Z &rhs) {
        Z res = lhs;
        res += rhs;
        return res;
    }
    friend Z operator-(const Z &lhs, const Z &rhs) {
        Z res = lhs;
        res -= rhs;
        return res;
    }
    friend Z operator/(const Z &lhs, const Z &rhs) {
        Z res = lhs;
        res /= rhs;
        return res;
    }
    friend ostream& operator<<(ostream& os, const Z& lhs) {
        os << lhs.x;
        return os;
    }
    friend istream& operator>>(istream& is, Z& lhs) {
        ll x;
        cin >> x;
        lhs.x = norm(x);
        return is;
    }
};

bool prime(int n) {
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            while (n % i == 0) n /= i;
            return false;
        }
    }
    return true;
}
void solve() {
    ll m;
    cin >> n;
    cin >> m;
    Z tmp = m % mod;
    Z ans = 0;
    rep (i, 2, n) {
        tmp = tmp * (m % mod);
        ans += tmp;
    }
    ll lc = 1;
    vector<Z> x(n + 1);
    rep (i, 2, n) {
        if (prime(i)) {
            lc = lcm(i, lc);
        }
        if (lc > m) {
            break;
        }
#define xxxx x
        x[i] = (m / lc) % mod;
    }
    x[1] = m % mod;
    rep (i, 2, n) {
        x[i] = x[i] * x[i - 1];
        ans -= x[i];
    }
    cout << ans  << endl;
}
signed main()
{
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int T = 1;
    for (int i = 1; i <= T; i++) {
        solve();
    }
}


use std::io;

fn main() {
    let mut a_str = String::new();
    io::stdin().read_line(&mut a_str).expect("");
    let mut v_a = a_str.trim().chars()
        .map(|x| x.to_digit(10).unwrap() as i32)
        .collect::<Vec<i32>>();

    let mut b_str = String::new();
    io::stdin().read_line(&mut b_str).expect("");
    let mut v_b = b_str.trim().chars()
        .map(|x| x.to_digit(10).unwrap() as i32)
        .collect::<Vec<i32>>();

    let n_b = 1;

    let mut res = String::new();
    v_a.sort();
    for i in 0..v_a.len() {
        for j in ((i + 1)..v_a.len()) {
            let mut t = v_a;
            t.swap(i, j);
            let n_t: i64 = t.iter().map(|x| x.to_string()).collect().parse().unwrap();
            let n_a: i64 = v_a.iter().map(|x| x.to_string()).collect().parse().unwrap();
            if (n_a < n_t && n_t < n_b) {
                v_a.swap(i, j);
            }
        }
    }
    res = v_a.iter().map(|x| x.to_string()).collect();
    println!("{}", res);
}


// Basics

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

extern crate rand;

use std::io::prelude::*;
use std::mem;
use std::io;
use std::io::BufRead;
use std::io::BufReader;
use std::string;
use std::cmp::*;
use std::collections::*;
use std::vec::Vec;
use std::collections::LinkedList;
use std::num;
use std::ops;
use std::fmt::Debug;
use std::str::FromStr;
use rand::Rng;
use std::ops::Shr;

struct Cin {
    data: LinkedList<String>,
}

impl Cin {
    fn new() -> Self {
        Cin { data: LinkedList::new() }
    }
    fn read_line(&self) -> String {
        let mut s: String = String::new();
        io::stdin().read_line(&mut s).expect("err");
        s
    }
    fn read_str(&mut self) -> String {
        if self.data.len() == 0 {
            let s = self.read_line();
//            let split = s.split("\\s+");
            let split = s.split_whitespace();
            for el in split {
                self.data.push_back(String::from(el));
            }
        }
        self.data.pop_front().expect("empty")
    }
    fn read_int(&mut self) -> i64 {
        self.read_str().parse().expect("err parse")
    }
    fn read_vec(&mut self, size: &i64) -> Vec<i64> {
        let mut v: Vec<i64> = Vec::new();
        for _i in 0..*size {
            v.push(self.read_int());
        }
        v
    }
}

fn main() {
    let mut cin = Cin::new();
    let n: i64 = cin.read_int();
    let vec = cin.read_vec(&n);
    let mut s: HashSet<i64> = HashSet::new();
    let mut res: LinkedList<i64> = LinkedList::new();
    for i in 0..vec.len() {
        let ref value = vec[vec.len() - 1 - i];
        let option = s.get(value).is_some();
        if !option {
            s.insert(value.clone());
            res.push_front(*value);
        }
    }
    println!("{}", res.len());
    for r in res { print!("{} ", r); }
    println!();
}


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

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

	l!(xor,sum = rin.l());
	let check = |a: &Vec<_>| -> bool {
		let mut x = 0;
		let mut s = 0;
		for &y in a {
			x ^= y;
			s += y;
		}
		x == xor && s == sum
	};
	let mut sol = None;
	if xor == sum {
		if xor == 0 {
			sol = Some(Vec::new());
		} else {
			sol = Some(vec![xor]);
		}
	} else if xor < sum && (xor ^ sum) % 2 == 0 {
		let d = sum - xor;
		let h = d / 2;
		if check(&vec![xor^h,h]) {
			sol = Some(vec![xor^h,h]);
		} else
			sol = Some(vec![xor,h,h]);
		}
	}
	if let Some(res) = sol {
		writeln!(rout, "{}", res.len()).ok();
		for x in res {
			write!(rout, "{} ", x).ok();
		}
		writeln!(rout, "").ok();
	} else {
		writeln!(rout, "-1").ok();
	}
}


//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::*;
use std::collections::BTreeMap;

fn run() {
    input! {
        n: usize,
        p: [usize; n],
    }
    let mut cnt = [0; 2];
    for p in p.iter() {
        if *p == 0 {
            continue;
        }
        cnt[*p % 2] += 1;
    }
    let even = n / 2 - cnt[0];
    let odd = (n + 1) / 2 - cnt[1];
    let inf = n;
    let mut dp = BTreeMap::<(usize, usize, usize), usize>::new();
    dp.insert((0, even, odd), 0);
    dp.insert((1, even, odd), 0);
    for p in p.iter().rev() {
        let mut next = BTreeMap::<(usize, usize, usize), usize>::new();
        for ((b, x, y), v) in dp {
            if *p == 0 {
                if x > 0 {
                    let po = next.entry((0, x - 1, y)).or_insert(inf);
                    *po = min(*po, v + (b ^ 0));
                }
                if y > 0 {
                    let po = next.entry((1, x, y - 1)).or_insert(inf);
                    *po = min(*po, v + (b ^ 1));
                }
            } else {
                let po = next.entry((*p % 2, x, y)).or_insert(inf);
                *po = min(*po, v + (b ^ (*p & 1)));
            }
        }
        dp = next;
    }
    let mut ans = inf;
    for (_, v) in dp {
        ans = min(ans, v);
    }
    println!("{}", ans);
}

fn main() {
    run();
}


use std::io;

fn read_line() -> (f64) {
    let mut input = String::new();

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

    let n: f64 = input.trim().parse().unwrap();

    n
}

fn main(){

    let n  = read_line();

    let log = n.log2().floor();
    let bacterias = 1.0 + (n - (2.0 as f64).powf(log));

    println!("{}", bacterias as i64);
}


#![allow(dead_code, unused_imports)]

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

const MODULO: u64 = 1_000_000_007;

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

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

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

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

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

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

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

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

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

fn main() -> Result<(), Box<dyn std::error::Error>> {
    println!("Karen");
    Ok(())
}


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

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

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

fn _main() {
    let mut scan = Scan::new();
    let a: usize = scan.next();
    let b: usize = scan.next();
    if a == b {
        println!("0 6 0");
    } else if a < b {
        let middle = a.max(b) - a.min(b) - 1;
        println!(
            "{} {} {}",
            a + middle / 2,
            middle % 2,
            6 - b + 1 + middle / 2
        );
    } else {
        let middle = a.max(b) - a.min(b) - 1;
        println!(
            "{} {} {}",
            6 - a + 1 + middle / 2,
            middle % 2,
            b + middle / 2
        );
    }
}

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


use std::io::{self, BufRead};
// use std::collections::*; // HashSet, HashMap, BTreeSet, BTreeMap, ...

fn main() {
    let stdin: io::Stdin = io::stdin();
    let mut lines: io::Lines<io::StdinLock> = stdin.lock().lines();

    let next_line = lines.next()
        .unwrap() // Option<Result> { Some(Result), None }
        .unwrap(); // Result<String, io::Error> { Ok(String), Err(io::Error) }

    let flv: Vec<_> = next_line
        .trim()
        .split(' ')
        .map(|n| {
            n.parse::<usize>().unwrap()
        })
        .collect();

    let n = flv[0];

    let mut s: String = lines.next()
        .unwrap()
        .unwrap()
        .trim()
        .to_string();

    for i in 2..n {
        if n % i == 0 {
            let tmp_end = s.split_off(i);
            s = s.chars().rev().collect();
            s.push_str(&tmp_end);
            // println!("{}: {}", i, s);
        }
    }
    s = s.chars().rev().collect();

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


#[allow(dead_code)]
fn scan<T: std::str::FromStr>() -> T
{
	static mut BUFFER: Vec<String> = vec![];
	loop {
		if let Some(token) = unsafe { BUFFER.pop() } {
			return token.parse().ok().unwrap();
		}
		let mut input = String::new();
		std::io::stdin().read_line(&mut input).ok();
		unsafe { BUFFER = input.split_whitespace().rev().map(String::from).collect(); }
	}
}

struct Comb {
	modu: i64,
	fact: Vec<i64>,
	ifact: Vec<i64>,
}

impl Comb {
	fn mpow(&self, mut x: i64, mut y: i64) -> i64
	{
		let mut ans = 1;
		while y > 0 {
			if y&1 == 1 {
				ans = ans*x % self.modu;
			}
			x = x*x % self.modu;
			y >>= 1;
		}
		ans
	}

	fn inv(&self, x: i64) -> i64 { self.mpow(x, self.modu-2) }

	fn new(modu: i64, size: usize) -> Self
	{
		assert!(size > 1);
		let mut tmp = Self { modu, fact: vec![0; size], ifact: vec![0; size] };
		tmp.fact[0] = 1;
		for i in 1..size {
			tmp.fact[i] = tmp.fact[i-1] * i as i64 % modu;
		}
		tmp.ifact[size-1] = tmp.inv(tmp.fact[size-1]);
		for i in (1..size).rev() {
			tmp.ifact[i-1] = tmp.ifact[i] * i as i64 % modu;
		}
		tmp
	}

	fn C(&self, n: i64, r: i64) -> i64
	{
		if 0 <= r && r <= n {
			self.fact[n as usize] * self.ifact[r as usize] % self.modu * self.ifact[(n-r) as usize] % self.modu
		} else {
			0
		}
	}

}

fn main()
{
	let n = scan::<i64>();
	let modu = scan::<i64>();
	let cb = Comb::new(modu, n as usize + 10);

	let mut ans = 0i64;
	for a in 0..=n {
		let b = n-a;
		let mut s = 0i64;
		for c in 0..=b {
			s += cb.C(b-1, c-1) * cb.C(a, c) % modu * cb.mpow(b, a-c) % modu * cb.mpow(n-1, c);
		}
		ans += s * cb.C(n, a) % modu * cb.fact[b as usize] % modu;
	}
	ans %= modu;
	println!("{}", ans);
}


#[allow(dead_code)]
fn scan<T: std::str::FromStr>() -> T
{
	static mut BUFFER: Vec<String> = vec![];
	loop {
		if let Some(token) = unsafe { BUFFER.pop() } {
			return token.parse().ok().unwrap();
		}
		let mut input = String::new();
		std::io::stdin().read_line(&mut input).ok();
		unsafe { BUFFER = input.split_whitespace().rev().map(String::from).collect(); }
	}
}

struct Comb {
	modu: i64,
	fact: Vec<i64>,
	ifact: Vec<i64>,
}

impl Comb {
	fn mpow(&self, mut x: i64, mut y: i64) -> i64
	{
		let mut ans = 1;
		while y > 0 {
			if y&1 == 1 {
				ans = ans*x % self.modu;
			}
			x = x*x % self.modu;
			y >>= 1;
		}
		ans
	}

	fn inv(&self, x: i64) -> i64 { self.mpow(x, self.modu-2) }

	fn new(modu: i64, size: usize) -> Self
	{
		assert!(size > 1);
		let mut tmp = Self { modu, fact: vec![0; size], ifact: vec![0; size] };
		tmp.fact[0] = 1;
		for i in 1..size {
			tmp.fact[i] = tmp.fact[i-1] * i as i64 % modu;
		}
		tmp.ifact[size-1] = tmp.inv(tmp.fact[size-1]);
		for i in (1..size).rev() {
			tmp.ifact[i-1] = tmp.ifact[i] * i as i64 % modu;
		}
		tmp
	}

	fn C(&self, n: i64, r: i64) -> i64
	{
		if 0 <= r && r <= n {
			self.fact[n as usize] * self.ifact[r as usize] % self.modu * self.ifact[(n-r) as usize] % self.modu
		} else {
			0
		}
	}

}

fn main()
{
	let n = scan::<i64>();
	let modu = scan::<i64>();
	let cb = Comb::new(modu, n as usize + 10);

	let mut ans = 0i64;
	for a in 0..=n {
		let b = n-a;
		let mut s = 0i64;
		for c in 0..=b {
			s += cb.C(b-1, c-1) * cb.C(a, c) % modu * cb.mpow(b, a-c) % modu * cb.mpow(n-1, c) % modu;
		}
		s %= modu;
		ans += s * cb.C(n, a) % modu * cb.fact[b as usize] % modu;
	}
	ans %= modu;
	println!("{}", ans);
}


#[allow(dead_code)]
fn scan<T: std::str::FromStr>() -> T
{
	static mut BUFFER: Vec<String> = vec![];
	loop {
		if let Some(token) = unsafe { BUFFER.pop() } {
			return token.parse().ok().unwrap();
		}
		let mut input = String::new();
		std::io::stdin().read_line(&mut input).ok();
		unsafe { BUFFER = input.split_whitespace().rev().map(String::from).collect(); }
	}
}

struct Comb {
	modu: i64,
	fact: Vec<i64>,
	ifact: Vec<i64>,
}

impl Comb {
	fn mpow(&self, mut x: i64, mut y: i64) -> i64
	{
		let mut ans = 1;
		while y > 0 {
			if y&1 == 1 {
				ans = ans*x % self.modu;
			}
			x = x*x % self.modu;
			y >>= 1;
		}
		ans
	}

	fn inv(&self, x: i64) -> i64 { self.mpow(x, self.modu-2) }

	fn new(modu: i64, size: usize) -> Self
	{
		assert!(size > 1);
		let mut tmp = Self { modu, fact: vec![0; size], ifact: vec![0; size] };
		tmp.fact[0] = 1;
		for i in 1..size {
			tmp.fact[i] = tmp.fact[i-1] * i as i64 % modu;
		}
		tmp.ifact[size-1] = tmp.inv(tmp.fact[size-1]);
		for i in (1..size).rev() {
			tmp.ifact[i-1] = tmp.ifact[i] * i as i64 % modu;
		}
		tmp
	}

	fn C(&self, n: i64, r: i64) -> i64
	{
		if 0 <= r && r <= n {
			self.fact[n as usize] * self.ifact[r as usize] % self.modu * self.ifact[(n-r) as usize] % self.modu
		} else {
			0
		}
	}

}

fn main()
{
	let n = scan::<i64>();
	let modu = scan::<i64>();
	let cb = Comb::new(modu, n as usize + 10);

	let mut ans = 0i64;
	for a in 0..=n {
		let b = n-a;
        let kooft_step = cb.inv(b) * (n-1) % modu;
        let mut kooft = cb.mpow(b, a);
		let mut s = 0i64;
		for c in 0..=std::cmp::min(a, b) {
			s += cb.C(b-1, c-1) * cb.C(a, c) % modu * kooft % modu;
            kooft = kooft * kooft_step % modu;
		}
		s %= modu;
		ans += s * cb.C(n, a) % modu * cb.fact[b as usize] % modu;
	}
	ans %= modu;
	println!("{}", ans);
}


fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let mut n: u64 = it.next().unwrap().parse().unwrap();
    let m: usize = it.next().unwrap().parse().unwrap();
    let p = 10;
    let mut cnt = vec![0; p];
    while n > 0 {
        let k = (n % p as u64) as usize;
        cnt[k] += 1;
        n /= p as u64;
    }
    let mut step = vec![1; p + 1];
    for i in (0..p).rev() {
        step[i] = step[i + 1] * (cnt[i] + 1);
    }
    let len = step[0];
    let mut dp = vec![vec![0u64; len]; m];
    dp[0][len - 1] = 1;
    let mut q = std::collections::VecDeque::new();
    q.push_back((0, len - 1));
    while let Some((rem, v)) = q.pop_front() {
        for d in 0..p {
            let a = v % step[d] / step[d + 1];
            if a > 0 && !(d == 0 && v == len - 1) {
                let u = v - step[d + 1];
                let r = (10 * rem + d) % m;
                if dp[r][u] == 0 {
                    q.push_back((r, u));
                }
                dp[r][u] += dp[rem][v];
            }
        }
    }
    let ans = dp[0][0];
    println!("{}", ans);
}

fn main() {
    run();
}


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

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

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

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

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

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

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

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

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

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

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

    result
}

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

    let mut memo = HashMap::new();

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


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

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

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

fn run() {
    input! {
        s: bytes,
    }
    if s.len() > 1 && s[0] == b'0' {
        println!("0");
        return;
    }
    let mut x = 1;
    if s.contains(&b'X') {
        x = 10;
    }
    let mut ans = 0;
    for v in 0..x {
        let mut dp = [0; 25];
        dp[0] = 1u64;
        for (i, s) in s.iter().enumerate() {
            if *s == b'_' {
                let mut s = 0;
                if i == 0 {
                    s = 1;
                }
                let mut next = [0; 25];
                for d in s..10 {
                    for (i, dp) in dp.iter().enumerate() {
                        next[(i * 10 + d) % 25] += *dp;
                    }
                }
                dp = next;
            } else if *s == b'X' {
                if i == 0 && v == 0 {
                    dp = [0; 25];
                    break;
                }
                let k = v;
                let mut next = [0; 25];
                for d in k..(k + 1) {
                    for (i, dp) in dp.iter().enumerate() {
                        next[(i * 10 + d) % 25] += *dp;
                    }
                }
                dp = next;
            } else {
                let k = (*s - b'0') as usize;
                let mut next = [0; 25];
                for d in k..(k + 1) {
                    for (i, dp) in dp.iter().enumerate() {
                        next[(i * 10 + d) % 25] += *dp;
                    }
                }
                dp = next;
            }
        }
        ans += dp[0];
    }
    println!("{}", ans);
}

fn main() {
    run();
}


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

fn compare(x: i32, y: i32) -> i32 {
    if x == y {
        return 0;
    }
    if (x == 2 && y == 4) || (x == 4 && y == 2) {
        return 0;
    }

    if x <= 3 && y <= 3 {
        return if x < y { -1 } else { 1 };
    }
    if x >= 3 && y >= 3 {
        return if x < y { 1 } else { -1 };
    }

    if x == 1 {
        return -1;
    }
    if y == 1 {
        return 1;
    }

    if x <= 3 { 1 } else { -1 }
}

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

    let tokens: Vec<&str> = input.split_whitespace().collect();
    let x = tokens[0].parse::<i32>().unwrap();
    let y = tokens[1].parse::<i32>().unwrap();

    match compare(x, y) {
        -1 => println!("<"),
         0 => println!("="),
         1 => println!(">"),
         _ => println!("This shouldn't happen...")
    };
}


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

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

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

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

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

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

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

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

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