#![allow(dead_code, clippy::many_single_char_names, unused_variables, non_snake_case, unused_macros, unused_imports, non_upper_case_globals)]
use std::{
    collections::*,
    io::{stdin, StdinLock, stdout, StdoutLock, BufReader, BufRead, BufWriter, Write},
    mem::swap
};

fn parse<T: std::str::FromStr>(n: &str) -> T {
    match n.parse::<T>() {
        Ok(x) => x,
        _ => panic!()
    }
}

macro_rules! fill {
    ($r: expr, str, $($x: ident),+) => { fill!($r, str, 30, $($x),+) };
    ($r: expr, $t: ty, $($x: ident),+) => { fill!($r, $t, 30, $($x),+) };
    ($r: expr, str, $c: expr, $($x: ident),+) => {
        let t = read!($r, $c);
        let mut t = t.split(' ');

        $(
            $x = t.next().unwrap();
        )+
    };
    ($r: expr, $t: ty, $c: expr, $($x: ident),+) => {
        let t = read!($r, $c);
        let mut t = t.split(' ').map(parse::<$t>);

        $(
            $x = t.next().unwrap();
        )+
    }
}

macro_rules! read {
    ($r: expr) => { read!($r, 20) };
    ($r: expr, str) => { read!($r, 20) };
    ($r: expr, $t: ty) => { parse::<$t>(&read!($r, 20)) };
    ($r: expr, str, $c: expr) => { read!($r, $c) };
    ($r: expr, $t: ty, $c: expr) => { parse::<$t>(&read!($r, $c)) };
    ($r: expr, $c: expr) => {
        {
            let mut s = String::with_capacity($c+2);
            $r.read_line(&mut s).unwrap();

            assert!(s.len() <= $c+2);

            if s.ends_with('\n') {
                s.pop();
                if s.ends_with('\r') {
                    s.pop();
                }
            }
            s
        }
    }
}

macro_rules! read_vec {
    ($r: expr) => { read_vec!($r, str, 10_000) };
    ($r: expr, str) => { read_vec!($r, str, 10_000) };
    ($r: expr, $t: ty) => { read_vec!($r, $t, 10_000) };
    ($r: expr, $c: expr) => { read_vec!($r, str, $c) };
    ($r: expr, str, $c: expr) => {
        {
            let v = read!($r, $c).split(' ').collect::<Vec<_>>();
            assert!(v.len() <= $c); // $c is upper bound of string
            v
        }
    };
    ($r: expr, $t: ty, $c: expr) => {
        {
            let v = read!($r, $c).split(' ').map(parse::<$t>).collect::<Vec<_>>();
            assert!(v.len() <= $c);
            v
        }
    };
}

fn main() {
    let r = stdin();
    let mut r = BufReader::with_capacity(10000, r.lock());

    let w = stdout();
    let mut w = BufWriter::with_capacity(10000, w.lock());
    unsafe { solve(&mut r, &mut w); }
}

const M: usize = std::usize::MAX;

unsafe fn solve(r: &mut BufReader<StdinLock>, w: &mut BufWriter<StdoutLock>) {
    let (a, b);
    fill!(r, usize, 19, a, b);

    if b%a != 0 {
        writeln!(w, "-1").unwrap();
    } else {
        let m = b/a;
        let tz = m.trailing_zeros();
        let mut m = m>>tz;

        let mut i = 0;
        while m != 1 {
            if m%3 != 0 {
                write!(w, "-1").unwrap();
                return;
            }
            m /= 3;
            i += 1;
        }

        write!(w, "{}", tz+i).unwrap();
    }
}


//spnauti-rust
#[allow(dead_code)]
macro_rules! a {
    ($c: tt, $x: expr, $y: expr) => {{
        let b = $y; let a = &mut $x;
        if b $c *a { *a = b; true } else { false }
    }};
}
struct WordReader {
    it : std::vec::IntoIter<String>,
}
#[allow(dead_code)]
impl WordReader {
    fn new<T: std::io::Read>(mut reader: T) -> WordReader {
        let mut s = String::new();
        reader.read_to_string(&mut s).unwrap();
        WordReader {
            it : s.split_ascii_whitespace().map(String::from)
            .collect::<Vec<_>>().into_iter()
        }
    }
    fn from_stdin() -> WordReader {
        WordReader::new(std::io::stdin())
    }
    fn s(&mut self) -> String {
        self.it.next().unwrap()
    }
    fn ab(&mut self) -> Vec<u8> {
        self.it.next().unwrap().into_bytes()
    }
    fn i(&mut self) -> i32 {
        self.it.next().unwrap().parse().unwrap()
    }
    fn ai(&mut self, n: usize) -> Vec<i32> {
        let mut a = Vec::with_capacity(n);
        for _ in 0..n { a.push(self.i()); }
        a
    }
}

fn main() {
    let mut input = WordReader::from_stdin();
    let n = input.i() as usize;
    let mut dp = Vec::new();
    dp.resize(n + 1, -10000);
    dp[0] = 0;

    for _ in 0..3 {
        let a = input.i() as usize;
        for i in a..n+1 {
            a!(>, dp[i], dp[i - a] + 1);
        }
    }
    println!("{}", dp[n]);
}


fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: u64 = it.next().unwrap().parse().unwrap();
    let k: u64 = it.next().unwrap().parse().unwrap();
    let ans = n / k * k + k;
    println!("{}", ans);
}

fn main() {
    run();
}


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

// I have no idea what I'm doing

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

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

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

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

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

    let a: i32 = scan.token();
    let b: i32 = scan.token();
    let c: i32 = scan.token();
    let d: i32 = scan.token();

    if a == 0 && (c > 0 || d > 0) {
        writeln!(out, "0")?;
        return Ok(());
    }

    writeln!(out, "{}", match a == d {
        true => 1,
        false => 0,
    })?;

    Ok(())
}


#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($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")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

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: usize,
        s: chars,
    }
    // Dilworth
    let mut dp = vec![0; n];
    let mut tbl = vec![0; 27];
    // Find a max LDS.
    let mut len = 0;
    for i in 0..n {
        let c = (s[i] as u8 - b'a') as usize;
        let &ma = tbl[c + 1..].iter().max().unwrap();
        dp[i] = ma + 1;
        len = max(len, ma + 1);
        tbl[c] = max(tbl[c], ma + 1);
    }
    if len >= 3 {
        puts!("NO\n");
        return;
    }
    puts!("YES\n");
    for i in 0..n {
        puts!("{}", dp[i] - 1);
    }
    puts!("\n");
}

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


//spnauti-rust
#[allow(unused_macros)]
macro_rules! a {
    ($c: tt, $x: expr, $y: expr) => {{
        let b = $y; let a = &mut $x;
        if b $c *a { *a = b; true } else { false }
    }};
}
struct WordReader {
    it : std::vec::IntoIter<String>,
}
#[allow(dead_code)]
impl WordReader {
    fn new<T: std::io::Read>(mut reader: T) -> WordReader {
        let mut s = String::new();
        reader.read_to_string(&mut s).unwrap();
        WordReader {
            it : s.split_ascii_whitespace().map(String::from)
            .collect::<Vec<_>>().into_iter()
        }
    }
    fn from_stdin() -> WordReader {
        WordReader::new(std::io::stdin())
    }
    fn s(&mut self) -> String {
        self.it.next().unwrap()
    }
    fn ab(&mut self) -> Vec<u8> {
        self.it.next().unwrap().into_bytes()
    }
    fn i(&mut self) -> i32 {
        self.it.next().unwrap().parse().unwrap()
    }
    fn ai(&mut self, n: usize) -> Vec<i32> {
        let mut a = Vec::with_capacity(n);
        for _ in 0..n { a.push(self.i()); }
        a
    }
}

fn main() {
    let mut input = WordReader::from_stdin();
    let mut a = input.ai(3);
    a.sort();
    println!("{}", a[2] - a[0]);
}


use std::io;
use std::io::{Write};
use std::str;

/// Reads white-space separated tokens one at a time.
pub struct Scanner<R> {
    reader: R,
    buffer: Vec<String>,
}

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

    /// Use "turbofish" syntax token::<T>() to select data type of next token.
    ///
    /// # Panics
    ///
    /// Panics if there's an I/O error or if the token cannot be parsed as T.
    pub fn token<T: str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            self.reader.read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

/// Same API as Scanner but nearly twice as fast, using horribly unsafe dark arts
/// **REQUIRES** Rust 1.34 or higher
pub struct UnsafeScanner<R> {
    reader: R,
    buf_str: Vec<u8>,
    buf_iter: str::SplitAsciiWhitespace<'static>,
}

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

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

pub fn scanner_from_file(filename: &str) -> Scanner<io::BufReader<std::fs::File>> {
    let file = std::fs::File::open(filename).expect("Input file not found");
    Scanner::new(io::BufReader::new(file))
}

pub fn writer_to_file(filename: &str) -> io::BufWriter<std::fs::File> {
    let file = std::fs::File::create(filename).expect("Output file not found");
    io::BufWriter::new(file)
}

#[allow(dead_code)]
fn max<T: std::cmp::PartialOrd>(a: T, b: T) -> T {
    if a > b { a } else { b }
}

fn solve() {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let mut scan = Scanner::new(stdin.lock());
    let mut out = io::BufWriter::new(stdout.lock());
    let n = scan.token::<i32>();
    let mut v = Vec::with_capacity(n as usize);
    for _ in 0..n {
        v.push(scan.token::<i32>());
    }
    v.sort();
    out.write(v.iter().map(|i| i.to_string()).collect::<Vec<_>>().join(" ").as_bytes()).unwrap();
    // let k = scan.token::<i32>();
    // let mut arr = scan.token::<String>().chars().collect::<Vec<char>>();
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024)
        .spawn(solve)
        .unwrap()
        .join()
        .unwrap();
}


use std::io;

fn get_elem(i: u8, j: u8) -> u32 {

    if i == 1 {
        1
    } else if i == j {
        2 * get_elem(i - 1, j)
    } else if i < j {
        get_elem(i, j - 1) + get_elem(i - 1, j)
    } else {
        0
    }

}

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).expect("Failed to read line");
    let n = line.trim().parse::<u8>().unwrap();

    println!("{}", get_elem(n , n));
}


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

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

    let k = input.i();
    let mut a = input.vp::<i32>(12);
    a.sort();
    a.reverse();
    let sol = (|| {
        if k == 0 { return 0; }
        let mut sum = 0;
        for i in 0..12 {
            sum += a[i as usize];
            if sum >= k {
                return i + 1;
            }
        }
        -1
    })();
    println!("{}", sol);
}


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

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

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

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

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

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

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

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

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

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

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

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

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

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 w: usize = it.next().unwrap().parse().unwrap();
    let mut a = vec![vec![]; 3];
    for _ in 0..n {
        let t: usize = it.next().unwrap().parse().unwrap();
        let g: usize = it.next().unwrap().parse().unwrap();
        a[g - 1].push(t);
    }
    let mut way = vec![vec![vec![vec![ModInt::zero(); a[2].len() + 2]; a[1].len() + 2]; a[0].len() + 2]; 3];
    way[0][1][0][0] = ModInt::one();
    way[1][0][1][0] = ModInt::one();
    way[2][0][0][1] = ModInt::one();
    for i in 0..=a[0].len() {
        for j in 0..=a[1].len() {
            for k in 0..=a[2].len() {
                for l in 0..3 {
                    let v = way[l][i][j][k];
                    for (g, &(x, y, z)) in [(i + 1, j, k), (i, j + 1, k), (i, j, k + 1)].iter().enumerate() {
                        if g != l {
                            way[g][x][y][z] += v;
                        }
                    }
                }
            }
        }
    }
    let mut dp1 = vec![vec![vec![ModInt::zero(); w + 1]; a[1].len() + 1]; a[0].len() + 1];
    dp1[0][0][0] = ModInt::one();
    for &b in a[0].iter() {
        for i in (1..=a[0].len()).rev() {
            for t in (b..=w).rev() {
                let v = dp1[i - 1][0][t - b];
                dp1[i][0][t] += v;
            }
        }
    }
    for &b in a[1].iter() {
        for i in 0..=a[0].len() {
            for j in (1..=a[1].len()).rev() {
                for t in (b..=w).rev() {
                    let v = dp1[i][j - 1][t - b];
                    dp1[i][j][t] += v;
                }
            }
        }
    }
    let mut dp2 = vec![vec![ModInt::zero(); w + 1]; a[2].len() + 1];
    dp2[0][0] = ModInt::one();
    for &b in a[2].iter() {
        for i in (1..=a[2].len()).rev() {
            for t in (b..=w).rev() {
                let v = dp2[i - 1][t - b];
                dp2[i][t] += v;
            }
        }
    }
    let pc = Precalc::new(n);
    let mut ans = ModInt::zero();
    for i in 0..=a[0].len() {
        for j in 0..=a[1].len() {
            for k in 0..=a[2].len() {
                for t in 0..=w {
                    let way = way[0][i][j][k] + way[1][i][j][k] + way[2][i][j][k];
                    ans += dp1[i][j][t] * dp2[k][w - t] * way * pc.fact(i) * pc.fact(j) * pc.fact(k);
                }
            }
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


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

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

    let mut a = input.vi(3);
    a.sort();
    println!("{}", 0.max(a[2] + 1 - a[1] - a[0]));
}


use std::io;
fn pgcd(mut a:i8,mut b:i8) -> i8 {
    while (a != b){
        if a > b {
            a = a -b;

        }else{
            b = b - a;
        }}
    return a;
}
fn main() {
    let mut line = String::new();
    io::stdin()
        .read_line(&mut line)
        .expect("error");

    let line: String = line.trim().parse().expect("no");
    let inputs: Vec<i8> = line.split(" ")
        .map(|x| x.parse().expect("Not an integer!"))
        .collect();
    let mut pgcd_a;
    let mut pgcd_b;

    let (mut a, mut b, mut n) = (inputs[0], inputs[1], inputs[2]);
    loop {
          pgcd_a = pgcd(a, n); // 3,9 => 3
        //println!("{}",pgcd_a);
        n = n -pgcd_a;  // 9 - 3 = 6
        if pgcd_a > n {
            println!("0");
            break;
        }
         pgcd_b = pgcd(b,n); // 5,6 => 1
        //println!("{}",pgcd_b);

        n = n-pgcd_b;
        if pgcd_b > n {
            println!("1");
            break;
        }

    }
}


use std::io;

fn poisonous_row(r: &Vec<bool>) -> bool {
  for i in 0..r.len() {
    if !r[i] { return true }
  }
  false
}

fn poisonous_col(m: &Vec<Vec<bool>>, j: usize) -> bool {
  for r in m {
    if !r[j] { return true }
  }
  false
}

fn main() {
  let mut s = String::new();
  io::stdin().read_line(&mut s).unwrap();
  let a: Vec<i32> = s.split_whitespace()
    .map(|x| x.parse().unwrap())
    .collect();

  let r = a[0];
  let c = a[1];

  let mut v: Vec<Vec<bool>> = vec![];

  for _ in 0..r {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    v.push(s.trim().chars()
      .map(|x| x == '.')
      .collect()
    );
  }

  let mut poisonous_rows = 0;
  let mut poisonous_cols = 0;
  for i in 0..r as usize {
    if poisonous_row(&v[i]) { poisonous_rows += 1; }
  }
  for j in 0..c as usize {
    if poisonous_col(&v, j) { poisonous_cols += 1; }
  }

  println!("{}", r*c - poisonous_rows*poisonous_cols);
}


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

use std::collections::*;
use std::io::*;
use std::cmp::{min, max};
use std::f64::consts::*;
use std::mem::swap;
use std::fs::File;
use std::rc::*;
use std::ascii::*;
use std::ops::*;

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

#[derive(PartialEq, PartialOrd, Eq, Ord, Copy, Clone)]
struct Pair<A: Eq + Ord + Copy + Clone, B: Eq + Ord + Copy + Clone>(A, B);

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

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

	fn read_word(&mut self) -> String {
		let mut v = Vec::new();
		let mut x = [255u8];
		self.buffer.read(&mut x).expect("EOF");
		while x[0] <= b' ' && x[0] != 255u8 {
			x[0] = 255u8;
			self.buffer.read(&mut x).expect("EOF");
		}
		while x[0] > b' ' && x[0] != 255u8 {
			v.push(x[0]);
			x[0] = 255u8;
			self.buffer.read(&mut x).expect("EOF");
		}
		String::from_utf8(v).unwrap()
	}
	#[inline]
	fn read_int(&mut self) -> i32 {
		self.read_word().parse::<i32>().expect("Parsing error")
	}
	#[inline]
	fn read_long(&mut self) -> i64 {
		self.read_word().parse::<i64>().expect("Parsing error")
	}
	#[inline]
	fn read_usize(&mut self) -> usize {
		self.read_word().parse::<usize>().expect("Parsing error")
	}
	#[inline]
	fn read_double(&mut self) -> f64 {
		self.read_word().parse::<f64>().expect("Parsing error")
	}
}
macro_rules! read {
    () => {};
	($inf:ident,$($t:ty),*) => ({($({$inf.read_word().parse::<$t>().expect("Parsing error")}),*)});
}
fn gcd<T: RemAssign + Ord + From<i32> + Copy + Clone>(x: T, y: T) -> T {
	let (mut a, mut b) = (x, y);
	while b > T::from(0) {
		a %= b;
		swap(&mut a, &mut b);
	}
	a
}

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

fn solve<Inner: BufRead, Output: Write>(inf: &mut Input<Inner>, ouf: &mut Output)
{
	let mut x = read!(inf,usize);
	while x % 10 == 0 {
		x /= 10;
	}
	let mut y = format!("{}", x).as_bytes().to_vec();
	y.reverse();
	if format!("{}", x) == String::from_utf8(y).unwrap() {
		writeln!(ouf, "YES");
	} else {
		writeln!(ouf, "NO");
	}
}


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

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

    io::stdin().read_line(&mut input)
        .expect("Failed to read line");

    let mut number_of_n: u32 = 0;
    let mut number_of_i: u32 = 0;
    let mut number_of_t: u32 = 0;
    let mut number_of_e: u32 = 0;

    for char in input.chars() {
        if char == 'n' {
            number_of_n = number_of_n + 1;
        } else if char == 'i' {
            number_of_i = number_of_i + 1;
        } else if char == 't' {
            number_of_t = number_of_t + 1;
        } else if char == 'e' {
            number_of_e = number_of_e + 1;
        }
    }

    if number_of_n % 2 == 1 {
        number_of_n = number_of_n + (number_of_n / 2) - 1;
    } else {
        number_of_n = (number_of_n - 1) + (number_of_n - 1)/2 -1;
    }

    println!("{}", cmp::min(cmp::min(number_of_n/3, number_of_i), cmp::min(number_of_t, number_of_e/3)))
}


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

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

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

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

fn main() {
    let s = readln!();
    let z = s.chars().enumerate().map(|(i,c)|
        if i == 0 && c == '9' {
            c
        } else {
            min(c,((9u8 - (c as u8 - '0' as u8)) + ('0' as u8)) as char)
        }).collect::<String>().chars().skip_while(|&c|c=='0').collect::<String>();
    println!("{}",if z.is_empty() { "9" } else { z.as_ref() });
}


//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; )*
    };
}
struct WordReaderB {
    bin: Box<[u8]>,
    it: RefCell<std::vec::IntoIter<Range<usize>>>
}
#[allow(dead_code)]
impl WordReaderB {
    fn from<T: Read>(mut r: T) -> Self {
        let mut bin = Vec::new();
        r.read_to_end(&mut bin).ok();
        let bin = bin.into_boxed_slice();
        let it = RefCell::new(Self::split(&bin).into_iter());
        Self { bin, it }
    }
    fn from_stdin() -> Self {
        Self::from(stdin())
    }
    fn split(a: &[u8]) -> Vec<Range<usize>> {
        let mut res = Vec::new();
        let mut last = None;
        let mut space = vec![false; 256];
        for &c in b" \t\n\r" {
            space[c as usize] = true;
        }
        for (i,&c) in a.iter().enumerate() {
            if space[c as usize] {
                if let Some(j) = last.take() {
                    res.push(j..i);
                }
            } else {
                last.get_or_insert(i);
            }
        }
        if let Some(j) = last {
            res.push(j..a.len());
        }
        res
    }
    fn bs(&self) -> &[u8] {
        &self.bin[self.it.borrow_mut().next().expect("EOF")]
    }
    fn sl(&self) -> std::borrow::Cow<str> {
        String::from_utf8_lossy(self.bs())
    }
    fn s(&self) -> String { self.sl().into_owned() }
    fn sk(&self, n: usize) {
        self.it.borrow_mut().nth(n - 1);
    }
    fn i(&self) ->    i32 { self.p() }
    fn u(&self) ->  usize { self.p() }
    fn f(&self) ->    f64 { self.p() }
    fn vi(&self, n: usize) -> Vec<i32> {
        self.vp::<i32>(n)
    }
    fn vu(&self, n: usize) -> Vec<usize> {
        self.vp::<usize>(n)
    }
    fn ii(&self, n: usize) -> impl Iterator<Item=i32> {
        self.ip(n).into_iter()
    }
    fn iu(&self, n: usize) -> impl Iterator<Item=usize> {
        self.ip(n).into_iter()
    }
    fn p<T: FromStr>(&self) -> T where T::Err: Debug {
        self.sl().parse::<T>().unwrap()
    }
    fn vp<T: FromStr>(&self, n: usize) -> Vec<T> where T::Err: Debug {
        (0..n).map(|_| self.p()).collect()
    }
    fn ip<T: FromStr>(&self, n: usize) -> impl Iterator<Item=T> where T::Err: Debug {
        self.vp(n).into_iter()
    }
}
//------------------- End rusT

fn main() {
    let rin = WordReaderB::from_stdin();

    let n = rin.u();
    let m: i64 = rin.p();
    let add = |x: i64, y: i64| {
        let z = x + y;
        if z >= m {
            z - m
        } else {
            z
        }
    };
    let mul = |x: i64, y: i64| {
        x * y % m
    };
    let mut fact = Vec::with_capacity(n + 1);
    fact.push(1);
    for i in 0..n {
        let x = mul(fact[i], (i + 1) as i64);
        fact.push(x);
    }
    let mut sol = 0;
    for len in 1..=n {
        let count = (n + 1 - len) as i64;
        let count2 = mul(count, count);
        sol = add(sol, mul(fact[len], mul(fact[n - len], count2)));
    }
    println!("{}", sol);
}


use std::io;
use std::io::{Write};
use std::str;

/// Reads white-space separated tokens one at a time.
pub struct Scanner<R> {
    reader: R,
    buffer: Vec<String>,
}

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

    /// Use "turbofish" syntax token::<T>() to select data type of next token.
    ///
    /// # Panics
    ///
    /// Panics if there's an I/O error or if the token cannot be parsed as T.
    pub fn token<T: str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            self.reader.read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

/// Same API as Scanner but nearly twice as fast, using horribly unsafe dark arts
/// **REQUIRES** Rust 1.34 or higher
pub struct UnsafeScanner<R> {
    reader: R,
    buf_str: Vec<u8>,
    buf_iter: str::SplitAsciiWhitespace<'static>,
}

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

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

pub fn scanner_from_file(filename: &str) -> Scanner<io::BufReader<std::fs::File>> {
    let file = std::fs::File::open(filename).expect("Input file not found");
    Scanner::new(io::BufReader::new(file))
}

pub fn writer_to_file(filename: &str) -> io::BufWriter<std::fs::File> {
    let file = std::fs::File::create(filename).expect("Output file not found");
    io::BufWriter::new(file)
}

#[allow(dead_code)]
fn max<T: std::cmp::PartialOrd>(a: T, b: T) -> T {
    if a > b { a } else { b }
}

#[allow(dead_code)]
fn min<T: std::cmp::PartialOrd>(a: T, b: T) -> T {
    if a < b { a } else { b }
}

fn solve() {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let mut scan = Scanner::new(stdin.lock());
    let mut out = io::BufWriter::new(stdout.lock());
    let n = scan.token::<i32>();
    let m = scan.token::<i32>();
    if min(n, m) % 2 == 0 {
        out.write("Malvika".as_bytes()).unwrap();
    } else {
        out.write("Akshat".as_bytes()).unwrap();
    }
    // let k = scan.token::<i32>();
    // let mut arr = scan.token::<String>().chars().collect::<Vec<char>>();
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024)
        .spawn(solve)
        .unwrap()
        .join()
        .unwrap();
}


#![warn(
    clippy::all,
    rust_2018_idioms,
    missing_copy_implementations,
    missing_debug_implementations,
    single_use_lifetimes,
    trivial_casts,
    unused_import_braces,
    unused_qualifications,
    unused_results
)]
#![allow(
    clippy::many_single_char_names,
    non_snake_case,
    unused_imports,
    unused_labels,
    unused_macros,
    dead_code
)]

use crate::ceil::*;
use crate::const_value::*;
use crate::modular::*;
use crate::prelude::*;
use crate::prime_value::*;
use crate::primes::*;
use crate::values::*;

static mut M: u32 = 0;

mod task {
    use super::*;

    #[derive(Clone, Debug)]
    pub struct Main;

    impl Problem for Main {
        fn solve<R: BufRead, W: Write, L: Write>(io: &mut Io<R, W, L>) {
            define_io!(io);

            let n = re!(usize);
            let m = re!(u32);
            unsafe {
                M = m;
            };

            #[derive(Clone, Copy, Debug, Default)]
            struct Prime;

            impl PrimeValue for Prime {}

            impl ConstValue for Prime {
                type Output = u32;
                fn get() -> Self::Output {
                    unsafe { M }
                }
            }

            let mut mul: Vec<Modular<u32, Prime>> = vec![Modular::from(0); n as usize + 1];
            let mut prob: Modular<u32, Prime> = Zero::zero();
            let mut dsum: Modular<u32, Prime> = Zero::zero();
            let mut sum: Modular<u32, Prime> = Zero::zero();
            for j1 in 1..=n {
                dsum += mul[j1];
                if j1 == 1 {
                    prob = One::one();
                } else {
                    prob = sum + dsum;
                }
                sum += prob;
                let mut j2 = j1 * 2;
                let mut j3 = j2 + 2;
                while j2 <= n {
                    mul[j2] += prob;
                    j2 += j1;
                    if j3 <= n {
                        mul[j3] -= prob;
                        j3 += j1 + 1;
                    }
                }
                if n < 10 {
                    /*dln!(
                        n,
                        m,
                        j1,
                        prob.0,
                        sum.0,
                        ..mul.iter().enumerate().map(|kv| (kv.0, kv.1 .0))
                    );*/
                }
            }
            ln!(prob.0);

            /*let mut div = vec![Modular::from(0); n as usize + 1];
            div[n as usize] = One::one();

            let mut sum: Modular<u32, Prime> = Zero::zero();
            let mut ans: Modular<u32, Prime> = Zero::zero();
            for j in (1..=n as usize).rev() {
                ans = sum;
                ans += div[j];
                sum += ans;
                for k in 2..=j {
                    div[j / k] += ans;
                }
                //dln!(n, m, j, ans.0, sum.0);
            }
            //dln!(n, m, ans.0, sum.0, ":", ..div.iter().map(|v| v.0));
            ln!(ans.0);*/
        }
    }

    #[cfg(test)]
    #[test]
    fn test_example() {
        Main::test(
            "
            --
            ==
            1 998244353
            --
            1
            ==
            2 998244353
            --
            2
            ==
            3 998244353
            --
            5
            ==
            5 998244353
            --
            25
            ==
            42 998244353
            --
            793019428
            ==
            200000 998244353
            --
            730229972
            ",
        );
    }

    #[cfg(test)]
    #[test]
    fn test_custom() {
        /*
        define_logger!(Some(Writer::new(BufWriter::new(stderr()))));
        for a in 0..4 {
            for b in 0..4 {
                // for a in vec![1..=2, 1..=3, 1..=4].each() {}
                let mut input = Writer::new(Vec::new());
                define_writer!(input);
                ln!(1, ..vec![a, b]);
                let output = Main::output(&input.writer());
                define_reader!(Reader::new(BufReader::new(output.as_bytes())));
                let sum: i32 = re!();
                assert_eq!(sum, a + b);
            }
        }*/
    }
}

pub fn main() {
    let mut reader = stdin();
    let mut writer = stdout();
    task::Main::solve(&mut Io::new(&mut reader, &mut writer));
    writer.flush().unwrap();
}

#[cfg(test)]
#[test]
fn test_32bit_target() {
    use core::mem::size_of;
    assert_eq!(
        size_of::<usize>(),
        4,
        "Codeforces supports only 32-bit Rust"
    );
}

// libs

mod ceil {
    use core::ops::{Add, Div, Sub};

    use crate::ops::DivEuclid;
    use crate::values::One;

    #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
    pub struct Ceil<T>(pub T);

    impl<T> Div<T> for Ceil<T>
    where
        T: Add<Output = T> + Clone + DivEuclid + One + Sub<Output = T>,
    {
        type Output = T;

        fn div(self, rhs: T) -> Self::Output {
            (self.0 + rhs.clone() - T::one()).div_euclid(rhs)
        }
    }

    pub fn up<T>(value: T) -> Ceil<T> {
        Ceil(value)
    }
}

mod const_value {
    pub trait ConstValue: Default {
        type Output;
        fn get() -> Self::Output;
    }
}

mod modular {
    use core::cmp::{Ord, Ordering};
    use core::ops::{
        Add, AddAssign, BitAnd, Div, DivAssign, Mul, MulAssign, Neg, Rem, ShrAssign, Sub, SubAssign,
    };

    use crate::const_value::ConstValue;
    use crate::gcd::gcd;
    use crate::modular_mul::ModularMul;
    use crate::modular_pow::ModularPow;
    use crate::mul_div::MulDiv;
    use crate::ops::{Abs, RemEuclid};
    use crate::prime_value::{PrimeValue, P1_000_000_007, P998_244_353};
    use crate::unsigned::Unsigned;
    use crate::value::Value;
    use crate::value_eulers_phi::ValueEulersPhi;
    use crate::values::{Five, One, Ten, Three, Two, Zero};

    #[derive(Clone, Copy, Debug, Default, Hash)]
    pub struct Modular<T, M>(pub T, pub M);

    impl<T, M> Modular<T, M> {
        pub fn new(value: T, modulus: M) -> Self
        where
            T: RemEuclid + Unsigned,
            M: Clone + Value<Output = T>,
        {
            let value = value.rem_euclid(modulus.get());
            Self(value, modulus)
        }

        pub fn from_raw(value: T, modulus: M) -> Self
        where
            T: Unsigned,
            M: Value<Output = T>,
        {
            Self(value, modulus)
        }

        pub fn from_raw_value(value: T) -> Self
        where
            T: Unsigned,
            M: ConstValue + Default + Value<Output = T>,
        {
            Self(value, M::default())
        }

        pub fn value(self) -> T {
            self.0
        }

        pub fn modulus(self) -> M {
            self.1
        }
    }

    impl<T, M> From<T> for Modular<T, M>
    where
        T: RemEuclid + Unsigned,
        M: Copy + ConstValue<Output = T>,
    {
        fn from(value: T) -> Self {
            Self::new(value, M::default())
        }
    }

    impl<T, M> Neg for Modular<T, M>
    where
        T: Add<Output = T> + PartialOrd + RemEuclid + Sub<Output = T> + Zero,
        M: Value<Output = T>,
    {
        type Output = Self;

        fn neg(self) -> Self {
            if self.0.is_zero() {
                self
            } else {
                Self(self.1.get() - self.0, self.1)
            }
        }
    }

    impl<T, M> Add for Modular<T, M>
    where
        T: Add<Output = T> + PartialOrd + RemEuclid + Sub<Output = T>,
        M: Value<Output = T>,
    {
        type Output = Self;

        fn add(self, other: Self) -> Self {
            let value = self.0 + other.0;
            if value >= self.1.get() {
                Self(value - self.1.get(), self.1)
            } else {
                Self(value, self.1)
            }
        }
    }

    impl<T, M> Sub for Modular<T, M>
    where
        T: Add<Output = T> + PartialOrd + Sub<Output = T> + Zero,
        M: Value<Output = T>,
    {
        type Output = Self;

        fn sub(self, other: Self) -> Self {
            if self.0 >= other.0 {
                Self(self.0 - other.0, self.1)
            } else {
                Self(self.0 + self.1.get() - other.0, self.1)
            }
        }
    }

    impl<T, M> Mul for Modular<T, M>
    where
        T: ModularMul,
        M: Value<Output = T>,
    {
        type Output = Self;

        fn mul(self, other: Self) -> Self {
            Self(self.0.modular_mul(other.0, self.1.get()), self.1)
        }
    }

    impl<T, M> Div for Modular<T, M>
    where
        T: ModularMul + ModularPow<T> + Sub<Output = T> + Two + Zero,
        M: PrimeValue<Output = T>,
    {
        type Output = Self;

        fn div(self, other: Self) -> Self {
            self.mul(other.inv().unwrap())
        }
    }

    impl<T, M> AddAssign for Modular<T, M>
    where
        T: Add<Output = T> + Copy + PartialOrd + RemEuclid + Sub<Output = T>,
        M: Value<Output = T>,
    {
        fn add_assign(&mut self, other: Self) {
            self.0 = (*self + other).0
        }
    }

    impl<T, M> SubAssign for Modular<T, M>
    where
        T: Add<Output = T> + Copy + PartialOrd + Sub<Output = T> + Zero,
        M: Value<Output = T>,
    {
        fn sub_assign(&mut self, other: Self) {
            self.0 = (*self - other).0
        }
    }

    impl<T, M> MulAssign for Modular<T, M>
    where
        T: Copy + ModularMul,
        M: Value<Output = T>,
    {
        fn mul_assign(&mut self, other: Self) {
            self.0 = (*self * other).0
        }
    }

    impl<T, M> DivAssign for Modular<T, M>
    where
        T: Copy + ModularMul + ModularPow<T> + Sub<Output = T> + Two + Zero,
        M: PrimeValue<Output = T>,
    {
        fn div_assign(&mut self, other: Self) {
            self.0 = (*self / other).0
        }
    }

    impl<T, M> Add<T> for Modular<T, M>
    where
        Self: Add<Self, Output = Self>,
        T: RemEuclid + Unsigned,
        M: Value<Output = T>,
    {
        type Output = Self;

        fn add(self, other: T) -> Self {
            let modulus = self.1;
            self + Self::new(other, modulus)
        }
    }

    impl<T, M> Sub<T> for Modular<T, M>
    where
        Self: Sub<Self, Output = Self>,
        T: RemEuclid + Unsigned,
        M: Value<Output = T>,
    {
        type Output = Self;

        fn sub(self, other: T) -> Self {
            let modulus = self.1;
            self - Self::new(other, modulus)
        }
    }

    impl<T, M> Mul<T> for Modular<T, M>
    where
        Self: Mul<Self, Output = Self>,
        T: RemEuclid + Unsigned,
        M: Value<Output = T>,
    {
        type Output = Self;

        fn mul(self, other: T) -> Self {
            let modulus = self.1;
            self * Self::new(other, modulus)
        }
    }

    impl<T, M> Div<T> for Modular<T, M>
    where
        Self: Div<Self, Output = Self>,
        T: RemEuclid + Unsigned,
        M: Value<Output = T>,
    {
        type Output = Self;

        fn div(self, other: T) -> Self {
            let modulus = self.1;
            self / Self::new(other, modulus)
        }
    }

    impl<T, M> AddAssign<T> for Modular<T, M>
    where
        Self: AddAssign<Self>,
        T: RemEuclid + Unsigned,
        M: Value<Output = T>,
    {
        fn add_assign(&mut self, other: T) {
            let modulus = self.1;
            *self += Self::new(other, modulus);
        }
    }

    impl<T, M> SubAssign<T> for Modular<T, M>
    where
        Self: SubAssign<Self>,
        T: RemEuclid + Unsigned,
        M: Value<Output = T>,
    {
        fn sub_assign(&mut self, other: T) {
            let modulus = self.1;
            *self -= Self::new(other, modulus);
        }
    }

    impl<T, M> MulAssign<T> for Modular<T, M>
    where
        Self: MulAssign<Self>,
        T: RemEuclid + Unsigned,
        M: Value<Output = T>,
    {
        fn mul_assign(&mut self, other: T) {
            let modulus = self.1;
            *self *= Self::new(other, modulus);
        }
    }

    impl<T, M> DivAssign<T> for Modular<T, M>
    where
        Self: DivAssign<Self>,
        T: RemEuclid + Unsigned,
        M: Value<Output = T>,
    {
        fn div_assign(&mut self, other: T) {
            let modulus = self.1;
            *self /= Self::new(other, modulus);
        }
    }

    impl<T, M> Modular<T, M> {
        pub fn pow<U>(self, exp: U) -> Self
        where
            T: ModularPow<U>,
            M: Value<Output = T>,
        {
            Self(self.0.modular_pow(exp, self.1.get()), self.1)
        }
    }

    impl<T, M> Modular<T, M>
    where
        T: ModularPow<T> + Sub<Output = T> + Two + Zero,
        M: PrimeValue<Output = T>,
    {
        // https://en.wikipedia.org/wiki/Fermat%27s_little_theorem
        // p: prime && a % p > 0
        // => a ** (p - 1) % p = 1
        // => a ** (p - 2) % p = a ** -1 % p
        pub fn inv(self) -> Option<Self> {
            if self.0.is_zero() {
                None
            } else {
                Some(self.pow(M::get() - T::two()))
            }
        }
    }

    impl<T, M> Modular<T, M>
    where
        T: Abs + Copy + ModularPow<T> + One + PartialOrd + Rem<Output = T> + Sub<Output = T> + Zero,
        M: Value<Output = T> + ValueEulersPhi,
    {
        pub fn inv_with_eulers_phi(self) -> Option<Self> {
            if self.0.is_zero() || gcd(self.0, self.1.get()) > T::one() {
                None
            } else {
                Some(self.pow(self.1.eulers_phi() - T::one()))
            }
        }
    }

    impl<T: Ord, M> Eq for Modular<T, M> {}

    impl<T: Ord, M> Ord for Modular<T, M> {
        fn cmp(&self, other: &Self) -> Ordering {
            self.0.cmp(&other.0)
        }
    }

    impl<T: Ord, M> PartialEq for Modular<T, M> {
        fn eq(&self, other: &Self) -> bool {
            self.0.eq(&other.0)
        }
    }

    impl<T: Ord, M> PartialOrd for Modular<T, M> {
        fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
            self.0.partial_cmp(&other.0)
        }
    }

    impl<T: Ord, M> PartialEq<T> for Modular<T, M> {
        fn eq(&self, other: &T) -> bool {
            self.0.eq(&other)
        }
    }

    impl<T: Ord, M> PartialOrd<T> for Modular<T, M> {
        fn partial_cmp(&self, other: &T) -> Option<Ordering> {
            self.0.partial_cmp(&other)
        }
    }

    macro_rules! def {
        ( $name:ident, $fn:ident, $is:ident ) => {
            impl<T, M> $name for Modular<T, M>
            where
                T: $name + PartialOrd + Unsigned,
                M: ConstValue + Default + Value<Output = T>,
            {
                fn $fn() -> Self {
                    assert!(T::$fn() < M::default().get());
                    Self::from_raw_value(T::$fn())
                }

                fn $is(&self) -> bool {
                    self.0 == T::$fn()
                }
            }
        };
    }

    def!(Zero, zero, is_zero);
    def!(One, one, is_one);
    def!(Two, two, is_two);
    def!(Three, three, is_three);
    def!(Five, five, is_five);
    def!(Ten, ten, is_ten);

    impl<T, M> Unsigned for Modular<T, M> {}

    impl<T, M> MulDiv for Modular<T, M>
    where
        Self: Div<Output = Self> + Mul<Output = Self>,
    {
        fn mul_div(self, mul: Self, div: Self) -> Self {
            self.mul(mul).div(div)
        }
    }

    pub type M1_000_000_007 = Modular<u32, P1_000_000_007>;
    pub type M998_244_353 = Modular<u32, P998_244_353>;

    pub type M07 = M1_000_000_007;
    pub type M53 = M998_244_353;
}

mod prelude {
    pub use core::borrow::{Borrow, BorrowMut};
    pub use core::cell::RefCell;
    pub use core::cmp::Ordering::{Equal, Greater, Less};
    pub use core::cmp::{max, min};
    pub use core::iter::{empty, once, repeat, FromIterator};
    pub use core::marker::PhantomData;
    pub use core::mem::{replace, swap, take};
    pub use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, LinkedList, VecDeque};
    pub use std::convert::{TryFrom, TryInto};
    pub use std::io::{
        sink, stderr, stdin, stdout, BufRead, BufReader, BufWriter, Stderr, Stdout, Write,
    };
    pub use std::str::from_utf8;
    pub use std::sync::Arc;

    // pub use crate::collections;
    pub use crate::define_io;
    pub use crate::io::Io;
    pub use crate::mode::Mode;
    pub use crate::readable::Readable;
    pub use crate::reader::Reader;
    pub use crate::writer::Writer;
    pub use crate::{btm, bts, hm, hs, replace_expr};
    pub use crate::{define_logger, define_reader, define_writer, write_arg, write_args};

    pub use crate::joined::Joined;
    pub use crate::lfmt;

    pub use crate::problem::Problem;
    pub use crate::trim_lines::TrimLines;
}

mod prime_value {
    use core::ops::Sub;

    use crate::const_value::ConstValue;
    use crate::value_eulers_phi::ValueEulersPhi;
    use crate::values::One;

    pub trait PrimeValue: Copy + ConstValue {}
    impl PrimeValue for P1_000_000_007 {}
    impl PrimeValue for P998_244_353 {}

    impl<T: PrimeValue> ValueEulersPhi for T
    where
        T::Output: One + Sub<Output = T::Output>,
    {
        fn eulers_phi(self) -> Self::Output {
            Self::get() - Self::Output::one()
        }
    }

    #[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
    pub struct P998_244_353;

    #[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
    pub struct P1_000_000_007;

    impl ConstValue for P998_244_353 {
        type Output = u32;
        fn get() -> Self::Output {
            998_244_353
        }
    }

    impl ConstValue for P1_000_000_007 {
        type Output = u32;
        fn get() -> Self::Output {
            1_000_000_007
        }
    }
}

mod primes {
    use core::iter::FusedIterator;

    use crate::dedup_count::DedupCount;

    #[derive(Clone, Debug)]
    pub struct Primes {
        sieve: Vec<usize>,
        len: usize,
    }

    impl Primes {
        pub fn new(len: usize) -> Self {
            let odds_len = len / 2;
            let mut sieve = vec![0; odds_len];
            let half = (len as f64).sqrt().ceil() as usize;
            for j in (3..half).step_by(2) {
                if sieve[j / 2] == 0 {
                    for k in (j * j..len).step_by(2 * j) {
                        if sieve[k / 2] == 0 {
                            sieve[k / 2] = j;
                        }
                    }
                }
            }
            Self { sieve, len }
        }

        pub fn odds_sieve(&self) -> &[usize] {
            &self.sieve
        }

        pub fn get_sieve_value(&self, value: usize) -> usize {
            if value < 4 {
                0
            } else if value & 1 == 0 {
                2
            } else {
                self.sieve[value / 2]
            }
        }

        pub fn is_prime(&self, value: usize) -> bool {
            if value < 3 {
                value == 2
            } else {
                value & 1 == 1 && self.sieve[value / 2] == 0
            }
        }

        pub fn iter(&self) -> PrimesIter<'_> {
            PrimesIter::new(self, 0)
        }

        pub fn iter_from(&self, from: usize) -> PrimesIter<'_> {
            PrimesIter::new(self, from)
        }

        pub fn factorize(&self, value: usize) -> PrimesFactorizeIter<'_> {
            assert!(value < self.len);
            PrimesFactorizeIter::new(self, value)
        }

        pub fn num_divisors(&self, value: usize) -> usize {
            let factorization = self.factorize(value);
            factorization
                .dedup_count()
                .map(|(_, count)| count + 1)
                .product()
        }

        pub fn eulers_phi(&self, value: usize) -> usize {
            if value == 1 {
                return 0;
            }
            let factorization = self.factorize(value);
            factorization.dedup_count().fold(value, |mult, (prime, _)| {
                ((mult as u64) * (prime - 1) as u64 / prime as u64) as usize
            })
        }
    }

    /*
        phi(36) = phi(2^2) * phi(3^3)
    */

    #[derive(Clone, Debug)]
    pub struct PrimesIter<'a>(&'a Primes, usize);

    impl<'a> PrimesIter<'a> {
        pub fn new(sieve: &'a Primes, from: usize) -> Self {
            Self(sieve, if from < 3 { 0 } else { from / 2 })
        }
    }

    impl Iterator for PrimesIter<'_> {
        type Item = usize;

        fn next(&mut self) -> Option<Self::Item> {
            if self.1 == 0 {
                if self.0.len > 2 {
                    self.1 = 1;
                    Some(2)
                } else {
                    None
                }
            } else {
                while self.1 < self.0.sieve.len() {
                    if self.0.sieve[self.1] != 0 {
                        self.1 += 1;
                    } else {
                        let item = self.1;
                        self.1 += 1;
                        return Some(item * 2 + 1);
                    }
                }
                None
            }
        }
    }

    impl FusedIterator for PrimesIter<'_> {}

    #[derive(Clone, Debug)]
    pub struct PrimesFactorizeIter<'a>(&'a Primes, usize);

    impl<'a> PrimesFactorizeIter<'a> {
        pub fn new(sieve: &'a Primes, value: usize) -> Self {
            Self(sieve, value)
        }
    }

    impl Iterator for PrimesFactorizeIter<'_> {
        type Item = usize;

        fn next(&mut self) -> Option<Self::Item> {
            if self.1 > 1 {
                if self.1 & 1 == 0 {
                    self.1 /= 2;
                    Some(2)
                } else {
                    let divisor = self.0.sieve[self.1 / 2];
                    if divisor != 0 {
                        self.1 /= divisor;
                        Some(divisor)
                    } else {
                        let item = self.1;
                        self.1 = 1;
                        Some(item)
                    }
                }
            } else {
                None
            }
        }
    }

    impl FusedIterator for PrimesFactorizeIter<'_> {}
}

mod values {
    macro_rules! def {
        ( $name:ident, $fn:ident, $is:ident, $value:literal ) => {
            pub trait $name {
                fn $fn() -> Self;
                fn $is(&self) -> bool;
            }
            def!(
                @impl $name, $fn, $is, $value,
                u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize
            );
        };
        ( @impl $name:ident, $fn:ident, $is:ident, $value:literal, $ty:ty $(, $($ts:ty),*)? ) => {
            impl $name for $ty {
                fn $fn() -> Self {
                    $value
                }

                fn $is(&self) -> bool {
                    *self == $value
                }
            }
            $( def!(@impl $name, $fn, $is, $value, $($ts),*); )?
        };
    }

    def!(Zero, zero, is_zero, 0);
    def!(One, one, is_one, 1);
    def!(Two, two, is_two, 2);
    def!(Three, three, is_three, 3);
    def!(Five, five, is_five, 5);
    def!(Ten, ten, is_ten, 10);
}

mod ops {
    macro_rules! def {
        ((
            $trait:ident $( ($($bounds:tt)*) )?,
            fn $fn:ident($($self:ident $(, $arg:ident: $arg_ty:ty)*)?) -> $ret:ty {
                u: $uexpr:expr, i: $iexpr:expr
            }
        )) => {
            pub trait $trait $( where $($bounds)* )? {
                fn $fn($($self $(, $arg: $arg_ty)*)?) -> $ret;
            }
            def!(@impl $trait, fn $fn($($self $(, $arg: $arg_ty)*)?) -> $ret {
                u8: $uexpr, u16: $uexpr, u32: $uexpr, u64: $uexpr, u128: $uexpr, usize: $uexpr,
                i8: $iexpr, i16: $iexpr, i32: $iexpr, i64: $iexpr, i128: $iexpr, isize: $iexpr
            });
        };
        ((
            $trait:ident $( ($($bounds:tt)*) )?,
            fn $fn:ident($($self:ident $(, $arg:ident: $arg_ty:ty)*)?) -> $ret:ty { $expr:expr }
        )) => {
            pub trait $trait $( where $($bounds)* )? {
                fn $fn($($self $(, $arg: $arg_ty)*)?) -> $ret;
            }
            def!(@impl $trait, fn $fn($($self $(, $arg: $arg_ty)*)?) -> $ret {
                u8: $expr, u16: $expr, u32: $expr, u64: $expr, u128: $expr, usize: $expr,
                i8: $expr, i16: $expr, i32: $expr, i64: $expr, i128: $expr, isize: $expr
            });
        };
        (@impl $trait:ident, fn $fn:ident($($tt:tt)*) -> $ret:ty {}) => {};
        (
            @impl $trait:ident,
            fn $fn:ident($($self:ident $(, $arg: ident: $arg_ty: ty)*)?) -> $ret:ty {
                $ty:tt: $expr:expr $(, $ts:tt: $es:expr)*
            }
        ) => {
            impl $trait for $ty {
                fn $fn($($self $(, $arg: $arg_ty)*)?) -> $ret {
                    $expr
                }
            }
            def!(@impl $trait, fn $fn($($self $(, $arg: $arg_ty)*)?) -> $ret { $($ts: $es),* });
        };
    }

    def!((Min, fn min() -> Self { Self::MIN } ));
    def!((Max, fn max() -> Self { Self::MAX } ));
    def!((Abs, fn abs(self) -> Self { u: self, i: self.abs() } ));
    def!((TrailingZeros, fn trailing_zeros(self) -> u32 { self.trailing_zeros() } ));
    def!((DivEuclid, fn div_euclid(self, rhs: Self) -> Self { self.div_euclid(rhs) } ));
    def!((RemEuclid, fn rem_euclid(self, rhs: Self) -> Self { self.rem_euclid(rhs) } ));
    def!((CheckedMul(Self: Sized), fn checked_mul(self, rhs: Self) -> Option<Self> {
        self.checked_mul(rhs)
    } ));
}

mod gcd {
    use core::ops::Rem;

    use crate::ops::Abs;
    use crate::values::Zero;

    // https://en.wikipedia.org/wiki/Euclidean_algorithm
    // gcd(a, b) = gcd(a - b, a): gcd(14, 10) = gcd(4, 10)
    pub fn gcd<T>(lhs: T, rhs: T) -> T
    where
        T: Abs + Clone + Rem<Output = T> + Zero,
    {
        if rhs.is_zero() {
            lhs.abs()
        } else {
            gcd(rhs.clone(), lhs % rhs)
        }
    }
}

mod modular_mul {
    pub trait ModularMul {
        fn modular_mul(self, other: Self, modulus: Self) -> Self;
    }

    macro_rules! def {
        ( $low:ty, $hi:ty $(, $rest:ty)* ) => {
            impl ModularMul for $low {
                fn modular_mul(self, other: $low, modulus: Self) -> Self {
                    (((self as $hi) * (other as $hi)).rem_euclid(modulus as $hi)) as $low
                }
            }
            def!($hi $(, $rest)*);
        };
        ( $last:ty ) => {};
    }

    def!(u8, u16, u32, u64, u128);
}

mod modular_pow {
    use core::ops::{Add, BitAnd, Mul, Rem, ShrAssign};

    use crate::modular_mul::ModularMul;
    use crate::values::{One, Zero};

    pub trait ModularPow<U> {
        fn modular_pow(self, exp: U, modulus: Self) -> Self;
    }

    macro_rules! def {
        ( $low:ty, $hi:ty $(, $rest:ty)* ) => {
            impl<U> ModularPow<U> for $low
            where
                U: One
                    + BitAnd<Output = U>
                    + Clone
                    + Copy
                    + PartialEq<U>
                    + PartialOrd
                    + ShrAssign
                    + Zero,
            {
                // https://doc.rust-lang.org/src/core/num/uint_macros.rs.html#1538-1558
                fn modular_pow(self, mut exp: U, modulus: Self) -> Self {
                    if exp == U::zero() {
                        return Self::one();
                    }
                    let mut base = self;
                    let mut acc = Self::one();

                    while exp > U::one() {
                        if (exp & U::one()) == U::one() {
                            acc = acc.modular_mul(base, modulus);
                        }
                        exp >>= U::one();
                        base = base.modular_mul(base, modulus);
                    }

                    acc.modular_mul(base, modulus)
                }
            }
            def!($hi $(, $rest)*);
        };
        ( $last:ty ) => {};
    }

    def!(u8, u16, u32, u64, u128);
}

mod mul_div {
    pub trait MulDiv {
        fn mul_div(self, mul: Self, div: Self) -> Self;
    }

    macro_rules! def {
        ( $low:ty, $hi:ty $(, $rest:ty)* ) => {
            impl MulDiv for $low {
                fn mul_div(self, mul: Self, div: Self) -> Self {
                    ((self as $hi) * (mul as $hi) / (div as $hi)) as $low
                }
            }
            def!($hi $(, $rest)*);
        };
        ( $last:ty ) => {};
    }

    def!(u8, u16, u32, u64, u128);
    def!(i8, i16, i32, i64, i128);
}

mod unsigned {
    pub trait Unsigned {}

    macro_rules! def {
        ( $($ty:ty),* ) => {
            $( impl Unsigned for $ty {} )*
        };
    }

    def!(u8, u16, u32, u64, u128, usize);
}

mod value {
    use crate::const_value::ConstValue;

    pub trait Value: Copy {
        type Output;
        fn get(self) -> Self::Output;
    }

    impl<T: Copy> Value for (T,) {
        type Output = T;
        fn get(self) -> Self::Output {
            self.0
        }
    }

    impl<T: Copy + ConstValue> Value for T {
        type Output = <Self as ConstValue>::Output;
        fn get(self) -> Self::Output {
            Self::get()
        }
    }
}

mod value_eulers_phi {
    use crate::value::Value;

    pub trait ValueEulersPhi: Value {
        fn eulers_phi(self) -> Self::Output;
    }
}

mod collections {
    #[macro_export]
    macro_rules! replace_expr {
        ($_t:tt $sub:expr) => {
            $sub
        };
    }

    #[macro_export]
    macro_rules! bts {
        () => {
            std::collections::BTreeSet::new()
        };
        ($($x:expr),+ $(,)?) => {{
            let mut collection = std::collections::BTreeSet::new();
            $( let _ = collection.insert($x); )+
            collection
        }};
    }

    #[macro_export]
    macro_rules! btm {
        () => {
            std::collections::BTreeMap::new()
        };
        ($(($k:expr, $v:expr)),+ $(,)?) => {{
            let mut collection = std::collections::BTreeMap::new();
            $( let _ = collection.insert($k, $v); )+
            collection
        }};
    }

    #[macro_export]
    macro_rules! hs {
        () => {
            std::collections::HashSet::new()
        };
        ($($x:expr),+ $(,)?) => {{
            let mut collection = std::collections::HashSet::with_capacity([$(crate::replace_expr!($x ())),+].len());
            $( let _ = collection.insert($x); )+
            collection
        }};
    }

    #[macro_export]
    macro_rules! hm {
        () => {
            std::collections::HashMap::new()
        };
        ($(($k:expr, $v:expr)),+ $(,)?) => {{
            let mut collection = std::collections::HashMap::with_capacity([$(crate::replace_expr!($v ())),+].len());
            $( let _ = collection.insert($k, $v); )+
            collection
        }};
    }
}

mod define_io {
    #[macro_export]
    macro_rules! define_io {
        ( $io:expr ) => {
            let _ = $io;
            $crate::define_reader!($io.reader);
            $crate::define_writer!($io.writer);
            $crate::define_logger!($io.logger);
            $crate::forbid_stdio!();
        };
    }

    #[macro_export]
    macro_rules! define_reader {
        ( $reader:expr ) => {
            let _ = $reader;
            $crate::define_reader!(@impl ($)($reader));
        };
        ( @impl ($d:tt)($reader:expr) ) => {
            #[allow(unused_macros)]
            macro_rules! re {
                () => {
                    $reader.read().unwrap()
                };
                ( [$d ty:tt; [$d len1:expr, $d len2:expr]] ) => {{
                    let value: NdArray<$d ty, Vec<$d ty>, _, _> =
                        NdArray::with(|| re!($d ty), [$d len1, $d len2]);
                    value
                }};
                ( [$d ty:tt; $d len:literal] ) => {{
                    let mut value: [_; $d len] = core::default::Default::default();
                    for j in 0..$d len {
                        value[j] = re!($d ty);
                    }
                    value
                }};
                ( [$d ty:tt; $d len:expr] ) => {
                    re!( Vec<_> [$d ty; $d len] );
                };
                ( vec[$d ty:tt; $d len:expr] ) => {
                    re!( Vec<_> [$d ty; $d len] );
                };
                ( bts[$d ty:tt; $d len:expr] ) => {
                    re!( std::collections::BTreeSet<_> [$d ty; $d len] );
                };
                ( hs[$d ty:tt; $d len:expr] ) => {
                    re!( std::collections::HashSet<_> [$d ty; $d len] );
                };
                ( ascii ) => {
                    re!( Ascii<Vec<u8>> ).0;
                };
                ( ascii[$d len:expr] ) => {
                    re!( Ascii<SmallVec<u8, [u8; $d len]>> ).0;
                };
                ( dec ) => {
                    re!( Decimal<Vec<u8>> ).0;
                };
                ( dec[$d len:expr] ) => {
                    re!( Decimal<SmallVec<u8, [u8; $d len]>> ).0;
                };
                ( bits[$d ch:tt] ) => {{
                    let value: Vec<bool> = $reader.read_bits($d ch).unwrap().collect();
                    value
                }};
                ( bits[$d true:literal; $d len:expr] ) => {{
                    let value: Vec<bool> = (0..$d len).map(|_|
                        $reader.read_word().unwrap() == $d true
                    ).collect();
                    value
                }};
                ( $d collection:ty [$d ty:tt; $d len:expr] ) => {{
                    #[allow(unused_qualifications)]
                    let value: $d collection = (0..$d len).map(|_| re!($d ty)).collect();
                    value
                }};
                ( ch ) => {{
                    let value = $reader.read_char().unwrap();
                    value as u8
                }};
                ( &str ) => {{
                    let value: &str = $reader.read_word().unwrap();
                    value
                }};
                (( $d ty:ty )) => {{
                    let value: $d ty = $reader.read().unwrap();
                    value
                }};
                ( $d ty:ty ) => {{
                    let value: $d ty = $reader.read().unwrap();
                    value
                }};
            }
        };
    }

    #[macro_export]
    macro_rules! define_writer {
        ( $writer:expr ) => {
            let _ = $writer;
            $crate::define_writer!(@impl ($)($writer));
        };
        ( @impl ($d:tt)($writer:expr) ) => {
            #[allow(unused_macros)]
            macro_rules! ln {
                ( $d($d tt:tt)* ) => {{
                    write_args!($writer, "", { $writer.space() }, (), ($d($d tt)*));
                    $writer.ln();
                }};
            }

            #[allow(unused_macros)]
            macro_rules! wr {
                ( $d($d tt:tt)* ) => {{
                    write_args!($writer, "", { $writer.space() }, (), ($d($d tt)*));
                }};
            }

            #[allow(unused_macros)]
            macro_rules! lf {
                ( $d( $d tt:tt )* ) => {{
                    writeln!($writer.writer_mut(), $d( $d tt )*).unwrap();
                }}
            }

            #[allow(unused_macros)]
            macro_rules! wf {
                ( $d( $d tt:tt )* ) => {{
                    write!($writer.writer_mut(), $d( $d tt )*).unwrap();
                }}
            }

            #[allow(unused_macros)]
            macro_rules! jo {
                ( $d($d tt:tt)* ) => {{
                    write_args!($writer, "", {}, (), ($d($d tt)*));
                }};
            }

            #[allow(unused_macros)]
            macro_rules! fl {
                () => { $writer.flush() }
            }

            #[allow(unused_macros)]
            macro_rules! yes {
                () => { ln!("YES") }
            }

            #[allow(unused_macros)]
            macro_rules! no {
                () => { ln!("NO") }
            }

            #[allow(unused_macros)]
            macro_rules! ask {
                ( $d( $d tt:tt )* ) => {{
                    ln!( "?", $d( $d tt )* );
                    $writer.flush();
                }}
            }

            #[allow(unused_macros)]
            macro_rules! ans {
                ( $d( $d tt:tt )* ) => {{
                    ln!( "!", $d( $d tt )* );
                    $writer.flush();
                }}
            }

            #[allow(unused_macros)] macro_rules! dbg { () => {} }
            #[allow(unused_macros)] macro_rules! print { () => {} }
            #[allow(unused_macros)] macro_rules! println { () => {} }
            #[allow(unused_macros)] macro_rules! eprint { () => {} }
            #[allow(unused_macros)] macro_rules! eprintln { () => {} }
        };
    }

    #[macro_export]
    macro_rules! define_logger {
        ( $logger:expr ) => {
            let _ = $logger;
            $crate::define_logger!(@impl ($)($logger));
        };
        ( @impl ($d:tt)($logger:expr) ) => {
            #[allow(unused_macros)]
            macro_rules! dd {
                { $d expr:expr } => {
                    if $logger.is_some() {
                        $d expr
                    }
                };
            }

            #[allow(unused_macros)]
            macro_rules! dln {
                ( $d($d tt:tt)* ) => {{
                    if let Some(logger) = $logger.as_mut() {
                        logger.debug_line_prefix(::core::line!());
                        write_args!(logger, ":?", { logger.seperator(", ") }, (), ($d($d tt)*));
                        logger.ln();
                    }
                }};
            }

            #[allow(unused_macros)]
            macro_rules! dwr {
                ( $d($d tt:tt)* ) => {{
                    if let Some(logger) = $logger.as_mut() {
                        logger.debug_line_prefix(::core::line!());
                        write_args!(logger, ":?", { logger.seperator(", ") }, (), ($d($d tt)*));
                    }
                }};
            }

            #[allow(unused_macros)]
            macro_rules! dlf {
                ( $d( $d tt:tt )* ) => {{
                    if let Some(logger) = $logger.as_mut() {
                        logger.debug_line_prefix(::core::line!());
                        writeln!(logger.writer_mut(), $d( $d tt )*).unwrap();
                    }
                }}
            }

            #[allow(unused_macros)]
            macro_rules! dwf {
                ( $d( $d tt:tt )* ) => {{
                    if let Some(logger) = $logger.as_mut() {
                        logger.debug_line_prefix(::core::line!());
                        write!(logger.writer_mut(), $d( $d tt )*).unwrap();
                    }
                }}
            }
        };
    }

    #[macro_export]
    macro_rules! forbid_stdio {
        () => {
            #[allow(unused_macros)]
            macro_rules! dbg {
                () => {
                    compile_error!();
                };
            }
            #[allow(unused_macros)]
            macro_rules! print {
                () => {
                    compile_error!();
                };
            }
            #[allow(unused_macros)]
            macro_rules! println {
                () => {
                    compile_error!();
                };
            }
            #[allow(unused_macros)]
            macro_rules! eprint {
                () => {
                    compile_error!();
                };
            }
            #[allow(unused_macros)]
            macro_rules! eprintln {
                () => {
                    compile_error!();
                };
            }
        };
    }

    #[macro_export]
    macro_rules! write_args {
        ( $writer:expr, $format:literal, $sep:expr, (), ( $(,)? ) ) => {};
        ( $writer:expr, $format:literal, $sep:expr, ( $($args:expr),* ), ( .. $($rest:tt)* ) ) => {
            write_args!( $writer, $format, $sep, ( ("", " ", "") $(, $args)* ), ( $($rest)* ));
        };
        ( $writer:expr, $format:literal, $sep:expr, ( $($args:expr),* ), ( ## $($rest:tt)* ) ) => {
            write_args!( $writer, $format, $sep, ( ("", "\n", "") $(, $args)* ), ( $($rest)* ));
        };
        ( $writer:expr, $format:literal, $sep:expr, ( $($args:expr),* ), ( && $($rest:tt)* ) ) => {
            write_args!( $writer, $format, $sep, ( ("", "", "") $(, $args)* ), ( $($rest)* ));
        };
        (
            $writer:expr, $format:literal, $sep:expr,
            ( $($args:expr),* ), ( ?? $expr:expr $(, $($rest:tt)*)? )
        ) => {
            $sep;
            write_arg!( $writer, "", ::core::concat!(::core::stringify!($expr), " = "), (), ());
            write_arg!( $writer, $format, $expr, (), ( $($args),* ));
            write_args!( $writer, $format, $sep, (), ( $($($rest)*)? ));
        };
        (
            $writer:expr, $format:literal, $sep:expr,
            ( $($args:expr),* ), ( $expr:expr $(, $($rest:tt)*)? )
        ) => {
            $sep;
            write_arg!( $writer, $format, $expr, (), ( $($args),* ));
            write_args!( $writer, $format, $sep, (), ( $($($rest)*)? ));
        };
    }

    #[macro_export]
    macro_rules! write_arg {
        ( $writer:expr, $format:literal, $expr:expr, $tail:expr, ( $head:expr $(, $rest:expr)* ) ) => {
            write_arg!( $writer, $format, $expr, ($head, $tail), ( $($rest),* ));
        };
        ( $writer:expr, $format:literal, $expr:expr, (), () ) => {
            write!($writer.writer_mut(), ::core::concat!("{", $format, "}"), &$expr).unwrap();
        };
        ( $writer:expr, $format:literal, $expr:expr, $tail:expr, () ) => {
            write!(
                $writer.writer_mut(),
                ::core::concat!("{", $format, "}"),
                $crate::joined::Joined::new($expr, $tail)
            ).unwrap();
        };
    }
}

mod io {
    pub use std::io::{BufRead, BufReader, BufWriter, Read, Sink, Write};

    use crate::mode::Mode;
    use crate::reader::Reader;
    use crate::writer::Writer;

    #[derive(Clone, Debug)]
    pub struct Io<R: BufRead, W: Write, L: Write> {
        pub reader: Reader<R>,
        pub writer: Writer<W>,
        pub logger: Option<Writer<L>>,
    }

    impl<R: Read, W: Write> Io<BufReader<R>, BufWriter<W>, Sink> {
        pub fn new(reader: R, writer: W) -> Self {
            let reader = Reader::new(BufReader::new(reader));
            let writer = Writer::new(BufWriter::new(writer));
            let logger = None;
            Self {
                reader,
                writer,
                logger,
            }
        }

        pub fn with_logger<L: Write>(self, logger: L) -> Io<BufReader<R>, BufWriter<W>, L> {
            let reader = self.reader;
            let writer = self.writer;
            let logger = Some(Writer::new(logger));
            Io {
                reader,
                writer,
                logger,
            }
        }
    }
}

mod mode {
    #[derive(Clone, Copy, Debug, Eq, PartialEq)]
    pub enum Mode {
        Release,
        Debug,
    }

    impl Mode {
        pub fn is_release(self) -> bool {
            self == Self::Release
        }

        pub fn is_debug(self) -> bool {
            self == Self::Debug
        }
    }
}

mod readable {
    use std::fmt;
    use std::io::{self, BufRead};

    use crate::reader::Reader;

    pub trait Readable: Sized {
        fn read<R: BufRead>(reader: &mut Reader<R>) -> io::Result<Self>;
    }

    pub trait ReadableWithFromStr {}

    macro_rules! def {
        ( $($ty:ty),* ) => {
            $( impl ReadableWithFromStr for $ty {} )*
        };
    }
    def!(u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize, f32, f64);

    impl<T> Readable for T
    where
        T: std::str::FromStr + ReadableWithFromStr,
        T::Err: fmt::Debug,
    {
        #[track_caller]
        fn read<R: BufRead>(reader: &mut Reader<R>) -> io::Result<Self> {
            Ok(reader.read_word()?.parse::<T>().unwrap())
        }
    }

    impl Readable for String {
        #[track_caller]
        fn read<R: BufRead>(reader: &mut Reader<R>) -> io::Result<Self> {
            Ok(reader.read_word()?.to_string())
        }
    }

    impl Readable for char {
        #[track_caller]
        fn read<R: BufRead>(reader: &mut Reader<R>) -> io::Result<Self> {
            Ok(reader.read_char()?)
        }
    }

    macro_rules! def {
        ( $($tn:ident),* ) => {
            def!(@impl ()( $($tn),* ));
        };
        ( @impl ( $($ts:ident),* ) ) => {
            impl< $($ts),* > Readable for ( $($ts,)* )
            where
                $($ts: Readable,)*
            {
                #[track_caller]
                fn read<R: BufRead>(reader: &mut Reader<R>) -> io::Result<Self> {
                    Ok(( $($ts::read(reader)?,)* ))
                }
            }
        };
        ( @impl ( $($ts:ident),* )() ) => {};
        ( @impl ( $($ts:ident),* )( $t1:ident $(, $tn:ident)* ) ) => {
            def!(@impl ( $($ts,)* $t1 ));
            def!(@impl ( $($ts,)* $t1 )( $($tn),* ));
        };
    }
    def!(T1, T2, T3, T4, T5, T6, T7, T8);
}

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

    use crate::readable::Readable;

    #[derive(Clone, Debug)]
    pub struct Reader<R: BufRead> {
        reader: R,
        line: String,
        offset: usize,
    }

    impl<R: BufRead> Reader<R> {
        pub fn new(reader: R) -> Self {
            Self {
                reader,
                line: String::new(),
                offset: 0,
            }
        }

        pub fn reader(&self) -> &R {
            &self.reader
        }

        pub fn reader_mut(&mut self) -> &mut R {
            &mut self.reader
        }

        #[track_caller]
        fn goto_word(&mut self) -> io::Result<()> {
            loop {
                if self.offset >= self.line.len() {
                    self.line.clear();
                    let len = self.reader.read_line(&mut self.line)?;
                    if len == 0 {
                        panic!("Unexpected EOF");
                    }
                    self.offset = 0;
                } else if self.line.as_bytes()[self.offset].is_ascii_whitespace() {
                    self.offset += 1;
                } else {
                    return Ok(());
                }
            }
        }

        #[track_caller]
        pub fn read_word(&mut self) -> io::Result<&str> {
            self.goto_word()?;
            let line = self.line.as_bytes();
            let start = self.offset;
            let mut end = start + 1;
            while end < self.line.len() && !line[end].is_ascii_whitespace() {
                end += 1;
            }
            self.offset = end + 1;
            let word = unsafe { std::str::from_utf8_unchecked(&line[start..end]) };
            return Ok(word);
        }

        #[track_caller]
        pub fn read_char(&mut self) -> io::Result<char> {
            self.goto_word()?;
            let ch = self.line[self.offset..].chars().next().unwrap();
            self.offset += ch.len_utf8();
            return Ok(ch);
        }

        #[track_caller]
        pub fn read<T: Readable>(&mut self) -> io::Result<T> {
            T::read(self)
        }

        #[track_caller]
        pub fn read_n<T: Readable>(
            &mut self,
            len: usize,
        ) -> impl '_ + Iterator<Item = io::Result<T>> {
            (0..len).map(move |_| T::read(self))
        }

        #[track_caller]
        pub fn read_ascii(&mut self) -> Result<&[u8], io::Error> {
            Ok(self.read_word()?.as_bytes())
        }

        #[track_caller]
        pub fn read_decimal(&mut self) -> Result<impl '_ + Iterator<Item = u8>, io::Error> {
            Ok(self
                .read_ascii()?
                .iter()
                .inspect(|&&ch| assert!(ch >= b'0' && ch <= b'9'))
                .map(|ch| ch - b'0'))
        }

        #[track_caller]
        pub fn read_bits(&mut self, one: u8) -> Result<impl '_ + Iterator<Item = bool>, io::Error> {
            Ok(self.read_ascii()?.iter().map(move |ch| *ch == one))
        }
    }
}

mod writer {
    use core::fmt::Display;
    use std::io::{self, Write};

    #[derive(Clone, Debug)]
    pub struct Writer<W: Write> {
        writer: W,
        is_new_line: bool,
    }

    impl<W: Write> Writer<W> {
        pub fn new(writer: W) -> Self {
            Self {
                writer,
                is_new_line: true,
            }
        }

        pub fn writer(&self) -> &W {
            &self.writer
        }

        pub fn writer_mut(&mut self) -> &mut W {
            &mut self.writer
        }

        pub fn is_new_line(&self) -> bool {
            self.is_new_line
        }

        pub fn space(&mut self) {
            if self.is_new_line {
                self.is_new_line = false;
            } else {
                write!(self.writer, " ").unwrap();
            }
        }

        pub fn seperator(&mut self, seperator: &str) {
            if self.is_new_line {
                self.is_new_line = false;
            } else {
                write!(self.writer, "{}", seperator).unwrap();
            }
        }

        pub fn ln(&mut self) {
            self.is_new_line = true;
            writeln!(self.writer).unwrap();
        }

        pub fn flush(&mut self) {
            self.writer.flush().unwrap();
        }

        pub fn debug_line_prefix(&mut self, line: u32) {
            if self.is_new_line {
                write!(self.writer, "[{}] ", line).unwrap();
            }
        }
    }
}

mod joined {
    use core::cell::RefCell;
    use core::fmt::{self, Debug, Display, Formatter};

    #[derive(Clone)]
    pub struct Joined<I, S>(RefCell<Option<I>>, S);

    #[derive(Clone, Debug)]
    pub struct JoinedOnce<I, S>(pub I, pub S);

    impl<I, S> Joined<I, S> {
        pub fn new(iterable: I, seperators: S) -> Self {
            let iterable = RefCell::new(Some(iterable));
            Self(iterable, seperators)
        }
    }

    impl<I, S> JoinedOnce<I, S> {
        pub fn new(iterable: I, seperators: S) -> Self {
            Self(iterable, seperators)
        }
    }

    macro_rules! def {
        ( $display:ident, $joined:ident ) => {
            pub trait $joined {
                fn into_fmt(self, f: &mut Formatter<'_>) -> fmt::Result;
            }

            impl<I, S> $display for Joined<I, S>
            where
                JoinedOnce<I, S>: $joined,
                S: Copy,
            {
                fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
                    let iterable = self.0.borrow_mut().take().unwrap();
                    JoinedOnce::new(iterable, self.1).into_fmt(f)
                }
            }

            impl<T, I, Ss> $joined for JoinedOnce<I, ((&str, &str, &str), Ss)>
            where
                I: IntoIterator<Item = T>,
                Ss: Copy,
                JoinedOnce<T, Ss>: $joined,
            {
                fn into_fmt(self, f: &mut Formatter<'_>) -> fmt::Result {
                    let mut iter = self.0.into_iter();
                    f.write_str(self.1 .0 .0)?;
                    if let Some(first) = iter.next() {
                        JoinedOnce::new(first, self.1 .1).into_fmt(f)?;
                        for item in iter {
                            f.write_str(self.1 .0 .1)?;
                            JoinedOnce::new(item, self.1 .1).into_fmt(f)?;
                        }
                    }
                    f.write_str(self.1 .0 .2)?;
                    Ok(())
                }
            }

            impl<T> $joined for JoinedOnce<T, ()>
            where
                T: $display,
            {
                fn into_fmt(self, f: &mut Formatter<'_>) -> fmt::Result {
                    self.0.fmt(f)
                }
            }
        };
    }

    def!(Display, JoinedDisplay);
    def!(Debug, JoinedDebug);
}

mod lfmt {
    #[macro_export]
    macro_rules! lfmt {
        () => {{ "" }};
        ( @impl ($($pattern:literal),*) $(, ($($args:tt)*))? ) => {{
            use ::core::fmt::{Debug, Display, Formatter, Result};

            #[derive(Clone, Copy)]
            struct LazyFormat<F: Fn(&mut Formatter<'_>) -> Result>(F);

            impl<F: Fn(&mut Formatter<'_>) -> Result> Debug for LazyFormat<F> {
                #[inline]
                fn fmt(&self, f: &mut Formatter<'_>) -> Result {
                    f.write_str(concat!("lazy_format(", stringify!(
                        ::core::concat!($($pattern)*),
                        $(, $($args)*)?), ")"))?;
                    (self.0)(f)
                }
            }

            impl<F: Fn(&mut Formatter<'_>) -> Result> Display for LazyFormat<F> {
                #[inline]
                fn fmt(&self, f: &mut Formatter<'_>) -> Result {
                    (self.0)(f)
                }
            }

            LazyFormat(#[inline] move |fmt: &mut Formatter<'_>| -> Result {
                ::core::write!(fmt, ::core::concat!($($pattern),*) $(, $($args)*)?)
            })
        }};
        ( @impl $($pattern:literal: $args:expr),* ) => {{
            $crate::lfmt!( @impl ($($pattern),*), ($($args),*) )
        }};
        ( $pattern:literal $(, $($args:tt)*)? ) => {{
            $crate::lfmt!( @impl ($pattern) $(, ($($args)*))? )
        }};
        ( , $arg:expr $(, $args:expr)* ) => {{
            $crate::lfmt!( @impl "{}": $arg $(, " {}": $args)* )
        }};
    }
}

mod problem {
    use std::io::{self, BufRead, Write};
    use std::str::from_utf8;

    use crate::io::Io;
    use crate::mode::Mode;
    use crate::trim_lines::TrimLines;

    pub trait Problem {
        fn solve<R: BufRead, W: Write, L: Write>(io: &mut Io<R, W, L>);

        fn output(reader: &[u8]) -> String {
            let mut output = Vec::new();
            let writer = &mut output;
            Self::solve(&mut Io::new(reader, writer).with_logger(io::stderr()));
            from_utf8(&output).unwrap().to_string()
        }

        #[track_caller]
        fn test(input: &str) {
            let mut is_ok = true;
            let mut splitted = input.split_whitespace();
            let io_seperator = splitted.next().unwrap();
            let case_seperator = splitted.next().unwrap();
            for case in input.split(case_seperator).skip(1) {
                let io: Vec<&str> = case.split(io_seperator).collect();
                assert_eq!(io.len(), 2);
                let input = io[0];
                let output = Self::output(io[0].as_bytes());
                let answer = io[1].trim_lines();
                if output != answer {
                    let mut diff = String::new();
                    let mut output_lines = output.trim_end().split("\n");
                    let mut answer_lines = answer.trim_end().split("\n");
                    loop {
                        let (output_line, answer_line) = (output_lines.next(), answer_lines.next());
                        if output_line.is_none() && answer_line.is_none() {
                            break;
                        }
                        match (output_line, answer_line) {
                            (None, None) => break,
                            (Some(output_line), Some(answer_line)) => {
                                if output_line == answer_line {
                                    diff = diff + "\x1b[0;33m    " + output_line + "\x1b[0m\n";
                                } else {
                                    diff = diff + "\x1b[0;31m  - " + output_line + "\x1b[0m\n";
                                    diff = diff + "\x1b[0;32m  + " + answer_line + "\x1b[0m\n";
                                }
                            }
                            (Some(output_line), None) => {
                                diff = diff + "\x1b[0;31m  - " + output_line + "\x1b[0m\n";
                            }
                            (None, Some(answer_line)) => {
                                diff = diff + "\x1b[0;32m  + " + answer_line + "\x1b[0m\n";
                            }
                        }
                    }
                    writeln!(
                        io::stderr(),
                        "{}\nInput:\n{}Output:\n{}Answer:\n{}Diff:\n{}",
                        "\x1b[0;31mError: Invalid output.\x1b[0m",
                        input
                            .trim_lines()
                            .lines()
                            .map(|line| format!("    {}\n", line))
                            .collect::<String>(),
                        output
                            .lines()
                            .map(|line| format!("    {}\n", line))
                            .collect::<String>(),
                        answer
                            .lines()
                            .map(|line| format!("    {}\n", line))
                            .collect::<String>(),
                        diff
                    )
                    .unwrap();
                    is_ok = false;
                }
            }
            if !is_ok {
                panic!();
            }
        }
    }
}

mod trim_lines {
    pub trait TrimLines {
        fn trim_lines(self) -> String;
    }

    impl TrimLines for &str {
        fn trim_lines(self) -> String {
            let lines: Vec<String> = self
                .trim()
                .lines()
                .map(|line| line.trim().to_string())
                .collect();
            lines.join("\n") + "\n"
        }
    }
}

mod dedup_count {
    use core::iter::FusedIterator;

    #[derive(Clone, Debug)]
    pub struct DedupCountIter<T, I> {
        iter: I,
        prev: Option<(T, usize)>,
    }

    impl<T, I> DedupCountIter<T, I> {
        pub fn new(iter: I) -> Self {
            Self { iter, prev: None }
        }
    }

    impl<T, I> Iterator for DedupCountIter<T, I>
    where
        T: Eq,
        I: Iterator<Item = T>,
    {
        type Item = (T, usize);

        fn next(&mut self) -> Option<Self::Item> {
            loop {
                match (self.prev.take(), self.iter.next()) {
                    (Some((prev, count)), Some(item)) => {
                        if prev == item {
                            self.prev = Some((prev, count + 1));
                        } else {
                            self.prev = Some((item, 1));
                            return Some((prev, count));
                        }
                    }
                    (Some((prev, count)), None) => {
                        return Some((prev, count));
                    }
                    (None, Some(item)) => self.prev = Some((item, 1)),
                    (None, None) => {
                        return None;
                    }
                }
            }
        }
    }

    impl<T, I> FusedIterator for DedupCountIter<T, I>
    where
        T: Eq,
        I: Iterator<Item = T>,
    {
    }

    pub trait DedupCount {
        type Output;
        fn dedup_count(self) -> Self::Output;
    }

    impl<T, I> DedupCount for I
    where
        I: IntoIterator<Item = T>,
    {
        type Output = DedupCountIter<T, I::IntoIter>;
        fn dedup_count(self) -> Self::Output {
            DedupCountIter::new(self.into_iter())
        }
    }
}


#![allow(unused_imports)]

use std::cmp::*;
use std::collections::*;
use std::fmt::Debug;
use std::io::{empty, Read};
use std::str::FromStr;

fn main() {
    let nn = read_vec::<usize>();
    let (n, k) = (nn[0], nn[1]);

    let first = min(k - 1, n - k);
    let result = first + 3 * n;
    println!("{}", result);
}

#[allow(dead_code)]
const DIV: i64 = 1_000_000_007;
#[allow(dead_code)]
const N: usize = 200000;
#[allow(dead_code)]
const CHARS: usize = 'z' as usize - 'a' as usize + 1;

#[allow(dead_code)]
fn print_vec<T: Debug>(a: &Vec<T>) {
    for i in 0..a.len() {
        if i != 0 {
            print!(" ");
        }
        print!("{:?}", a[i]);
    }
    println!();
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut s = String::with_capacity(N);
    std::io::stdin().read_line(&mut s).unwrap();
    s
}

#[allow(dead_code)]
fn read_vec<T: FromStr>() -> Vec<T>
    where T::Err: Debug
{
    return read_line()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
}