//! http://codeforces.com/contest/799/problem/A

fn single_oven_time(n: u32, t: u32, k: u32) -> u64 {
  let mut cakes = 0;
  let mut time = 0;
  while cakes < n {
    cakes += k;
    time += t as u64;
  }
  time
}

fn double_oven_time(n: u32, t: u32, k: u32, d: u32) -> u64 {
  let mut has_oven = false;
  let mut cakes = 0;
  let mut time = 0u64;
  while cakes < n {
    time += 1;
    if time % (t as u64) == 0 { cakes += k; }
    if let (n, false) = time.overflowing_sub(d as u64) {
      if n % (t as u64) == 0 && has_oven { cakes += k; }
    }
    if time == d as u64 { has_oven = true; }
  }
  time
}

fn main() {
  use std::io;
  let mut buf = String::new();
  io::stdin().read_line(&mut buf).unwrap();
  let mut ns = buf.split(" ")
    .map(|str| str.trim().parse::<u32>().unwrap());
  let n = ns.next().unwrap();
  let t = ns.next().unwrap();
  let k = ns.next().unwrap();
  let d = ns.next().unwrap();
  if double_oven_time(n, t, k, d) < single_oven_time(n, t, k) {
    println!("YES");
  } else {
    println!("NO");
  }
}


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

fn main() {
    let v: Vec<i32> = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().split(" ").map(|s| s.parse::<i32>().unwrap()).collect()
    };
    let (a, b, mut n) = (v[0], v[1], v[2]);

    loop {
        n -= gcd(a, n);
        if n == 0 {
            println!("0");
            break;
        }
        n -= gcd(b, n);
        if n == 0 {
            println!("1");
            break;

        }
    }
}


fn input() -> (u8, u8, u8) {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let buf: Vec<u8> = buf
        .trim()
        .split_whitespace()
        .map(|elem| elem.parse().unwrap())
        .collect();
    (buf[0], buf[1], buf[2])
}

fn gcd(x: u8, n: u8) -> u8 {
    if n == 0 {
        return x;
    }
    gcd(n, x % n)
}

fn main() {
    let (a, b, mut n) = input();
    let mut simons_turn = true;

    loop {
        let x = if simons_turn { a } else { b };
        let gcd = gcd(x, n);

        if gcd <= n {
            simons_turn = !simons_turn;
            n -= gcd;
        } else {
            break;
        }
    }

    println!("{}", if simons_turn { 1 } else { 0 });
}


/// Codeforces Round #663 (Div. 2)
/// https://codeforces.com/contest/1391/problem/C

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

fn main() {
    let stdout = io::stdout();
    let mut output = BufWriter::new(stdout.lock());
    let mut stdin = io::stdin();
    let mut input_string = String::new();
    stdin.read_to_string(&mut input_string).unwrap();
    let mut input_iter = input_string.split_whitespace();

    macro_rules! read(() => (input_iter.next().unwrap().parse().unwrap()));
    macro_rules! println(( $( $x:expr ),* ) => (writeln!(output, $( $x, )*).unwrap()));

    let n: usize = read!();
    let modulo = 1_000_000_007;
    let mut solution: u64 = 1;
    let mut power_of_2: u64 = 1;

    for i in 2..(n + 1) {
        solution = (solution * i as u64) % modulo;
        power_of_2 = (power_of_2 * 2) % modulo;
    }

    if solution < power_of_2 {
        solution += modulo;
    }

    solution = (solution - power_of_2) % modulo;

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


use std::io::Read;

fn read<T: std::str::FromStr>() -> T {
    let token: String = std::io::stdin()
        .bytes()
        .map(|c| c.ok().unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

mod mint {
    use std::ops::{Add, BitAnd, Div, Mul, Rem, Shr, Sub};

    #[derive(Copy, Clone)]
    pub struct Mint<T> {
        x: T,
        mo: T,
    }
    impl<T> Mint<T>
    where
        T: Copy,
    {
        pub fn new(x: T, mo: T) -> Mint<T> {
            Mint { x, mo }
        }
    }
    impl<T> Mint<T>
    where
        T: Copy,
    {
        pub fn val(&self) -> T {
            self.x
        }
        pub fn mo(&self) -> T {
            self.mo
        }
    }
    impl<T> Add<T> for Mint<T>
    where
        T: Copy,
        T: Add<Output = T>,
        T: Rem<Output = T>,
    {
        type Output = Mint<T>;
        fn add(self, rhs: T) -> Mint<T> {
            Mint::new((self.val() + rhs % self.mo()) % self.mo(), self.mo())
        }
    }
    impl<T> Add<Mint<T>> for Mint<T>
    where
        T: Copy,
        Mint<T>: Add<T, Output = Mint<T>>,
    {
        type Output = Mint<T>;
        fn add(self, rhs: Mint<T>) -> Mint<T> {
            self + rhs.val()
        }
    }
    impl<T> Sub<T> for Mint<T>
    where
        T: Copy,
        T: Add<Output = T>,
        T: Sub<Output = T>,
        T: Rem<Output = T>,
    {
        type Output = Mint<T>;
        fn sub(self, rhs: T) -> Mint<T> {
            Mint::new(
                (self.val() + self.mo() - rhs % self.mo()) % self.mo(),
                self.mo(),
            )
        }
    }
    impl<T> Sub<Mint<T>> for Mint<T>
    where
        T: Copy,
        Mint<T>: Sub<T, Output = Mint<T>>,
    {
        type Output = Mint<T>;
        fn sub(self, rhs: Mint<T>) -> Mint<T> {
            self - rhs.val()
        }
    }
    impl<T> Mul<T> for Mint<T>
    where
        T: Copy,
        T: Mul<Output = T>,
        T: Rem<Output = T>,
    {
        type Output = Mint<T>;
        fn mul(self, rhs: T) -> Mint<T> {
            Mint::new((self.val() * rhs % self.mo()) % self.mo(), self.mo())
        }
    }
    impl<T> Mul<Mint<T>> for Mint<T>
    where
        T: Copy,
        Mint<T>: Mul<T, Output = Mint<T>>,
    {
        type Output = Mint<T>;
        fn mul(self, rhs: Mint<T>) -> Mint<T> {
            self * rhs.val()
        }
    }

    impl<T> Mint<T>
    where
        T: Copy,
        T: Sub<Output = T>,
        T: Div<Output = T>,
        T: PartialOrd,
        T: PartialEq,
        T: BitAnd<Output = T>,
        T: Shr<Output = T>,
        Mint<T>: Mul<Output = Mint<T>>,
    {
        pub fn pow(self, y: T) -> Mint<T> {
            let one = self.mo() / self.mo();
            let zero = self.mo() - self.mo();
            let mut res = Mint::one(self.mo());
            let mut base = self;
            let mut exp = y;
            while exp > zero {
                if (exp & one) == one {
                    res = res * base;
                }
                base = base * base;
                exp = exp >> one;
            }
            res
        }
    }
    impl<T> Div<T> for Mint<T>
    where
        T: Copy,
        T: Sub<Output = T>,
        T: Div<Output = T>,
        T: PartialOrd,
        T: PartialEq,
        T: BitAnd<Output = T>,
        T: Shr<Output = T>,
        Mint<T>: Mul<Output = Mint<T>>,
    {
        type Output = Mint<T>;
        fn div(self, rhs: T) -> Mint<T> {
            let one = self.mo() / self.mo();
            self * Mint::new(rhs, self.mo()).pow(self.mo() - one - one)
        }
    }
    impl<T> Div<Mint<T>> for Mint<T>
    where
        T: Copy,
        Mint<T>: Div<T, Output = Mint<T>>,
    {
        type Output = Mint<T>;
        fn div(self, rhs: Mint<T>) -> Mint<T> {
            self / rhs.val()
        }
    }
    impl<T> Mint<T>
    where
        T: Copy,
        T: Div<Output = T>,
        Mint<T>: Div<Output = Mint<T>>,
    {
        pub fn inv(self) -> Mint<T> {
            Mint::one(self.mo()) / self
        }
    }
    impl<T> std::fmt::Display for Mint<T>
    where
        T: Copy + std::fmt::Display,
    {
        fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
            write!(f, "{}", self.val())
        }
    }
    impl<T> Mint<T>
    where
        T: Copy,
        T: Sub<Output = T>,
    {
        pub fn zero(mo: T) -> Mint<T> {
            Mint { x: mo - mo, mo }
        }
    }
    impl<T> Mint<T>
    where
        T: Copy,
        T: Div<Output = T>,
    {
        pub fn one(mo: T) -> Mint<T> {
            Mint { x: mo / mo, mo }
        }
    }
}

use mint::Mint;

fn factorials(n: usize, mo: u64) -> (Vec<Mint<u64>>, Vec<Mint<u64>>) {
    let mut fac = vec![Mint::new(0, mo); n];
    let mut fac_inv = vec![Mint::new(0, mo); n];
    fac[0] = Mint::new(1, mo);
    for i in 1..n {
        fac[i] = fac[i - 1] * (i as u64);
    }
    fac_inv[n - 1] = fac[n - 1].inv();
    for i in (0..n - 1).rev() {
        fac_inv[i] = fac_inv[i + 1] * ((i + 1) as u64);
    }
    (fac, fac_inv)
}

fn main() {
    let n: usize = read();
    let mo = 1000000007;
    let (fac, _) = factorials(n + 1, mo);
    let mut ans = fac[n];
    ans = ans - Mint::new(2, mo).pow(n as u64 - 1);
    println!("{}", ans);
}


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

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

fn resolve(hy: i64, ay: i64, dy: i64, hm: i64, am: i64, dm: i64) -> bool {
    let ay = ay - dm;
    let am = am - dy;
    if ay <= 0 {
        return false;
    }
    if am <= 0 {
        return true;
    }
    let yt = (hy - 1) / am;
    let mt = (hm - 1) / ay;
    yt > mt
}

fn solve() {
    let (hy, ay, dy) = parse_line!(i64, i64, i64);
    let (hm, am, dm) = parse_line!(i64, i64, i64);
    let (h, a, d) = parse_line!(i64, i64, i64);
    let mut ans = std::i64::MAX;
    for aadd in 0..200 {
        for dadd in 0..100 {
            let ay = ay + aadd;
            let dy = dy + dadd;
            let mut l: i64 = -1;
            let mut r: i64 = 10001;
            if !resolve(hy + r, ay, dy, hm, am, dm) {
                continue;
            }
            while r - l > 1 {
                let m = (l + r) / 2;
                let hy = hy + m;
                if resolve(hy, ay, dy, hm, am, dm) {
                    r = m;
                }else{
                    l = m;
                }
            }
            let cost = aadd * a + dadd * d + r * h;
            if cost < ans {
                ans = cost;
            }
        }
    }
    println!("{}", ans);
}

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


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

fn exec() {
    let mut sc = Scanner::new();
    let k: i64 = sc.ne();
    let a: i64 = sc.ne();
    let b: i64 = sc.ne();
    let aw = a / k;
    let bw = b / k;
    let mut ok = true;
    if aw == 0 && bw == 0 {
        ok = false;
    } else if aw == 0 {
        ok = b % k == 0;
    } else if bw == 0 {
        ok = a % k == 0;
    }
    if ok {
        println!("{}", aw + bw);
    } else {
        println!("-1");
    }
}

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

#[allow(dead_code)]
impl Precalc {
    pub fn new(n: usize) -> Precalc {
        let mut inv = vec![ModInt::one(); n + 1];
        let mut fact = vec![ModInt::one(); n + 1];
        let mut ifact = vec![ModInt::one(); n + 1];
        for i in 2..(n + 1) {
            inv[i] = -inv[MOD as usize % i] * ModInt(MOD / i as u32);
            fact[i] = fact[i - 1] * ModInt(i as u32);
            ifact[i] = ifact[i - 1] * inv[i];
        }
        Precalc {
            inv: inv,
            fact: fact,
            ifact: ifact,
        }
    }
    pub fn inv(&self, n: usize) -> ModInt {
        self.inv[n]
    }
    pub fn fact(&self, n: usize) -> ModInt {
        self.fact[n]
    }
    pub fn ifact(&self, n: usize) -> ModInt {
        self.ifact[n]
    }
    pub fn comb(&self, n: usize, k: usize) -> ModInt {
        if k > n {
            return ModInt::zero();
        }
        self.fact[n] * self.ifact[k] * self.ifact[n - k]
    }
}
// ---------- end Precalc ----------
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

// ここまで

fn run() {
    input! {
        n: usize,
        m: u64,
    }
    if m > n as u64 - 1 {
        println!("0");
        return;
    }
    let m = m as usize;
    let pc = Precalc::new(n + m);
    if m == 0 {
        println!("{}", pc.fact(n));
        return;
    }
    let mut ans = ModInt::zero();
    let mut sign = ModInt::one();
    for i in (1..=(n - m)).rev() {
        ans += sign * pc.comb(n - m, i) * ModInt::from(i).pow(n as u32);
        sign = -sign;
    }
    ans *= pc.comb(n, n - m) * ModInt(2);
    println!("{}", ans);
}

fn main() {
    run();
}


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

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

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

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

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

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

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

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

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

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

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

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

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

#[allow(dead_code)]
impl Precalc {
    pub fn new(n: usize) -> Precalc {
        let mut inv = vec![ModInt::one(); n + 1];
        let mut fact = vec![ModInt::one(); n + 1];
        let mut ifact = vec![ModInt::one(); n + 1];
        for i in 2..(n + 1) {
            inv[i] = -inv[MOD as usize % i] * ModInt(MOD / i as u32);
            fact[i] = fact[i - 1] * ModInt(i as u32);
            ifact[i] = ifact[i - 1] * inv[i];
        }
        Precalc {
            inv: inv,
            fact: fact,
            ifact: ifact,
        }
    }
    pub fn inv(&self, n: usize) -> ModInt {
        self.inv[n]
    }
    pub fn fact(&self, n: usize) -> ModInt {
        self.fact[n]
    }
    pub fn ifact(&self, n: usize) -> ModInt {
        self.ifact[n]
    }
    pub fn comb(&self, n: usize, k: usize) -> ModInt {
        if k > n {
            return ModInt::zero();
        }
        self.fact[n] * self.ifact[k] * self.ifact[n - k]
    }
}
// ---------- end Precalc ----------
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn run() {
    input! {
        n: usize,
        m: u64,
    }
    if m > n as u64 - 1 {
        println!("0");
        return;
    }
    let m = m as usize;
    let pc = Precalc::new(n + m);
    if m == 0 {
        println!("{}", pc.fact(n));
        return;
    }
    let mut ans = ModInt::zero();
    let mut sign = ModInt::one();
    for i in (1..=(n - m)).rev() {
        ans += sign * pc.comb(n - m, i) * ModInt::from(i).pow(n as u32);
        sign = -sign;
    }
    ans *= pc.comb(n, n - m) * ModInt(2);
    println!("{}", ans);
}
fn main() {
    run();
}


// https://codeforces.com/problemset/problem/732/A
use std::io;

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

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

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

    let k = words[0];
    let r = words[1];

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


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

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

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

fn run() {
    input! {
        n: usize,
        l: u64,
    }
    let mut dp = vec![1u64; n + 1];
    for i in 2..=n {
        dp[i] = dp[i - 1] + dp[i - 2];
    }
    let mut ans = vec![];
    let mut l = l - 1;
    let mut s = 1;
    while s <= n {
        if dp[n - s] > l {
            ans.push(s);
            s += 1;
        } else {
            l -= dp[n - s];
            ans.push(s + 1);
            ans.push(s);
            s += 2;
        }
    }
    let mut s = String::new();
    for a in ans {
        s.push_str(&format!("{} ", a));
    }
    s.pop();
    println!("{}", s);
}

fn main() {
    run();
}


use std::io;
fn main() {
 let mut n = String::new();
 io::stdin().read_line(&mut n).expect("failed to read");
 let n :u64 = n.trim().parse().expect("failed to parse");
 let counter:u64 = n/2520;
 println!("{}", counter);
}


use std::cmp::{max, min};
use std::io::{stdin, stdout, BufWriter, Write};

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>,
}
impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn main() {
    let mut scanner = Scanner::default();
    let info: Vec<usize> = (0..2).map(|_| scanner.next()).collect();
    let arr: Vec<char> = scanner.next::<String>().chars().collect();
    let mut dp = vec![false; arr.len()];
    dp[0] = true;
    dp[arr.len() - 1] = true;

    let mut count = 1;
    let mut current_pos = info[1];

    while !dp[std::cmp::min(current_pos, arr.len() - 1)] {
        dp[current_pos] = true;
        match arr[current_pos] {
            '1' => {
                current_pos += info[1];
                count += 1;
            }
            '0' => current_pos -= 1,
            _ => (),
        }
    }
    if current_pos >= arr.len() - 1 {
        println!("{}", count);
    } else {
        println!("-1");
    }
}


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

fn exec() {
    let mut sc = Scanner::new();
    let n: i64 = sc.ne();
    let m: usize = 100;
    let inf = 1e18 as i64 * 2;
    let mut dp = vec![inf; m];
    dp[0] = 1;
    dp[1] = 2;
    for i in 2..m {
        dp[i] = dp[i - 1] + dp[i - 2];
        if dp[i] > inf {
            break;
        }
    }
    let pos = dp.iter().position(|&x| x > n).unwrap();
    // for i in 0..m {
    //     println!("{} {}", i, dp[i]);
    // }
    println!("{}", pos - 1);
}
const DEFAULT_STACK: usize = 16 * 1024 * 1024;
fn main() {
    let builder = thread::Builder::new();
    let th = builder.stack_size(DEFAULT_STACK);
    let handle = th.spawn(|| { exec(); }).unwrap();
    let _ = handle.join();
}

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

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


#![allow(dead_code, unused_macros, unused_imports)]
use std::collections::*;
use std::io;
use std::io::Write;
macro_rules! fprintln {
    ($dst:expr) => (
        $dst.write("\n".as_bytes()).unwrap();
    );
    ($dst:expr, $($arg:tt)*) => ( {
        $dst.write_fmt(format_args!($($arg)*)).unwrap();
        $dst.write("\n".as_bytes()).unwrap();
    }
    );
}

macro_rules! fprintvec {
    ($dst:expr, $arg:expr) => {{
        fprintln!(
            $dst,
            "{}",
            $arg.iter()
                .map(|x| format!("{}", x))
                .collect::<Vec<String>>()
                .join(" ")
        );
    }};
}

macro_rules! parse_input {
    ($t:ident) => {{
        let mut input_line = String::new();
        io::stdin().read_line(&mut input_line).unwrap();
        input_line
            .trim_end_matches("\n")
            .trim_end_matches("\r")
            .parse::<$t>()
            .unwrap()
    }};
}

macro_rules! split_input {
    ($t:ident) => {{
        parse_input!(String)
            .split(" ")
            .map(|z| z.parse::<$t>().unwrap())
            .collect::<Vec<$t>>()
    }};
}

fn depth(t: i64, k: i64, start: i64) -> i64 {
    let v;
    let t = t % (2 * k);
    if t <= k {
        v = t;
    } else {
        v = k - (t - k);
    }
    v + start
}

fn slow(depths: &Vec<i64>, k: i64, l: i64) -> bool {
    let mut valid = (0..=2 * k).collect::<HashSet<i64>>();
    for p in depths.iter() {
        let mut next = HashSet::new();
        for z in valid.iter() {
            for x in 1..=(2 * k) {
                if depth(z + x, k, *p) <= l {
                    next.insert((z + x) % (2 * k));
                } else {
                    break;
                }
            }
        }
        valid = next;
    }
    valid.len() > 0
}

fn main() {
    let stdout = io::stdout();
    let lock = stdout.lock();
    let mut w = io::BufWriter::new(lock);
    let num_tests = parse_input!(usize);
    // let num_tests = 1;
    for _ in 0..num_tests {
        let limits = split_input!(i64);
        let n = limits[0];
        let k = limits[1];
        let l = limits[2];
        let vals = split_input!(i64);
        let mut start = -k;
        let mut valid = true;
        // for (p, &d) in vals.iter().enumerate() {
        //     if d > l {
        //         valid = false;
        //         break;
        //     }
        //     if d + k <= l {
        //         start = -k;
        //     } else {
        //         let nt = start + 1;
        //         let bad = (l - d) + 1;
        //         let good = -bad;
        //         if nt >= bad {
        //             valid = false;
        //             break;
        //         }
        //         start = std::cmp::max(nt, good);
        //     }
        //     dbg!(start);
        // }
        valid = slow(&vals, k, l);
        if valid {
            fprintln!(w, "YES");
        } else {
            fprintln!(w, "NO");
        }
    }
}


#![allow(dead_code, unused_imports)]

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

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

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

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

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

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

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

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

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

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

fn gcd(a: u64, b: u64) -> u64 {
    let mut a = a;
    let mut b = b;
    while a != b {
        if a > b {
            a = a - b
        } else {
            b = b - a
        }
    }
    a
}

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

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

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

use std::cmp::{max, min};
use std::collections::VecDeque;

fn first_factor(n: u32) -> u32 {
    if n % 2 == 0 {
        return 2;
    }
    if n % 3 == 0 {
        return 3;
    }
    let mut f = 6;
    while (f - 1) * (f - 1) <= n {
        if n % (f - 1) == 0 {
            return f - 1;
        }
        if n % (f + 1) == 0 {
            return f + 1;
        }
        f += 6;
    }
    return n;
}

fn found(d: Vec<u16>, k: u16, limit: u16) -> bool {
    if d.is_empty() {
        return true;
    }
    let p = (0..k).chain((1..k + 1).rev()).collect::<Vec<_>>();
    for start in 0..p.len() {
        if d.iter()
            .enumerate()
            .map(|(i, di)| di + p[(i + start) % p.len()])
            .all(|di| di <= limit)
        {
            return true;
        }
    }
    false
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    for _ in 0..read_usize() {
        let (_n, k, l) = read_3::<u16, u16, u16>();
        let d = read_multiple();
        let mut dead = false;
        let mut gap = Vec::new();
        for di in d {
            if k + di <= l {
                if !found(gap, k, l) {
                    dead = true
                }
                gap = Vec::new();
            } else {
                gap.push(di)
            }
        }
        if !found(gap, k, l) {
            dead = true
        }
        if dead {
            println!("No")
        } else {
            println!("Yes")
        }
    }
    Ok(())
}


use std::io;

fn is_palindrome(x: &str) -> bool {
    if x.len() <= 1 {
        return true;
    }
    let b = x.as_bytes();
    let mut index = 0;
    while index < (x.len() / 2) {
        if b[index] != b[x.len() - index - 1] {
            return false;
        }
        index = index + 1;
    }
    true
}

fn is_quasi_palindrome(x: &str) -> bool {
    let mut k = String::from(x);
    let mut count = 0;
    while count < 10 {
        if is_palindrome(k.as_str()) {
            return true;
        }
        k = String::from("0") + &k;
        count = count + 1;
    }
    false
}

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

    match is_quasi_palindrome(input.trim_right()) {
        true => println!("YES"),
        false => println!("NO"),
    }

}


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

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

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

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

    let n = input.i();
    let a = input.i();
    let b = input.i();
    println!("{}", ((a - 1 + b) % n + n) % n + 1);
}


const MOD: i64 = 998244353;

fn main() {
    input! {
        n: usize,
        m: i64,
    }
    let mut ans = 0;
    for i in 1..=n {
        ans += modpow(m, i as i64);
        ans %= MOD;
    }
    let mut p = vec![true; n + 1];
    p[0] = false;
    p[1] = false;
    for i in 2..=n {
        if p[i] && i * i <= n {
            for j in (i * i..=n).step_by(i) {
                p[j] = false;
            }
        }
    }
    let mut dp = vec![0; n];
    let mut f = 1;
    for i in 0..n {
        if p[i + 1] {
            f *= (i + 1) as i64;
            f = f.min(m + 1);
        }
        dp[i] = m / f % MOD;
        if i > 0 {
            dp[i] *= dp[i - 1];
            dp[i] %= MOD;
        }
        ans += MOD - dp[i];
        ans %= MOD;
    }
    println!("{}", ans);
}

pub fn modpow(mut base: i64, mut exp: i64) -> i64 {
    let mut ans = 1;
    base %= MOD;
    while exp > 0 {
        if exp % 2 == 1 {
            ans = ans * base % MOD;
        }
        base = base * base % MOD;
        exp >>= 1;
    }
    ans
}

mod io {
    use std::cell::RefCell;
    use std::io::*;

    std::thread_local! {
        pub static STDIN: RefCell<Stdin> = RefCell::new(stdin());
        pub static STDOUT: RefCell<BufWriter<Stdout>> = RefCell::new(BufWriter::new(stdout()));
    }

    #[macro_export]
    macro_rules! input {
        () => {};
        (mut $var:ident: $t:tt, $($rest:tt)*) => {
            let mut $var = __input_inner!($t);
            input!($($rest)*)
        };
        ($var:ident: $t:tt, $($rest:tt)*) => {
            let $var = __input_inner!($t);
            input!($($rest)*)
        };
        (mut $var:ident: $t:tt) => {
            let mut $var = __input_inner!($t);
        };
        ($var:ident: $t:tt) => {
            let $var = __input_inner!($t);
        };
    }

    #[macro_export]
    macro_rules! __input_inner {
        (($($t:tt),*)) => {
            ($(__input_inner!($t)),*)
        };
        ([$t:tt; $n:expr]) => {
            (0..$n).map(|_| __input_inner!($t)).collect::<Vec<_>>()
        };
        ([$t:tt]) => {{
            let n = __input_inner!(usize);
            (0..n).map(|_| __input_inner!($t)).collect::<Vec<_>>()
        }};
        (chars) => {
            __input_inner!(String).chars().collect::<Vec<_>>()
        };
        (bytes) => {
            __input_inner!(String).into_bytes()
        };
        (usize1) => {
            __input_inner!(usize) - 1
        };
        ($t:ty) => {
            $crate::io::STDIN.with(|r| {
                use std::io::BufRead;
                let r = r.borrow_mut();
                let mut r = r.lock();
                let mut s = vec![];
                loop {
                    let buf = r.fill_buf().unwrap();
                    if buf.is_empty() {
                        break;
                    }
                    if let Some(i) = buf.iter().position(u8::is_ascii_whitespace) {
                        s.extend_from_slice(&buf[..i]);
                        r.consume(i + 1);
                        if !s.is_empty() {
                            break;
                        }
                    } else {
                        s.extend_from_slice(buf);
                        let n = buf.len();
                        r.consume(n);
                    }
                }
                std::str::from_utf8(&s).unwrap().parse::<$t>().unwrap()
            })
        };
    }

    #[macro_export]
    macro_rules! println {
        () => {
            $crate::io::STDOUT.with(|w| {
                use std::io::Write;
                std::writeln!(w.borrow_mut()).unwrap()
            })
        };
        ($($arg:tt)*) => {
            $crate::io::STDOUT.with(|w| {
                use std::io::Write;
                std::writeln!(w.borrow_mut(), $($arg)*).unwrap()
            })
        };
    }

    #[macro_export]
    macro_rules! print {
        ($($arg:tt)*) => {
            $crate::io::STDOUT.with(|w| {
                use std::io::Write;
                std::write!(w.borrow_mut(), $($arg)*).unwrap()
            })
        };
    }

    #[macro_export]
    macro_rules! flush {
        () => {
            $crate::io::STDOUT.with(|w| {
                use std::io::Write;
                w.borrow_mut().flush().unwrap()
            })
        };
    }
}


use std::collections::VecDeque;
use std::fmt::{Display, Formatter};
use std::io::{Read, stdin};
use std::marker::PhantomData;
use std::ops::{Add, Mul, Range, RangeBounds, Sub};

fn main() {
    let mut scan = Scanner::default();

    let n = scan.next_usize();
    let m = scan.next_usize();

    let mut sum = M::<998244353>(0);
    let mut prod = M::<998244353>(1);

    let mut pos_factor = 1;
    for i in 1..=n {
        if is_prime(i) {
            pos_factor *= i;
        }
        let pos_count = m / pos_factor;
        if pos_count == 0 { break; }
        prod = prod * M(pos_count);
        sum = sum + prod;
    }

    let mut total = M(0);
    for i in 1..=n {
        total = total + M(m).pow(M(i));
    }
    let amb = total - sum;

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

struct PrimeIterator {
    primes: Vec<usize>
}

fn primes() -> PrimeIterator {
    PrimeIterator{ primes: Vec::new() }
}

impl Iterator for PrimeIterator {
    type Item = usize;

    fn next(&mut self) -> Option<Self::Item> {
        for i in self.primes.last().map(|x| *x + 1).unwrap_or(2).. {
            if self.primes.iter().all(|prime| i % prime != 0) {
                self.primes.push(i);
                return Some(i)
            }
        }
        unreachable!()
    }
}

fn firstfac(x: usize) -> usize {
    if x % 2 == 0 {
        return 2;
    };
    for n in (1..).map(|m| 2 * m + 1).take_while(|m| m * m <= x) {
        if x % n == 0 {
            return n;
        };
    }
    x
}

pub fn is_prime(n: usize) -> bool {
    if n <= 1 { return false }
    firstfac(n) == n
}

#[derive(Clone, Copy)]
struct M<const P: usize>(usize);

impl<const P: usize> Add for M<P> {
    type Output = M<P>;

    #[inline(always)]
    fn add(self, rhs: Self) -> Self::Output {
        let mut v = self.0 + rhs.0;
        if v >= P {
            v -= P
        }
        M(v)
    }
}

impl<const P: usize> Sub for M<P> {
    type Output = M<P>;

    #[inline(always)]
    fn sub(self, rhs: Self) -> Self::Output {
        let mut v = self.0.wrapping_sub(rhs.0);
        if v >= P {
            v = v.wrapping_add(P)
        }
        M(v)
    }
}

impl<const P: usize> Mul for M<P> {
    type Output = M<P>;

    #[inline(always)]
    fn mul(self, rhs: Self) -> Self::Output {
        M(((self.0 as u128 * rhs.0 as u128) % P as u128) as usize)
    }
}

impl<const P: usize> Display for M<P> {
    #[inline(always)]
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        Display::fmt(&self.0, f)
    }
}

impl<const P: usize> M<P> {
    #[inline(always)]
    pub fn pow(mut self, n: Self) -> Self {
        let mut n = n.0;
        let mut res: Self = Self(1);
        while n > 0 {
            if n % 2 == 1 { res = res * self }
            self = self * self;
            n /= 2;
        }

        res
    }

    #[inline(always)]
    pub fn inv(self) -> Self {
        self.pow(M(P - 2))
    }
}

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>,
}
impl Scanner {
    fn next_usize(&mut self) -> usize {
        self.next()
    }

    fn next_string(&mut self) -> String {
        self.next()
    }

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

    fn iter<T: std::str::FromStr>(&mut self) -> ScannerIter<T> {
        ScannerIter {
            phantom: Default::default(),
            scanner: self,
        }
    }
}

struct ScannerIter<'a, T: std::str::FromStr> {
    phantom: PhantomData<T>,
    scanner: &'a mut Scanner,
}

impl<'a, T: std::str::FromStr> Iterator for ScannerIter<'a, T> {
    type Item = T;

    fn next(&mut self) -> Option<Self::Item> {
        Some(self.scanner.next())
    }
}


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

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

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

// ここまで

fn run() {
    input! {
        n: u64,
    }
    if n <= 2 {
        println!("1");
        return;
    }
    let mut m = 4;
    let mut d = 1;
    while m + 1 < n {
        m = 2 * (m + 1) - d;
        d ^= 1;
    }
    if m == n || m + 1 == n {
        println!("1");
    } else {
        println!("0");
    }
}

fn main() {
    run();
}


use std::str::FromStr;

fn read_str() -> String {
    let mut buffer: String = String::new();
    std::io::stdin().read_line(&mut buffer).expect("Error");
    buffer.trim().to_string()
}

fn read_int<T: FromStr>() -> T{
    read_str().parse::<T>().ok().expect("Error")
}

fn main() {
    let n: u16 = read_int();
    for &divisor in &[4, 7, 47, 74, 444, 447, 474, 477, 744, 747, 777] {
        if divisor > n { break; }
        if n % divisor == 0 {
            println!("YES");
            std::process::exit(0);
        }
    }
    println!("NO");
}


use std::io;

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

    if permute()
        .into_iter()
        .any(|n| s.trim().parse::<usize>().unwrap() % n == 0)
    {
        println!("YES");
    } else {
        println!("NO");
    }
}

fn permute() -> Vec<usize> {
    let arr: [usize; 2] = [4, 7];
    let mut vec = vec![4, 7];

    let mut from = 0;
    let mut to = vec.len();
    'outer: loop {
        for n in arr.iter() {
            for i in from..to {
                let cur = cat(*n, vec[i]);
                if cur < 1000 {
                    vec.push(cat(*n, vec[i]));
                } else {
                    break 'outer;
                }
            }
        }
        from = to;
        to = vec.len();
    }
    vec
}

fn cat(left: usize, right: usize) -> usize {
    let right_f = right as f64;
    let mult_left_by: usize = 10_usize.pow(right_f.log10() as u32 + 1_u32);
    (left * mult_left_by) + right
}


use std::io::stdin;

fn main() {
    let mut arr: [i16; 101] = [0; 101];
    let mut inp = String::with_capacity(500);
    for _ in 1..3 {
        stdin().read_line(&mut inp).unwrap();
    }
    let mut inp = inp.split_whitespace();
    let _ = inp.next().unwrap();
    let mut i: usize;
    for num in inp {
        i = num.parse().unwrap();
        arr[i] += 1;
    }
    let mut max = arr[0];
    i = 1;
    while i < arr.len() {
        if arr[i] > max {
            max = arr[i];
        }
        i += 1;
    }
    println!("{}",max);
}


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

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}

macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn primes(x: i64) -> Vec<i64> {
    let mut x = x;
    let mut ret = vec![];
    for p in 2..x+1 {
        if x % p == 0 {
            ret.push(p);
            while x % p == 0 { x /= p; }
            if x == 1 { break }
        }
        if p * p > x && x > 1 {
            ret.push(x);
            break;
        }
    }
    return ret;
}

fn pow(p: i64, count: i64) -> i64 {
    if count == 0 {
        1
    } else {
        let a = pow((p * p) % M, count / 2) % M;
        if count % 2 == 0 {
            a
        } else {
            (a * p) % M
        }
    }
}

fn main() {
    let mut sc = Scanner::new();
    let x: i64 = sc.cin();
    let n: i64 = sc.cin();
    let ps = primes(x);
    let mut ans = 1;
    // trace!(&ps);
    for &p in ps.iter() {
        let mut count = 0;
        let mut z = n;
        while z >= p {
            count += z / p;
            z /= p;
        }
        // trace!(p, count, pow(p%M,count));
        ans *= pow(p % M, count);
        ans %= M;
    }
    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


use std::io::BufRead;

const MODULO: u128 = 1000000007;

fn delta_greater(a: usize, b: usize, c: usize) -> bool {
    if a > b {
        return (a - b) > c;
    } else {
        return (b - a) > c;
    }
}

fn sqrt_int(x: usize) -> usize {
    if x == 0 {
        return 0;
    }
    let mut value: usize = x + 2;
    let mut value1: usize = x;
    while delta_greater(value, value1, 1) {
        value = value1;
        value1 = (value + (x / value)) / 2;
    }
    value1 = (value1 + (x / value1)) / 2;
    return value1;
}

fn get_power_value(base: u128, power: u128) -> u128 {
    let mut value: u128 = 1;
    let mut z: u128 = base;
    let mut power_of_2: u128 = 1;
    let mut power_tmp: u128 = power;
    for _ in 0..127 {
        if (power_tmp & 1) != 0 {
            value *= z;
            value %= MODULO;
        }

        z *= z;
        z %= MODULO;

        power_of_2 <<= 1;
        power_tmp >>= 1;
        if power_of_2 > power {
            break;
        }
    }
    return value;
}

fn get_prime_divider_power(value: u128, divider: u128) -> u128 {
    let mut power: u128 = 0;
    let mut divider_tmp: u128 = divider;
    while divider_tmp <= value {
        power += value / divider_tmp;
        divider_tmp *= divider;
    }
    return power;
}

fn func_g1_mod(n: u128, p: u128) -> u128 {
    let power: u128 = get_prime_divider_power(n, p);
    return get_power_value(p, power);
}

fn func_f1_mod(x: usize, n: u128) -> u128 {
    let mut value: u128 = 1;

    let mut x_tmp: usize = x;
    for i in 2..(sqrt_int(x) + 1) {
        if (x_tmp % i) == 0 {
            value *= func_g1_mod(n, i as u128);
            value %= MODULO;
        }
        while (x_tmp % i) == 0 {
            x_tmp /= i;
        }
    }
    if x_tmp > 1 {
        value *= func_g1_mod(n, x_tmp as u128);
        value %= MODULO;
    }

    return value;
}

#[cfg(test)]
mod tests {
    use super::{func_f1_mod, get_power_value, sqrt_int};

    #[test]
    fn test_a1() {
        assert_eq!(sqrt_int(0), 0);
        assert_eq!(sqrt_int(1), 1);
        assert_eq!(sqrt_int(2), 1);
        assert_eq!(sqrt_int(3), 1);
        assert_eq!(sqrt_int(4), 2);
        assert_eq!(sqrt_int(5), 2);
        assert_eq!(sqrt_int(6), 2);
        assert_eq!(sqrt_int(7), 2);
        assert_eq!(sqrt_int(8), 2);
        assert_eq!(sqrt_int(9), 3);
        assert_eq!(sqrt_int(10), 3);
    }

    #[test]
    fn test_b1() {
        assert_eq!(get_power_value(0, 1), 0);
        assert_eq!(get_power_value(0, 2), 0);
        assert_eq!(get_power_value(0, 3), 0);
        assert_eq!(get_power_value(1, 0), 1);
        assert_eq!(get_power_value(1, 1), 1);
        assert_eq!(get_power_value(1, 2), 1);
        assert_eq!(get_power_value(1, 3), 1);
        assert_eq!(get_power_value(2, 0), 1);
        assert_eq!(get_power_value(2, 1), 2);
        assert_eq!(get_power_value(2, 2), 4);
        assert_eq!(get_power_value(2, 3), 8);
        assert_eq!(get_power_value(3, 0), 1);
        assert_eq!(get_power_value(3, 1), 3);
        assert_eq!(get_power_value(3, 2), 9);
        assert_eq!(get_power_value(3, 3), 27);
    }

    #[test]
    fn test_c1() {
        assert_eq!(func_f1_mod(10, 2), 2);
    }
    #[test]
    fn test_c2() {
        assert_eq!(func_f1_mod(20190929, 1605), 363165664);
    }
    #[test]
    fn test_c3() {
        assert_eq!(func_f1_mod(947, 987654321987654321), 593574252);
    }
}

fn read_usize_u128_pair(stdin_lock: &mut std::io::StdinLock) -> (usize, u128) {
    let mut line1: String = String::new();
    stdin_lock.read_line(&mut line1).unwrap();
    let mut line1_values = line1.trim().split(" ");
    let value1: usize = line1_values.next().unwrap().parse::<usize>().unwrap();
    let value2: u128 = line1_values.next().unwrap().parse::<u128>().unwrap();
    return (value1, value2);
}

fn main() {
    let stdin: std::io::Stdin = std::io::stdin();
    let mut stdin_lock: std::io::StdinLock = stdin.lock();

    let (x, n): (usize, u128) = read_usize_u128_pair(&mut stdin_lock);

    let func_value: u128 = func_f1_mod(x, n);

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


#![allow(unused_variables)]
#![allow(unused_must_use)]

use std::io::{self, prelude::*};

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    let mut input = Input::new(stdin.lock());
    let mut output = io::BufWriter::new(stdout.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(output, $($format)*).unwrap());
    }

    let n: usize = input.next();
    let mut a: Vec<usize> = input.iter().take(n).collect();
    a.sort();
    let mut cur = Vec::new();
    let mut ans = 0usize;
    for x in a {
        if !cur.iter().any(|&y| x % y == 0) {
            cur.push(x);
            ans += 1;
        }
    }
    puts!("{}\n", ans);
}

struct Input<R> {
    lines: io::Lines<R>,
    cur: String,
    split: std::str::SplitAsciiWhitespace<'static>, //'
}

impl<R: BufRead> Input<R> {
    fn new(reader: R) -> Input<R> {
        use std::mem::transmute;

        let mut lines = reader.lines();
        let cur = lines.next().unwrap().unwrap();
        let split = unsafe { transmute(cur.split_ascii_whitespace()) };
        Input { lines, cur, split }
    }
    fn update(&mut self) {
        use std::mem::transmute;
        self.cur = self.lines.next().unwrap().unwrap();
        unsafe { self.split = transmute(self.cur.split_ascii_whitespace()) };
    }
    fn next<F: std::str::FromStr>(&mut self) -> F {
        loop {
            if let Some(thing) = self.split.next() {
                return thing.parse().ok().unwrap();
            }
            self.update();
        }
    }
    fn iter<I: std::str::FromStr>(&mut self) -> InputIter<R, I> {
        InputIter {
            input: self,
            _phantom: std::marker::PhantomData,
        }
    }
}

struct InputIter<'a, R, I> {
    input: &'a mut Input<R>,
    _phantom: std::marker::PhantomData<I>,
}

impl<'a, R, I> Iterator for InputIter<'a, R, I>
where
    R: BufRead,
    I: std::str::FromStr,
{
    type Item = I;
    fn next(&mut self) -> Option<Self::Item> {
        Some(self.input.next())
    }
}


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

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

fn main() {
    let t = read::<usize>();
    for _ in 0..t {
        let v = read_vec::<usize>();
        let a = read_vec::<usize>()
            .iter()
            .map(|&x| x - 1)
            .collect::<Vec<_>>();
        let (n, k, d) = (v[0], v[1], v[2]);
        let mut count = vec![0; k];
        let mut current_using = HashSet::new();
        for i in 0..d {
            count[a[i]] += 1;
            current_using.insert(a[i]);
        }
        let mut ans = current_using.len();

        for i in d..n {
            count[a[i - d]] -= 1;
            if count[a[i - d]] == 0 {
                current_using.remove(&a[i - d]);
            }
            count[a[i]] += 1;
            current_using.insert(a[i]);
            ans = min(ans, current_using.len());
        }
        println!("{}", ans);
    }
}

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

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


use std::cmp::Ordering;
use std::collections::*;
use std::io::prelude::*;
fn main() {
    let mut buf = String::new();
    let stdin = std::io::stdin();
    let mut handle = stdin.lock();
    handle.read_to_string(&mut buf).unwrap();
    let mut entries = buf.split_whitespace();
    let num_cases: usize = entries.next().unwrap().parse().unwrap();
    for _ in 0..num_cases {
        let n: usize = entries.next().unwrap().parse().unwrap();
        let k: usize = entries.next().unwrap().parse().unwrap();

        let d: usize = entries.next().unwrap().parse().unwrap();
        let mut a = Vec::with_capacity(n);
        for _ in 0..n {
            let ai: usize = entries.next().unwrap().parse().unwrap();
            a.push(ai);
        }
        let res = solve(&mut a, d, k);
        println!("{}", res);
    }
}

fn solve(a: &mut [usize], d: usize, k: usize) -> usize {
    let k = k + 1;
    let mut cache = vec![0; k];
    for i in 0..d {
        cache[a[i]] += 1;
    }
    let mut res = find_min(a, &mut cache, d);
    for i in d..a.len() {
        cache[a[i]] += 1;
        cache[a[i - d]] -= 1;
        let new_res = find_min(a, &mut cache, d);
        if new_res < res {
            res = new_res
        }
    }
    res
    // for i in d..a.len() {
    //     let a_to_inc = a[i];
    //     let a_to_inc_in_index = indexes.binary_search(a_to_inc).unwrap();
    //     if (a_to_inc_in_index > 0) {
    //         let mut next_entry = a_to_inc_in_index - 1;
    //         while (cache[next_entry] == cache[a_to_inc_in_index]) && (next_entry > 0) {
    //             next_entry -= 1;
    //         }
    //         cache[a_to_inc_in_index] += 1;
    //         indexes.swap(a_to_inc_in_index, next_entry);
    //     }

    //     let a_to_dec = a[i - d];
    //     let a_to_dec_in_index = indexes.binary_search(a_to_dec).unwrap();
    //     if (a_to_dec_in_index < a.len() - 1) {
    //         let mut next_entry = a_to_dec_in_index + 1;
    //         while (cache[next_entry] == cache[a_to_dec_in_index]) && (next_entry < a.len() - 1) {
    //             next_entry += 1;
    //         }
    //         cache[a_to_dec_in_index] += 1;
    //         indexes.swap(a_to_dec_in_index, next_entry);
    //     }
    // }
}

fn find_min(a: &mut [usize], cache: &mut [usize], d: usize) -> usize {
    let mut indexes: Vec<usize> = (0..cache.len()).into_iter().collect();
    indexes.sort_by(|i, j| match cache[*i] as isize - cache[*j] as isize {
        x if x < 0 => Ordering::Greater,
        x if x == 0 => Ordering::Equal,
        _ => Ordering::Less,
    });
    let mut score = 0;
    let mut i = 0;
    while score < d {
        score += cache[indexes[i]];
        i += 1;
    }
    i
}

#[cfg(test)]
mod tests {
    use super::*;
    // #[test]
    // fn test1() {
    //     assert_eq!(solve(&mut [1, 2, 1, 2, 1], 2, 2), 2);
    // }

    #[test]
    fn test2() {
        assert_eq!(solve(&mut [10, 8, 6, 4], 4, 10), 4);
    }
}


use std::io;
fn main() {
    let mut buf = String::new();
    // pass nubmer of chars
    io::stdin().read_line(&mut buf).unwrap();
    io::stdin().read_line(&mut buf).unwrap();
    let v: u32 = buf.split_whitespace()
               .map(|word| {
                   word.chars()
                       .map(|c| if c.is_uppercase() {1} else {0})
                       .sum()
               })
               .max().unwrap();
    println!("{}", v);
}


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

    let (a, category) = match x % 4 {
        0 => (1, 'A'),
        1 => (0, 'A'),
        2 => (1, 'B'),
        3 => (2, 'A'),
        _ => unreachable!()
    };

    println!("{} {}", a, category);
}


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

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

    let x = input.u();
    let a = [3,0,2,1];
    let mut soli = 0;
    let mut sola = a[x % 4];
    for i in 1..=2 {
        let x = x + i;
        if m!(<,sola,a[x % 4]) {
            soli = i;
        }
    }
    println!("{} {}", soli, (sola + b'A') as char);
}


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

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

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

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

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

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

fn f(i: usize, k: u64, ll: &Vec<u64>) -> char {
    let mut i = i;
    let mut k = k;

    loop {
        if i == 0 {
            let f0 = "What are you doing at the end of the world? Are you busy? Will you save us?";
            return if f0.len() as u64 > k {
                f0.chars().nth(k as usize).unwrap()
            } else {
                '.'
            };
        } else {
            if k < 34 {
                let s1 = "What are you doing while sending \"";
                return s1.chars().nth(k as usize).unwrap();
            } else if k < 34 + ll[i - 1] {
                // f(i - 1, k - 34, ll)
                i -= 1;
                k -= 34;
            } else if k < 34 + ll[i - 1] + 32 {
                let s2 = "\"? Are you busy? Will you send \"";
                return s2.chars().nth((k - 34 - ll[i - 1]) as usize).unwrap();
            } else if k < 34 + ll[i - 1] + 32 + ll[i - 1] {
                // f(i - 1, k - 34 - ll[i - 1] - 32, ll)
                k -= 34 + ll[i - 1] + 32;
                i -= 1;
            } else if k < 34 + ll[i - 1] + 32 + ll[i - 1] + 2 {
                let s3 = "\"?";
                return s3.chars()
                    .nth((k - 34 - ll[i - 1] - 32 - ll[i - 1]) as usize)
                    .unwrap();
            } else {
                return '.';
            }
        }
    }

}

fn main() {
    let k_max: u64 = 1000000000000000000;

    let mut ll = Vec::new();
    ll.push(75u64);
    let mut n = 0;
    for i in 1..100001 {
        n = ll[i - 1] * 2 + 68;
        ll.push(n);
        if n > k_max {
            break;
        }
    }
    while ll.len() < 100001 {
        ll.push(n);
    }

    let mut ans = Vec::new();

    let n = get!(usize);

    for _ in 0..n {
        let (n, k) = get!(usize, u64);
        ans.push(f(n, k - 1, &ll));
    }

    println!("{}", ans.into_iter().collect::<String>());
}


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

    if n % 2 == 0 {
        println!("{:?}", n / 2);
    } else {
        println!("{:?}", n / 2 - n);
    }
}


use std::mem;
use std::io;
use std::string;
use std::cmp::*;
use std::collections::*;

fn load() -> Vec<i64> {
    let mut line = String::new();
    io::stdin().read_line(&mut line).expect("Failed to read line");
    let vec: Vec<&str> = line.split(" ").collect();
    let mut data : Vec<i64> = Vec::new();
    for i in vec {
        let el : i64 = i.trim().parse().unwrap();
        data.push(el);
    }
    data
}

fn main() {
    let s = load()[0];
    println!("{}", ((s+1)/2)*(1-2*(s%2)));
}
// min, max
// HashSet, insert, contains
// Vec, len, sort


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

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

fn main() {
    let n: usize = get();
    let m: usize = get();
    let k: usize = get();
    println!("{} {} {}",
             (k - 1) / (2 * m) + 1,
             ((k - 1) % (2 * m)) / 2 + 1,
             if k % 2 == 1 { "L" } else { "R" });
}


use std::io;

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

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

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


use std::io;

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

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

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


// https://codeforces.com/problemset/problem/520/B
use std::io;
use std::collections::VecDeque;

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

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

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

    let n = words[0];
    let m = words[1];

    let mut distance = [1<<30;1000005];
    distance[n as usize] = 0;

    let mut q = VecDeque::<i64>::new();
    q.push_back(n);

    while !q.is_empty() {
        let u = q.pop_front().unwrap();
        let v = (2*u) as usize;
        let x = (u-1) as usize;

        if distance[v] == 1<<30 && (v as i64) < 2*m {
            distance[v] = distance[u as usize] + 1;
            q.push_back(v as i64);
        }

        if distance[x] == 1<<30 && x > 0 {
            distance[x] = distance[u as usize] + 1;
            q.push_back(u-1);
        }
    }
    println!("{}", distance[m as usize]);
}


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

    use std::collections::VecDeque;
    let a: usize = input.p();
    let b: usize = input.p();
    let mut dist = vec![-1; 20000];
    {
        let mut q = VecDeque::new();
        q.push_back(a as i32);
        dist[a] = 0;
        while let Some(p) = q.pop_front() {
            let d = dist[p as usize] + 1;
            let mut push = |q: &mut VecDeque<_>, p: i32, d: i32| {
                if let Some(x @ &mut -1) = dist.get_mut(p as usize) {
                    *x = d;
                    q.push_back(p);
                }
            };
            push(&mut q, 2 * p, d);
            push(&mut q, p - 1, d);
        }
    }
    println!("{}", dist[b]);
}


use std::io::stdin;
fn main() {
    let (mut h, m) = parse();
    let e = h;
    while reverse_number(h) > 59 || (reverse_number(h) <= m && h == e) {
        h += 1;
    }

    if h >= 24 {
        println!("00:00")
    } else {
        print_it(h, reverse_number(h));
    }
}

fn parse() -> (usize, usize) {
    let mut entry = String::new();
    let mut hours = String::new();
    let mut minutes = String::new();
    let mut b = false;
    stdin().read_line(&mut entry).unwrap();

    for i in entry.trim().chars() {
        if i == ':' {
            b = true;
        } else if b {
            minutes.push(i);
        } else {
            hours.push(i);
        };
    }
    (hours.parse().unwrap(), minutes.parse().unwrap())
}

fn reverse_number(val: usize) -> usize {
    ((val % 10) * 10) + ((val - (val % 10)) / 10)
}

fn print_it(a: usize, b: usize) {
    let hours: String;
    let minutes: String;

    if a < 10 {
        hours = format!("0{}", a);
    } else {
        hours = format!("{}", a);
    };
    if b < 10 {
        minutes = format!("0{}", b);
    } else {
        minutes = format!("{}", b);
    };
    println!("{}:{}", hours, minutes);
}


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

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

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

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

fn _main() {
    let mut scan = Scan::new();
    let n: usize = scan.next();
    let mut m: usize = scan.next();
    let circle = n * (n + 1) / 2;
    m %= circle;
    for i in 1..n {
        if i <= m {
            m -= i;
        } else {
            break;
        }
    }
    println!("{}", m);
}

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


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

fn readstring() -> String {
    read_string_from_buffer(&io::stdin())
}

fn readint() -> i32 {
    read_int_from_buffer(&io::stdin())
}

fn read_string_from_buffer(buf: &io::Stdin) -> String {
    let mut input_text = String::new();
    buf.read_line(&mut input_text)
        .expect("failed to read from stdin");
    input_text.trim_right().to_string()
}

fn read_int_from_buffer(buf: &io::Stdin) -> i32 {
    read_string_from_buffer(buf)
        .parse::<i32>()
        .expect("couldn't parse data to an integer")
}

fn read_line_of_integers() -> Vec<i32> {
    readstring()
        .split_whitespace()
        .map(|x| x.parse::<i32>().unwrap())
        .collect()
}

fn read_line_of_longs() -> Vec<i64> {
    readstring()
        .split_whitespace()
        .map(|x| x.parse::<i64>().unwrap())
        .collect()
}

fn h(par: &mut Vec<i32>, d: &mut Vec<i32>, i: i32) -> i32 {
    if i == 1 {
        return -1;
    }
    let p = par[i as usize - 2];
    if d[i as usize - 2] == 0 {
        d[i as usize - 2] = h(par, d, p) + 1
    }
    d[i as usize - 2]
}

fn main() {
    let v = read_line_of_integers();
    let (a, b) = (cmp::min(v[0], v[1]), cmp::max(v[0], v[1]));
    if a + v[2] <= b {
        println!("{}", 2 * (a + v[2]));
    } else {
        println!("{}", 2 * b + ((v[2] - (b - a)) / 2) * 2);
    }
}


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

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

fn string_to_integer_iterator(string: String) -> Vec<i32> {
  string.split(' ')
    .map(|s| s.trim())
    .filter(|s| !s.is_empty())
    .map(|s| s.parse().unwrap()).collect()
}

fn main() {
  let vector = string_to_integer_iterator(read_line());
  let min = cmp::min(vector[0], vector[1]);
  let max = cmp::max(vector[0], vector[1]);
  let poten_max = min + vector[2];

  let result = (poten_max + cmp::min(poten_max, max)) >> 1 << 1;

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


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

    let _n = input.next::<i32>();
    let s = input.next::<String>();

    let mut count = 0;

    for xxx in s.split(|c| c != 'x') {
        if xxx.len() > 2 {
            count += xxx.len() - 2;
        }
    }

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

#[allow(unused)]
pub mod io {

    const BUFFER_SIZE: usize = 8192;

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

    type AsciiStr = Vec<u8>;

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

    impl Input {

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

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

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

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

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

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

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

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


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

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

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($format:expr) => (write!(out,$format).unwrap());
        ($format:expr, $($args:expr),+) => (write!(out,$format,$($args),*).unwrap())
    }
    let n: usize = get();
    let s: Vec<_> = get_word().chars().collect();
    let mut tot = 0;
    let mut cur = 0;
    for i in 0 .. n + 1 {
        if i == n || s[i] != 'x' {
            tot += max(0, cur - 2);
            cur = 0;
        } else {
            cur += 1;
        }
    }
    puts!("{}\n", tot);
}

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


//! http://codeforces.com/contest/266/problem/A

fn main() {
  use std::io;
  let mut buf = String::new();
  io::stdin().read_line(&mut buf).unwrap();
  buf.clear();
  io::stdin().read_line(&mut buf).unwrap();
  let rocks = buf.trim().as_bytes();
  let mut last = rocks[0];
  let mut remove = 0;
  for &rock in &rocks[1..] {
    if rock == last { remove += 1; }
    else { last = rock; }
  }
  println!("{}", remove);
}


/*
    Implementation - https://codeforces.com/problemset/problem/1030/A
    Completed: 2/7/20 21:20
*/

use std::io;

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

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

    let mut byte: &u8 = &0;
    let mut out_value = 0;

    for letter in last_input.as_bytes() {
        if letter == byte {
            out_value += 1;
        }
        byte = letter;
    }

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


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

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

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

// 長さ3までしかなさそう
// 1~3までをそれぞれ数えられればいい
// 長さ1
// gcd > 1 なペアの数
// 長さ2
// gcd = 1 で最小素因数の積がN 以下なもの
// 長さ3
// 最小素因数の積がNを超えるやつ
// どう数える
// 1
// 包除原理でいけるはず
// 2, 3
// 最小素因数で分類すればなんとかなる?
// 2 * p > N な素数は削除しておく
// 互いに素の条件を扱えてなかった...
// 最小素因数の積がNを超えてるなら互いに素になる
// 超えないなら？
// 事前にメモっておけばいい感じか?
// ややこしい
// 最小素因数が異なるかつ積がN以下かつ互いに素じゃないペアの数

fn run() {
    input! {
        n: usize,
    }
    let mut factor = (0..=n).collect::<Vec<_>>();
    let mut mobius = vec![1i8; n + 1];
    let mut prime = vec![];
    let mut cnt = vec![];
    for i in 2..=n {
        if i == factor[i] {
            prime.push(i);
            let mut c = 0;
            for j in 1..=(n / i) {
                let p = &mut factor[j * i];
                if i <= *p {
                    *p = i;
                    c += 1;
                }
                mobius[j * i] *= -1;
            }
            cnt.push(c);
            let pp = i.saturating_mul(i);
            for j in 1..=(n / pp) {
                mobius[j * pp] = 0;
            }
        }
    }
    while prime.last().map_or(false, |p| 2 * *p > n) {
        prime.pop();
        cnt.pop();
    }
    let mut all = cnt.iter().sum::<i64>();
    all = all * (all - 1) / 2;
    let mut ans = 0i64;
    for (i, mobius) in mobius.iter().enumerate().skip(2) {
        let s = *mobius as i64;
        if s != 0 {
            let cnt = (n / i) as i64;
            all += s * cnt * (cnt - 1) / 2;
            ans -= cnt * (cnt - 1) / 2 * s;
        }
    }
    let mut sum = 0;
    let mut x = 0;
    let mut two = 0;
    for (i, (c, p)) in cnt.iter().zip(prime.iter()).enumerate() {
        while x < i && *p * prime[x] <= n {
            two += cnt[x];
            x += 1;
        }
        while x > 0 && *p * prime[x - 1] > n {
            x -= 1;
            two -= cnt[x];
        }
        ans += (sum - two) * *c * 3;
        all -= (sum - two) * *c;
        sum += *c;
    }
    ans += 2 * all;
    println!("{}", ans);
}

fn main() {
    run();
}


struct Scanner<'a, T: std::io::Read> {
    reader: &'a mut T,
    buffer: [u8; 4096],
    position: usize,
    size: usize
}

impl<'a, T: std::io::Read> Scanner<'a, T> {
    const SPACES: [i32; 4] = [
        ' ' as i32,
        '\n' as i32,
        '\t' as i32,
        '\r' as i32];
    const ZERO: i32 = '0' as i32;
    const NINE: i32 = '9' as i32;
    const NEG: i32 = '-' as i32;
    const EOF: i32 = -1;

    fn new(reader: &'a mut T) -> Scanner<'a, T> {
        Scanner {
            reader,
            buffer: [0; 4096],
            position: 0,
            size: 0
        }
    }

    fn read_block(&mut self) {
        self.size = self.reader.read(&mut self.buffer).unwrap();
        self.position = 0;
    }

    fn read_char(&mut self) -> i32 {
        if self.position >= self.size {
            self.read_block();
            if self.position >= self.size {
                return Scanner::<T>::EOF;
            }
        }

        let ch = self.buffer[self.position];
        self.position += 1;

        ch as i32
    }

    fn read_char_skip_ws(&mut self) -> i32 {
        let mut ch = self.read_char();
        while ch != Scanner::<T>::EOF && Scanner::<T>::SPACES.contains(&ch) {
            ch = self.read_char();
        }

        if ch == Scanner::<T>::EOF {
            return Scanner::<T>::EOF;
        }

        return ch;
    }

    fn read_int(&mut self) -> Option<i32> {
        let mut ch = self.read_char_skip_ws();
        if ch == Scanner::<T>::EOF {
            return None;
        }

        let mut negative = false;
        if ch == Scanner::<T>::NEG {
            negative = true;
            ch = self.read_char();
        }

        let mut result = 0;
        while ch != Scanner::<T>::EOF && ch >= Scanner::<T>::ZERO && ch <= Scanner::<T>::NINE {
            result = result * 10 + ch - Scanner::<T>::ZERO;
            ch = self.read_char();
        }

        Some(if negative {
            -result
        } else {
            result
        })
    }

    fn read_str(&mut self, s: &mut String) -> bool {
        let mut ch = self.read_char_skip_ws();
        if ch == Scanner::<T>::EOF {
            return false;
        }

        while !Scanner::<T>::SPACES.contains(&ch) {
            s.push(std::char::from_u32(ch as u32).unwrap());
            ch = self.read_char();
        }

        return true;
    }
}

fn main() {
    let mut stdin = std::io::stdin();
    let mut reader = Scanner::new(&mut stdin);

    let n = reader.read_int().unwrap() as i64;
    let k = reader.read_int().unwrap() as i64;

    let y = ((-3f64 + ((9 + 8 * (n + k)) as f64).sqrt()) / 2f64) as i64;
    let x = n - y;

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


//! http://codeforces.com/contest/405/problem/A

fn main() {
  use std::io;
  let mut buf = String::new();
  let mut rows: Vec<u32> = Vec::with_capacity(100);
  let cols: Vec<u32>;
  io::stdin().read_line(&mut buf).unwrap();
  let n = buf.trim().parse::<u32>().unwrap();
  buf.clear();
  io::stdin().read_line(&mut buf).unwrap();
  cols = buf.split(" ")
    .map(|str| str.trim().parse::<u32>().unwrap())
    .collect();
  for i in 1..101 {
    let mut row = 0;
    for j in 0..(n as usize) {
      if cols[j] >= i {
        row += 1;
      }
    }
    rows.push(row);
  }
  let mut res: Vec<u32> = Vec::with_capacity(n as usize);
  for i in 1..(n as usize + 1) {
    let mut col = 0;
    for j in 0..100 {
      if rows[j] >= i as u32 {
        col += 1;
      }
    }
    res.push(col);
  }
  res.reverse();
  for i in 0..n as usize {
    if i != 0 { print!(" "); }
    print!("{}", res[i]);
  }
  println!();
}


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

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

    let _first = iterator.next().unwrap().unwrap();
    let second = iterator.next().unwrap().unwrap();

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

    numbers.sort();

    let strings: Vec<String> = numbers
        .iter()
        .map(|s| s.to_string())
        .collect();
    println!("{}", strings.join(" "));
}


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

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

fn main() {
    let v: Vec<u8> = get_word().bytes().collect();
    let mut ok = true;
    let mut used = [false; 26];
    let n = v.len();
    for i in 0 .. n {
        let idx = (v[i] - b'a') as usize;
        for j in 0 .. idx {
            if !used[j] {
                ok = false;
            }
        }
        used[idx] = true;
    }
    println!("{}", if ok { "YES" } else { "NO" });
}