// ternary operation
#[allow(unused_macros)]
macro_rules! _if {
  ($_test:expr, $_then:expr, $_else:expr) => {
    if $_test { $_then } else { $_else }
  };
  ($_test:expr, $_pat:pat, $_then:expr, $_else:expr) => {
    match $_test {
      $_pat => $_then,
      _     => $_else
    }
  };
}

use std::io::{ stdin, stdout, Write };
use my::WriteWith;

#[inline(always)]
fn abc109_c() {
  let stdin  = stdin();
  let stdout = stdout();
  let (mut scanner, mut writer) = my::rw(12, stdin.lock(), stdout.lock());
  let mut itoa = my::ItoA::with_capacity(10);

  let n = scanner.uint_until::<usize>(my::SP);
  let x = scanner.int_until::<i32>(my::LF);

  let ans = scanner.fold_int_to_end(n, my::SP, 0, | gcd, num |
    my::gcd((num - x).abs(), gcd)
  );

  // let mut ans = 0;
  // for _ in 0..n - 1 {
  //   ans = my::gcd((scanner.int_until::<i32>(my::SP) - x).abs(), ans);
  // }
  // ans = my::gcd((scanner.int_until::<i32>(my::LF) - x).abs(), ans);

  writer.write_with(itoa.from_i32(ans), b"\n").unwrap();
  writer.flush().unwrap();
}

fn main() {
  abc109_c();
}

//------------------------------------------------------------------------
mod my {

  #[derive(Debug)]
  pub struct Scanner<R> {
    reader: R,
    buf   : Vec<u8>,
  }

  impl<R> Scanner<R>
    where R: BufRead
  {
    #[allow(dead_code)]
    #[inline(always)]
    pub fn with_capacity(cap: usize, reader: R) -> Self {
      Scanner {
        reader: reader,
        buf   : Vec::with_capacity(cap),
      }
    }

    #[allow(dead_code)]
    #[inline(always)]
    fn read_until(&mut self, delim: u8) {
      self.buf.clear();
      let mut len = self.reader
                        .read_until(delim, &mut self.buf).unwrap();
      if len == 0 {
        return;
      }

      len -= 1;
      if self.buf[len] == delim {
        self.buf.truncate(len);
      }
    }

    #[allow(dead_code)]
    #[inline(always)]
    pub fn fold_int_to_end<T, F>(&mut self, n: usize, delim: u8, mut init: T, mut func: F) -> T
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Neg<Output=T> +
               Default +
               From<u8> +
               Debug,
            F: ::std::ops::FnMut(T, T) -> T
    {
      for _ in 0..n - 1 {
        init = func(init, self.int_until(delim));
      }
      func(init, self.int_until(LF))
    }

    #[allow(dead_code)]
    #[inline(always)]
    pub fn uint_until<T>(&mut self, delim: u8) -> T
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Default +
               From<u8> +
               Debug
    {
      self.read_until(delim);
      atoui(&self.buf)
    }

    #[allow(dead_code)]
    #[inline(always)]
    pub fn int_until<T>(&mut self, delim: u8) -> T
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Neg<Output=T> +
               Default +
               From<u8> +
               Debug
    {
      self.read_until(delim);
      atoi(&self.buf)
    }
  } // impl<R> Scanner<R>

  #[allow(dead_code)]
  #[inline(always)]
  pub fn rw<R, W>(cap: usize, r: R, w: W) -> (Scanner<BufReader<R>>, BufWriter<W>)
    where R: BufRead,
          W: io::Write
  {
    (
      Scanner::with_capacity(cap, BufReader::new(r)),
      BufWriter::new(w)
    )
  }

  #[allow(dead_code)]
  #[inline(always)]
  pub fn atoui<T>(s: &[u8]) -> T
    where T: Add<Output=T> +
             Sub<Output=T> +
             Mul<Output=T> +
             Default +
             From<u8> +
             Debug
  {
    let mut n = T::default();
    if s.len() == 0 {
      return n;
    }

    let mut i = 0;
    if s[i] == PLUS_SIGN {
      i += 1;
    }

    for b in &s[i..] {
      n = (n * T::from(10)) + T::from(b - ASCII_0);
    }

    n
  }

  #[allow(dead_code)]
  #[inline(always)]
  pub fn atoi<T>(s: &[u8]) -> T
    where T: Add<Output=T> +
             Sub<Output=T> +
             Mul<Output=T> +
             Neg<Output=T> +
             Default +
             From<u8> +
             Debug
  {
    let mut n = T::default();
    if s.len() == 0 {
      return n;
    }

    let mut i = 0;
    let mut negative = false;
    if s[i] == MINUS_SIGN {
      negative = true;
      i += 1;
    } else if s[i] == PLUS_SIGN {
      i += 1;
    }

    for b in &s[i..] {
      n = (n * T::from(10)) + T::from(b - ASCII_0);
    }

    _if!(negative,
      n.neg(),
      n)
  }

  use std::hash::Hasher;
  use std::hash::BuildHasher;

  pub struct MyHasher(u64);

  impl Default for MyHasher {

    fn default() -> Self {
      MyHasher(0x00)
    }
  }

  impl BuildHasher for MyHasher {
    type Hasher = MyHasher;

    fn build_hasher(&self) -> Self::Hasher {
      Self::Hasher::default()
    }
  }

  impl Hasher for MyHasher {

    fn finish(&self) -> u64 {
      self.0
    }

    fn write(&mut self, bytes: &[u8]) {
      self.0 = 0;
      for i in 0..bytes.len() {
        self.0 ^= (bytes[i] as u64) << (8 * (i % 8));
      }
    }
  }

  //----------------------------------------------------------------------
  use std::io::{ self, BufRead, BufReader, Write, BufWriter };
  use std::fmt::Debug;
  use std::ops::{ Add, Sub, Mul, Div, Rem, Neg };
//  use std::str::{ self, FromStr };
  use std::mem;

  const PLUS_SIGN : u8 = b'+';
  const MINUS_SIGN: u8 = b'-';
  const ASCII_0   : u8 = b'0';
  const ASCII_9   : u8 = b'9';

  pub const SP    : u8 = b' ';
  pub const LF    : u8 = b'\n';

  //----------------------------------------------------------------------
  #[allow(dead_code)]

  pub fn floor<T>(dividend: T, divisor: T) -> T
    where T: Add<Output=T> +
             Sub<Output=T> +
             Div<Output=T> +
             Copy +
             Default +
             Debug
  {
    dividend / divisor
  }

  #[allow(dead_code)]

  pub fn ceil<T>(dividend: T, divisor: T) -> T
    where T: Add<Output=T> +
             Sub<Output=T> +
             Div<Output=T> +
             Copy +
             Default +
             From<u8> +
             Debug
  {
    (dividend + divisor - T::from(1)) / divisor
  }

  //----------------------------------------------------------------------
  #[allow(dead_code)]

  pub fn rotate_right<T>(ary: &mut [T])
    where T: Copy +
             Debug
  {
    if ary.len() <= 1 {
      return;
    }

    let len = ary.len() - 1;
    let tmp = ary[len];
    for i in 0..len {
      ary[len - i] = ary[len - i - 1];
    }
    ary[0] = tmp;
  }

  #[allow(dead_code)]

  pub fn rotate_left<T>(ary: &mut [T])
    where T: Copy +
             Debug
  {
    if ary.len() <= 1 {
      return;
    }

    let len = ary.len() - 1;
    let tmp = ary[0];
    for i in 0..len {
      ary[i] = ary[i + 1];
    }
    ary[len] = tmp;
  }

  //----------------------------------------------------------------------
  #[allow(dead_code)]
  #[inline(always)]
  pub fn gcd<T>(x: T, y: T) -> T
    where T: Rem<Output=T> +
             Default +
             PartialEq +
             Copy +
             Debug
  {
    _if!(y == T::default(),
      x,
      gcd(y, x % y))
  }

  //----------------------------------------------------------------------
  #[allow(dead_code)]

  pub fn intersection<T>(mut x: (T, T), mut y: (T, T)) -> Option<(T, T)>
    where T: PartialOrd +
             Copy +
             Debug
  {
    if x.0 > x.1 {
      mem::swap(&mut x.0, &mut x.1);
    }
    if y.0 > y.1 {
      mem::swap(&mut y.0, &mut y.1);
    }

    if x.0 >= y.1 || x.1 <= y.0 {
      return None;
    }

    if x.0 < y.0 {
      x.0 = y.0;
    }
    if x.1 > y.1 {
      x.1 = y.1;
    }

    Some(x)
  }

  //----------------------------------------------------------------------
  #[allow(dead_code)]

  pub fn is_ascii_digit(b: u8) -> bool {
    _if!(b >= ASCII_0 && b <= ASCII_9,
      true,
      false)
  }

  #[allow(dead_code)]

  pub fn is_ascii_uppercase(b: u8) -> bool {
    _if!(b >= b'A' && b <= b'Z',
      true,
      false)
  }

  #[allow(dead_code)]

  pub fn is_ascii_lowercase(b: u8) -> bool {
    _if!(b >= b'a' && b <= b'z',
      true,
      false)
  }

  #[allow(dead_code)]

  pub fn is_ascii_alphabetic(b: u8) -> bool {
    _if!(is_ascii_uppercase(b) || is_ascii_lowercase(b),
      true,
      false)
  }

  #[allow(dead_code)]

  pub fn to_ascii_lowercase(b: u8) -> u8 {
    _if!(is_ascii_uppercase(b),
      b + 0x20,
      b)
  }

  #[allow(dead_code)]

  pub fn to_ascii_uppercase(b: u8) -> u8 {
    _if!(is_ascii_lowercase(b),
      b - 0x20,
      b)
  }

  //----------------------------------------------------------------------
  pub trait WriteWith {
    fn write_with(&mut self, buf: &[u8], delim: &[u8]) -> io::Result<usize>;
  }

  impl<W> WriteWith for BufWriter<W>
    where W: io::Write
  {
    #[allow(dead_code)]
    #[inline(always)]
    fn write_with(&mut self, buf: &[u8], delim: &[u8]) -> io::Result<usize>
    {
      Ok(self.write(buf)? + self.write(delim)?)
    }
  } // impl<W> WriteWith for BufWriter<W>

  //----------------------------------------------------------------------
  macro_rules! pub_fn_ItoA_from_ty {
    (uint, $($name:ident => $_type:ty),*) => {$(
      #[allow(dead_code)]
      #[inline(always)]
      pub fn $name(&mut self, mut n: $_type) -> &[u8] {
        self.buf.clear();
        if n == 0 {
          self.buf.push(ASCII_0);
          return self.buf.as_slice();
        }

        while n > 0 {
          self.buf.push((n % 10) as u8 + ASCII_0);
          n /= 10;
        }
        self.buf.reverse();
        self.buf.as_slice()
      }
    )*};

    (int, $($name:ident => $_type:ty),*) => {$(
      #[allow(dead_code)]
      #[inline(always)]
      pub fn $name(&mut self, mut n: $_type) -> &[u8] {
        self.buf.clear();
        if n == 0 {
          self.buf.push(ASCII_0);
          return self.buf.as_slice();
        }

        let mut negative = false;
        if n.is_negative() {
          negative = true;
          n = n.abs();
        }

        while n > 0 {
          self.buf.push((n % 10) as u8 + ASCII_0);
          n /= 10;
        }
        if negative {
          self.buf.push(MINUS_SIGN);
        }
        self.buf.reverse();
        self.buf.as_slice()
      }
    )*};
  }

  #[derive(Debug)]
  pub struct ItoA {
    buf: Vec<u8>,
  }

  impl ItoA {
    #[allow(dead_code)]
    #[inline(always)]
    pub fn new() -> Self {
      ItoA {
        buf: Vec::new(),
      }
    }

    #[allow(dead_code)]
    #[inline(always)]
    pub fn with_capacity(cap: usize) -> Self {
      ItoA {
        buf: Vec::with_capacity(cap),
      }
    }

    pub_fn_ItoA_from_ty!(
      uint,
      from_usize => usize,
      from_u8    => u8,
      from_u16   => u16,
      from_u32   => u32,
      from_u64   => u64
    );

    pub_fn_ItoA_from_ty!(
      int,
      from_isize => isize,
      from_i8    => i8,
      from_i16   => i16,
      from_i32   => i32,
      from_i64   => i64
    );
  } // impl ItoA

/*
  //----------------------------------------------------------------------
  #[allow(dead_code)]
  #[inline(always)]
  pub fn rw<R, W>(cap: usize, r: R, w: W) -> (Scanner<BufReader<R>>, BufWriter<W>)
    where R: BufRead,
          W: io::Write
  {
    (
      Scanner::with_capacity(cap, BufReader::new(r)),
      BufWriter::new(w)
    )
  }

  #[allow(dead_code)]

  pub fn r<R>(cap: usize, r: R) -> Scanner<BufReader<R>>
    where R: BufRead
  {
    Scanner::with_capacity(cap, BufReader::new(r))
  }

  #[allow(dead_code)]

  pub fn w<W>(w: W) -> BufWriter<W>
    where W: io::Write
  {
    BufWriter::new(w)
  }
*/

/*
  //----------------------------------------------------------------------
  #[derive(Debug)]
  pub struct Scanner<R> {
    reader: R,
    buf   : Vec<u8>,
  }

  impl<R> Scanner<R>
    where R: BufRead
  {
    #[allow(dead_code)]

    pub fn new(reader: R) -> Self {
      Scanner {
        reader: reader,
        buf   : Vec::new(),
      }
    }

    #[allow(dead_code)]
    #[inline(always)]
    pub fn with_capacity(cap: usize, reader: R) -> Self {
      Scanner {
        reader: reader,
        buf   : Vec::with_capacity(cap),
      }
    }

    //--------------------------------------------------------------------

    #[allow(dead_code)]
    #[inline(always)]
    pub fn into_inner(self) -> R {
      self.reader
    }

    #[inline(always)]
    fn read_until(&mut self, delim: u8) {
      self.buf.clear();
      let mut len = self.reader
                      .read_until(delim, &mut self.buf)
                      .expect(&format!("read_until(): {}", line!()));
      if len == 0 {
        return;
      }

      len -= 1;
      if self.buf[len] == delim {
        self.buf.truncate(len);
      }
    }

    #[allow(dead_code)]

    fn read_until_delim(&mut self) {
      let mut buf: [u8; 1] = [0; 1];

      self.buf.clear();
      while self.reader
              .read(&mut buf)
              .expect(&format!("read(): {}", line!())) != 0 &&
            buf[0] != SP &&
            buf[0] != LF
      {
        self.buf.push(buf[0]);
      }
    }

    //--------------------------------------------------------------------
    // s -> n
    #[allow(dead_code)]

    pub fn parse_until<T>(&mut self, delim: u8) -> T
      where T: FromStr + Debug,
            <T as FromStr>::Err: Debug
    {
      self.read_until(delim);
      unsafe { str::from_utf8_unchecked(&self.buf) }
        .parse()
        .unwrap()
    }

    //--------------------------------------------------------------------
    #[allow(dead_code)]
    #[inline(always)]
    pub fn byte_until(&mut self, delim: u8) -> Vec<u8> {
      self.read_until(delim);
      self.buf.clone()
    }

    #[allow(dead_code)]
    #[inline(always)]
    pub fn string_until(&mut self, delim: u8) -> String {
      unsafe { String::from_utf8_unchecked(self.byte_until(delim)) }
    }

    //--------------------------------------------------------------------
    // s -> n
    #[allow(dead_code)]
    #[inline(always)]
    pub fn uint_until<T>(&mut self, delim: u8) -> T
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Default +
               From<u8> +
               Debug
    {
      self.read_until(delim);
      atoui(&self.buf)
    }

    // s -> n
    #[allow(dead_code)]
    #[inline(always)]
    pub fn int_until<T>(&mut self, delim: u8) -> T
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Neg<Output=T> +
               Default +
               From<u8> +
               Debug
    {
      self.read_until(delim);
      atoi(&self.buf)
    }

    // s -> n
    #[allow(dead_code)]

    pub fn int_1<T>(&mut self) -> T
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Neg<Output=T> +
               Default +
               From<u8> +
               Debug
    {
      self.read_until_delim();
      let mut n = T::default();
      if self.buf.len() == 0 {
        return n;
      }

      let mut i = 0;
      let mut negative = false;
      if self.buf[i] == MINUS_SIGN {
        negative = true;
        i += 1;
      } else if self.buf[i] == PLUS_SIGN {
        i += 1;
      }

      for b in &self.buf[i..] {
        n = (n * T::from(10)) + T::from(b - ASCII_0);
      }

      _if!(negative,
        n.neg(),
        n)
    }

    // s -> n
    #[allow(dead_code)]

    pub fn int<T>(&mut self) -> T
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Neg<Output=T> +
               Default +
               From<u8> +
               Debug
    {
      let mut buf: [u8; 1] = [0; 1];

      if self.reader
             .read(&mut buf)
             .expect(&format!("read(): {}", line!())) == 0 ||
         buf[0] == SP ||
         buf[0] == LF
      {
        panic!("int_until_x(): {}", line!());
      }

      let mut n = T::default();

      let mut negative = false;
      if buf[0] == MINUS_SIGN {
        negative = true;
      } else if buf[0] == PLUS_SIGN {
        // do nothing
      } else {
        n = (n * T::from(10)) + T::from(buf[0] - ASCII_0);
      }

      loop {
        self.reader
            .read(&mut buf)
            .expect(&format!("read(): {}", line!()));
        if buf[0] == SP || buf[0] == LF {
          break;
        } else {
          n = (n * T::from(10)) + T::from(buf[0] - ASCII_0);
        }
      }

      // while self.reader
      //         .read(&mut buf)
      //         .expect(&format!("read(): {}", line!())) != 0 &&
      //       buf[0] != SP &&
      //       buf[0] != LF
      // {
      //   n = (n * T::from(10)) + T::from(buf[0] - ASCII_0);
      // }

      _if!(negative,
        n.neg(),
        n)
    }

    //--------------------------------------------------------------------
    #[allow(dead_code)]

    pub fn uint_to_end<T, F>(&mut self, n: usize, delim: u8, mut init: T, mut func: F) -> T
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Default +
               From<u8> +
               Debug,
            F: ::std::ops::FnMut(T, T) -> T
    {
      for _ in 0..n - 1 {
        init = func(init, self.uint_until(delim));
      }
      func(init, self.uint_until(LF))
    }

    #[allow(dead_code)]

    pub fn int_to_end<T, F>(&mut self, n: usize, delim: u8, mut init: T, mut func: F) -> T
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Neg<Output=T> +
               Default +
               From<u8> +
               Debug,
            F: ::std::ops::FnMut(T, T) -> T
    {
      for _ in 0..n - 1 {
        init = func(init, self.int_until(delim));
      }
      func(init, self.int_until(LF))
    }

    #[allow(dead_code)]

    pub fn uint_n<T, F>(&mut self, n: usize, delim: u8, mut func: F)
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Default +
               From<u8> +
               Debug,
            F: ::std::ops::FnMut(T)
    {
      for _ in 0..n {
        func(self.uint_until(delim));
      }
    }

    #[allow(dead_code)]

    pub fn int_n<T, F>(&mut self, n: usize, delim: u8, mut func: F)
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Neg<Output=T> +
               Default +
               From<u8> +
               Debug,
            F: ::std::ops::FnMut(T)
    {
      for _ in 0..n {
        func(self.int_until(delim));
      }
    }

    //--------------------------------------------------------------------
    #[allow(dead_code)]

    pub fn uint_vec<T>(&mut self, n: usize, delim: u8) -> Vec<T>
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Default +
               From<u8> +
               Debug
    {
      let mut vec = Vec::with_capacity(n);
      for _ in 0..n - 1 {
        vec.push(self.uint_until(delim));
      }
      vec.push(self.uint_until(LF));
      vec
    }

    #[allow(dead_code)]

    pub fn int_vec<T>(&mut self, n: usize, delim: u8) -> Vec<T>
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Neg<Output=T> +
               Default +
               From<u8> +
               Debug
    {
      let mut vec = Vec::with_capacity(n);
      for _ in 0..n - 1 {
        vec.push(self.int_until(delim));
      }
      vec.push(self.int_until(LF));
      vec
    }

    // horizontal
    //
    // N
    // s1 s2 s3, ..., sN -> [n1, n2, n3, ..., nN]
    #[allow(dead_code)]

    pub fn uint_vec_h<T>(&mut self) -> Vec<T>
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Default +
               From<u8> +
               Debug
    {
      let n: usize = self.uint_until(LF);
      self.uint_vec(n, SP)
    }

    // horizontal
    //
    // N
    // s1 s2 s3, ..., sN -> [n1, n2, n3, ..., nN]
    #[allow(dead_code)]

    pub fn int_vec_h<T>(&mut self) -> Vec<T>
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Neg<Output=T> +
               Default +
               From<u8> +
               Debug
    {
      let n: usize = self.uint_until(LF);
      self.int_vec(n, SP)
    }

    // N M
    // s11 s12 s13 ... s1M
    // s21 s22 s23 ... s2M
    // s31 s32 s33 ... s3M
    //   :
    // sN1 sN2 sN3 ... sNM
    // -> [
    //      [n11, n12, n13, ..., n1M],
    //      [n21, n22, n23, ..., n2M],
    //      [n31, n32, n33, ..., n3M],
    //          :
    //      [nN1, nN2, nN3, ..., nNM],
    //    ]
    #[allow(dead_code)]

    pub fn uint_vec2<T>(&mut self, n: usize, m: usize) -> Vec<Vec<T>>
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Default +
               From<u8> +
               Debug
    {
      let mut vec = Vec::with_capacity(n);
      for _ in 0..n {
        vec.push(self.uint_vec(m, SP));
      }
      vec
    }

    // N M
    // s11 s12 s13 ... s1M
    // s21 s22 s23 ... s2M
    // s31 s32 s33 ... s3M
    //   :
    // sN1 sN2 sN3 ... sNM
    // -> [
    //      [n11, n12, n13, ..., n1M],
    //      [n21, n22, n23, ..., n2M],
    //      [n31, n32, n33, ..., n3M],
    //          :
    //      [nN1, nN2, nN3, ..., nNM],
    //    ]
    #[allow(dead_code)]

    pub fn int_vec2<T>(&mut self, n: usize, m: usize) -> Vec<Vec<T>>
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Neg<Output=T> +
               Default +
               From<u8> +
               Debug
    {
      let mut vec = Vec::with_capacity(n);
      for _ in 0..n {
        vec.push(self.int_vec(m, SP));
      }
      vec
    }

  } // impl<R> Scanner<R>
*/

} // mod my


// ternary operation
#[allow(unused_macros)]
macro_rules! _if {
  ($_test:expr, $_then:expr, $_else:expr) => {
    if $_test { $_then } else { $_else }
  };
  ($_test:expr, $_pat:pat, $_then:expr, $_else:expr) => {
    match $_test {
      $_pat => $_then,
      _     => $_else
    }
  };
}

use std::io::{ stdin, stdout, Write, BufReader };
use my::WriteWith;

#[inline(always)]
fn abc109_c() {
  let stdin  = stdin();
  let stdout = stdout();
  let mut scanner = my::Scanner::with_capacity(12, BufReader::new(stdin.lock()));
  let mut writer  = stdout.lock();
  let mut itoa    = my::ItoA::with_capacity(10);

  let n = my::atoui::<usize>(scanner.read_until(my::SP));
  let x = my::atoi::<i32>(scanner.read_until(my::LF));

  let ans = scanner.fold(n, my::SP, 0, | gcd, s |
    my::gcd((my::atoi::<i32>(s) - x).abs(), gcd)
  );

  writer.write_with(itoa.from_i32(ans), b"\n").unwrap();
  writer.flush().unwrap();
}

fn main() {
  abc109_c();
}

//------------------------------------------------------------------------
mod my {
  use std::hash::Hasher;
  use std::hash::BuildHasher;

  pub struct MyHasher(u64);

  impl Default for MyHasher {
    #[inline(always)]
    fn default() -> Self {
      MyHasher(0x00)
    }
  }

  impl BuildHasher for MyHasher {
    type Hasher = MyHasher;

    #[inline(always)]
    fn build_hasher(&self) -> Self::Hasher {
      Self::Hasher::default()
    }
  }

  impl Hasher for MyHasher {
    #[inline(always)]
    fn finish(&self) -> u64 {
      self.0
    }

    #[inline(always)]
    fn write(&mut self, bytes: &[u8]) {
      self.0 = 0;
      for i in 0..bytes.len() {
        self.0 ^= (bytes[i] as u64) << (8 * (i % 8));
      }
    }
  }

  //----------------------------------------------------------------------
  use std::io::{ self, Write };
  use std::fmt::Debug;
  use std::ops::{ Add, Sub, Mul, Rem, Neg };
  use std::mem;

  #[allow(dead_code)]
  pub const SP    : u8 = b' ';
  #[allow(dead_code)]
  pub const LF    : u8 = b'\n';

  //----------------------------------------------------------------------
  #[allow(dead_code)]
  #[inline(always)]
  pub fn rotate_right<T>(ary: &mut [T])
    where T: Copy +
             Debug
  {
    if ary.len() <= 1 {
      return;
    }

    let len = ary.len() - 1;
    let tmp = ary[len];
    for i in 0..len {
      ary[len - i] = ary[len - i - 1];
    }
    ary[0] = tmp;
  }

  #[allow(dead_code)]
  #[inline(always)]
  pub fn rotate_left<T>(ary: &mut [T])
    where T: Copy +
             Debug
  {
    if ary.len() <= 1 {
      return;
    }

    let len = ary.len() - 1;
    let tmp = ary[0];
    for i in 0..len {
      ary[i] = ary[i + 1];
    }
    ary[len] = tmp;
  }

  //----------------------------------------------------------------------
  #[allow(dead_code)]
  #[inline(always)]
  pub fn gcd<T>(mut x: T, mut y: T) -> T
    where T: Rem<Output=T> +
             Default +
             PartialEq +
             Copy +
             Debug
  {
    let zero = T::default();

    if x == zero { return y; }
    if y == zero { return x; }

    while y != zero {
      let tmp = x % y;
      x = y;
      y = tmp;
    }

    x
  }

  //----------------------------------------------------------------------
  #[allow(dead_code)]
  #[inline(always)]
  pub fn intersection<T>(mut x: (T, T), mut y: (T, T)) -> Option<(T, T)>
    where T: PartialOrd +
             Copy +
             Debug
  {
    if x.0 > x.1 {
      mem::swap(&mut x.0, &mut x.1);
    }
    if y.0 > y.1 {
      mem::swap(&mut y.0, &mut y.1);
    }

    if x.0 >= y.1 || x.1 <= y.0 {
      return None;
    }

    if x.0 < y.0 {
      x.0 = y.0;
    }
    if x.1 > y.1 {
      x.1 = y.1;
    }

    Some(x)
  }

  //----------------------------------------------------------------------
  #[allow(dead_code)]
  #[inline(always)]
  pub fn is_ascii_digit(b: u8) -> bool {
    _if!(b >= b'0' && b <= b'9',
      true,
      false)
  }

  #[allow(dead_code)]
  #[inline(always)]
  pub fn is_ascii_uppercase(b: u8) -> bool {
    _if!(b >= b'A' && b <= b'Z',
      true,
      false)
  }

  #[allow(dead_code)]
  #[inline(always)]
  pub fn is_ascii_lowercase(b: u8) -> bool {
    _if!(b >= b'a' && b <= b'z',
      true,
      false)
  }

  #[allow(dead_code)]
  #[inline(always)]
  pub fn is_ascii_alphabetic(b: u8) -> bool {
    _if!(is_ascii_uppercase(b) || is_ascii_lowercase(b),
      true,
      false)
  }

  #[allow(dead_code)]
  #[inline(always)]
  pub fn to_ascii_lowercase(b: u8) -> u8 {
    _if!(is_ascii_uppercase(b),
      b + 0x20,
      b)
  }

  #[allow(dead_code)]
  #[inline(always)]
  pub fn to_ascii_uppercase(b: u8) -> u8 {
    _if!(is_ascii_lowercase(b),
      b - 0x20,
      b)
  }

  //----------------------------------------------------------------------
  #[allow(dead_code)]
  #[inline(always)]
  pub fn atoui<T>(s: &[u8]) -> T
    where T: Add<Output=T> +
             Sub<Output=T> +
             Mul<Output=T> +
             Default +
             From<u8> +
             Debug
  {
    let mut n = T::default();
    if s.len() == 0 {
      return n;
    }

    let mut i = 0;
    if s[i] == b'+' {
      i += 1;
    }

    for b in &s[i..] {
      n = (n * T::from(10)) + T::from(b - b'0');
    }

    n
  }

  #[allow(dead_code)]
  #[inline(always)]
  pub fn atoi<T>(s: &[u8]) -> T
    where T: Add<Output=T> +
             Sub<Output=T> +
             Mul<Output=T> +
             Neg<Output=T> +
             Default +
             From<u8> +
             Debug
  {
    let mut n = T::default();
    if s.len() == 0 {
      return n;
    }

    let mut i = 0;
    let mut negative = false;
    if s[i] == b'-' {
      negative = true;
      i += 1;
    } else if s[i] == b'+' {
      i += 1;
    }

    for b in &s[i..] {
      n = (n * T::from(10)) + T::from(b - b'0');
    }

    _if!(negative,
      n.neg(),
      n)
  }

  //----------------------------------------------------------------------
  #[allow(dead_code)]
  #[inline(always)]
  pub fn rw<R, W>(cap: usize, r: R, w: W) -> (Scanner<io::BufReader<R>>, io::BufWriter<W>)
    where R: io::BufRead,
          W: io::Write
  {
    (
      Scanner::with_capacity(cap, io::BufReader::new(r)),
      io::BufWriter::new(w)
    )
  }

  //----------------------------------------------------------------------
  pub trait WriteWith {
    fn write_with(&mut self, buf: &[u8], delim: &[u8]) -> io::Result<usize>;
  }

  macro_rules! fn_write_with {
    () => {
      #[inline(always)]
      fn write_with(&mut self, buf: &[u8], delim: &[u8]) -> io::Result<usize> {
        Ok(self.write(buf)? + self.write(delim)?)
      }
    };
  }

  impl WriteWith for Vec<u8> {
    fn_write_with!();
  }
  impl<W> WriteWith for io::BufWriter<W>
    where W: io::Write
  {
    fn_write_with!();
  }
  impl<'a> WriteWith for io::StdoutLock<'a> {
    fn_write_with!();
  }

  //----------------------------------------------------------------------
  macro_rules! pub_fn_ItoA_from_ty {
    (uint, $($name:ident => $_type:ty),*) => {$(
      #[allow(dead_code)]
      #[inline(always)]
      pub fn $name(&mut self, mut n: $_type) -> &[u8] {
        self.buf.clear();
        if n == 0 {
          self.buf.push(b'0');
          return self.buf.as_slice();
        }

        while n > 0 {
          self.buf.push((n % 10) as u8 + b'0');
          n /= 10;
        }
        self.buf.reverse();
        self.buf.as_slice()
      }
    )*};

    (int, $($name:ident => $_type:ty),*) => {$(
      #[allow(dead_code)]
      #[inline(always)]
      pub fn $name(&mut self, mut n: $_type) -> &[u8] {
        self.buf.clear();
        if n == 0 {
          self.buf.push(b'0');
          return self.buf.as_slice();
        }

        let mut negative = false;
        if n.is_negative() {
          negative = true;
          n = n.abs();
        }

        while n > 0 {
          self.buf.push((n % 10) as u8 + b'0');
          n /= 10;
        }
        if negative {
          self.buf.push(b'-');
        }
        self.buf.reverse();
        self.buf.as_slice()
      }
    )*};
  }

  #[derive(Debug)]
  pub struct ItoA {
    buf: Vec<u8>,
  }

  impl ItoA {
    #[allow(dead_code)]
    #[inline(always)]
    pub fn with_capacity(cap: usize) -> Self {
      ItoA {
        buf: Vec::with_capacity(cap),
      }
    }

    pub_fn_ItoA_from_ty!(
      uint,
      from_usize => usize,
      from_u8    => u8,
      from_u16   => u16,
      from_u32   => u32,
      from_u64   => u64
    );

    pub_fn_ItoA_from_ty!(
      int,
      from_isize => isize,
      from_i8    => i8,
      from_i16   => i16,
      from_i32   => i32,
      from_i64   => i64
    );
  } // impl ItoA

  //----------------------------------------------------------------------
  #[derive(Debug)]
  pub struct Scanner<R> {
    reader: R,
    buf   : Vec<u8>,
  }

  impl<R> Scanner<R>
    where R: io::BufRead
  {
    #[allow(dead_code)]
    #[inline(always)]
    pub fn with_capacity(cap: usize, reader: R) -> Self {
      Scanner {
        reader: reader,
        buf   : Vec::with_capacity(cap),
      }
    }

    //--------------------------------------------------------------------
    #[allow(dead_code)]
    #[inline(always)]
    pub fn into_inner(self) -> R {
      self.reader
    }

    #[allow(dead_code)]
    #[inline(always)]
    pub fn resize(&mut self, len: usize, val: u8) {
      self.buf.resize(len, val);
    }

    //--------------------------------------------------------------------
    #[allow(dead_code)]
    #[inline(always)]
    pub fn read_until(&mut self, delim: u8) -> &[u8] {
      self.buf.clear();
      let mut len = self.reader.read_until(delim, &mut self.buf).unwrap();
      if len == 0 {
        return self.buf.as_slice();
      }

      len -= 1;
      if self.buf[len] == delim {
        self.buf.truncate(len);
      }
      self.buf.as_slice()
    }

    //--------------------------------------------------------------------
    #[allow(dead_code)]
    #[inline(always)]
    pub fn for_each<F>(&mut self, n: usize, delim: u8, mut func: F)
      where F: FnMut(&[u8])
    {
      for _ in 0..n - 1 {
        func(self.read_until(delim));
      }
      func(self.read_until(LF))
    }

    #[allow(dead_code)]
    #[inline(always)]
    pub fn fold<B, F>(&mut self, n: usize, delim: u8, mut init: B, mut func: F) -> B
      where F: FnMut(B, &[u8]) -> B
    {
      for _ in 0..n - 1 {
        init = func(init, self.read_until(delim));
      }
      func(init, self.read_until(LF))
    }
  } // impl<R> Scanner<R>

} // mod my


// ternary operation
#[allow(unused_macros)]
macro_rules! _if {
  ($_test:expr, $_then:expr, $_else:expr) => {
    if $_test { $_then } else { $_else }
  };
  ($_test:expr, $_pat:pat, $_then:expr, $_else:expr) => {
    match $_test {
      $_pat => $_then,
      _     => $_else
    }
  };
}

use std::io::{ stdin, stdout, Write };
use my::WriteWith;

#[inline(always)]
fn abc109_c() {
  let stdin  = stdin();
  let stdout = stdout();
  let (mut scanner, mut writer) = my::rw(12, stdin.lock(), stdout.lock());
  let mut itoa = my::ItoA::with_capacity(10);

  let n = scanner.uint_until::<usize>(my::SP);
  let x = scanner.int_until::<i32>(my::LF);

  let ans = scanner.fold_int_to_end(n, my::SP, 0, | gcd, num |
    my::gcd((num - x).abs(), gcd)
  );

  writer.write_with(itoa.from_i32(ans), b"\n").unwrap();
  writer.flush().unwrap();
}

fn main() {
  abc109_c();
}

//------------------------------------------------------------------------
mod my {

  #[derive(Debug)]
  pub struct Scanner<R> {
    reader: R,
    buf   : Vec<u8>,
  }

  impl<R> Scanner<R>
    where R: BufRead
  {
    #[allow(dead_code)]
    #[inline(always)]
    pub fn with_capacity(cap: usize, reader: R) -> Self {
      Scanner {
        reader: reader,
        buf   : Vec::with_capacity(cap),
      }
    }

    //--------------------------------------------------------------------
    #[allow(dead_code)]
    #[inline(always)]
    fn read_until(&mut self, delim: u8) {
      self.buf.clear();
      let mut len = self.reader
                        .read_until(delim, &mut self.buf).unwrap();
      if len == 0 {
        return;
      }

      len -= 1;
      if self.buf[len] == delim {
        self.buf.truncate(len);
      }
    }

    //--------------------------------------------------------------------
    #[allow(dead_code)]
    #[inline(always)]
    pub fn uint_until<T>(&mut self, delim: u8) -> T
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Default +
               From<u8> +
               Debug
    {
      self.read_until(delim);

      let mut n = T::default();
      if self.buf.len() == 0 {
        return n;
      }

      let mut i = 0;
      if self.buf[i] == PLUS_SIGN {
        i += 1;
      }

      for b in &self.buf[i..] {
        n = (n * T::from(10)) + T::from(b - ASCII_0);
      }

      n
    }

    #[allow(dead_code)]
    #[inline(always)]
    pub fn int_until<T>(&mut self, delim: u8) -> T
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Neg<Output=T> +
               Default +
               From<u8> +
               Debug
    {
      self.read_until(delim);

      let mut n = T::default();
      if self.buf.len() == 0 {
        return n;
      }

      let mut i = 0;
      let mut negative = false;
      if self.buf[i] == MINUS_SIGN {
        negative = true;
        i += 1;
      } else if self.buf[i] == PLUS_SIGN {
        i += 1;
      }

      for b in &self.buf[i..] {
        n = (n * T::from(10)) + T::from(b - ASCII_0);
      }

      _if!(negative,
        n.neg(),
        n)
    }

    //--------------------------------------------------------------------
    #[allow(dead_code)]
    #[inline(always)]
    pub fn fold_uint_to_end<T, F>(&mut self, n: usize, delim: u8, mut init: T, mut func: F) -> T
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Default +
               From<u8> +
               Debug,
            F: ::std::ops::FnMut(T, T) -> T
    {
      for _ in 0..n - 1 {
        init = func(init, self.uint_until(delim));
      }
      func(init, self.uint_until(LF))
    }

    #[allow(dead_code)]
    #[inline(always)]
    pub fn fold_int_to_end<T, F>(&mut self, n: usize, delim: u8, mut init: T, mut func: F) -> T
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Neg<Output=T> +
               Default +
               From<u8> +
               Debug,
            F: ::std::ops::FnMut(T, T) -> T
    {
      for _ in 0..n - 1 {
        init = func(init, self.int_until(delim));
      }
      func(init, self.int_until(LF))
    }
  } // impl<R> Scanner<R>

  #[allow(dead_code)]
  #[inline(always)]
  pub fn rw<R, W>(cap: usize, r: R, w: W) -> (Scanner<BufReader<R>>, BufWriter<W>)
    where R: BufRead,
          W: io::Write
  {
    (
      Scanner::with_capacity(cap, BufReader::new(r)),
      BufWriter::new(w)
    )
  }

/*
  #[allow(dead_code)]
  #[inline(always)]
  pub fn atoui<T>(s: &[u8]) -> T
    where T: Add<Output=T> +
             Sub<Output=T> +
             Mul<Output=T> +
             Default +
             From<u8> +
             Debug
  {
    let mut n = T::default();
    if s.len() == 0 {
      return n;
    }

    let mut i = 0;
    if s[i] == PLUS_SIGN {
      i += 1;
    }

    for b in &s[i..] {
      n = (n * T::from(10)) + T::from(b - ASCII_0);
    }

    n
  }

  #[allow(dead_code)]
  #[inline(always)]
  pub fn atoi<T>(s: &[u8]) -> T
    where T: Add<Output=T> +
             Sub<Output=T> +
             Mul<Output=T> +
             Neg<Output=T> +
             Default +
             From<u8> +
             Debug
  {
    let mut n = T::default();
    if s.len() == 0 {
      return n;
    }

    let mut i = 0;
    let mut negative = false;
    if s[i] == MINUS_SIGN {
      negative = true;
      i += 1;
    } else if s[i] == PLUS_SIGN {
      i += 1;
    }

    for b in &s[i..] {
      n = (n * T::from(10)) + T::from(b - ASCII_0);
    }

    _if!(negative,
      n.neg(),
      n)
  }
*/

/*
  #[allow(dead_code)]
  #[inline(always)]
  pub fn read_until<R>(reader: &mut R, delim: u8, buf: &mut Vec<u8>)
    where R: BufRead
  {
    buf.clear();
    reader.read_until(delim, buf).unwrap();

    let len = buf.len() - 1;
    if buf[len] == delim {
      buf.truncate(len);
    }
  }

  #[allow(dead_code)]
  #[inline(always)]
  pub fn for_each<R>(&mut self, n: usize, reader: &mut R, delim: u8, buf: &mut Vec<u8>, mut init: T, mut func: F)
    where R: BufRead,
          F: ::std::ops::FnMut(T, T)
  {
    for _ in 0..n - 1 {
      read_until(reader, delim, buf);
      func(buf);
    }
    read_until(reader, LF, buf);
    func(buf);
  }
*/

  use std::hash::Hasher;
  use std::hash::BuildHasher;

  pub struct MyHasher(u64);

  impl Default for MyHasher {

    fn default() -> Self {
      MyHasher(0x00)
    }
  }

  impl BuildHasher for MyHasher {
    type Hasher = MyHasher;

    fn build_hasher(&self) -> Self::Hasher {
      Self::Hasher::default()
    }
  }

  impl Hasher for MyHasher {

    fn finish(&self) -> u64 {
      self.0
    }

    fn write(&mut self, bytes: &[u8]) {
      self.0 = 0;
      for i in 0..bytes.len() {
        self.0 ^= (bytes[i] as u64) << (8 * (i % 8));
      }
    }
  }

  //----------------------------------------------------------------------
  use std::io::{ self, BufRead, BufReader, Write, BufWriter };
  use std::fmt::Debug;
  use std::ops::{ Add, Sub, Mul, Div, Rem, Neg };
//  use std::str::{ self, FromStr };
  use std::mem;

  const PLUS_SIGN : u8 = b'+';
  const MINUS_SIGN: u8 = b'-';
  const ASCII_0   : u8 = b'0';
  const ASCII_9   : u8 = b'9';

  pub const SP    : u8 = b' ';
  pub const LF    : u8 = b'\n';

  //----------------------------------------------------------------------
  #[allow(dead_code)]

  pub fn floor<T>(dividend: T, divisor: T) -> T
    where T: Add<Output=T> +
             Sub<Output=T> +
             Div<Output=T> +
             Copy +
             Default +
             Debug
  {
    dividend / divisor
  }

  #[allow(dead_code)]

  pub fn ceil<T>(dividend: T, divisor: T) -> T
    where T: Add<Output=T> +
             Sub<Output=T> +
             Div<Output=T> +
             Copy +
             Default +
             From<u8> +
             Debug
  {
    (dividend + divisor - T::from(1)) / divisor
  }

  //----------------------------------------------------------------------
  #[allow(dead_code)]

  pub fn rotate_right<T>(ary: &mut [T])
    where T: Copy +
             Debug
  {
    if ary.len() <= 1 {
      return;
    }

    let len = ary.len() - 1;
    let tmp = ary[len];
    for i in 0..len {
      ary[len - i] = ary[len - i - 1];
    }
    ary[0] = tmp;
  }

  #[allow(dead_code)]

  pub fn rotate_left<T>(ary: &mut [T])
    where T: Copy +
             Debug
  {
    if ary.len() <= 1 {
      return;
    }

    let len = ary.len() - 1;
    let tmp = ary[0];
    for i in 0..len {
      ary[i] = ary[i + 1];
    }
    ary[len] = tmp;
  }

  //----------------------------------------------------------------------
  #[allow(dead_code)]
  #[inline(always)]
  pub fn gcd<T>(x: T, y: T) -> T
    where T: Rem<Output=T> +
             Default +
             PartialEq +
             Copy +
             Debug
  {
    _if!(y == T::default(),
      x,
      gcd(y, x % y))
  }

  //----------------------------------------------------------------------
  #[allow(dead_code)]

  pub fn intersection<T>(mut x: (T, T), mut y: (T, T)) -> Option<(T, T)>
    where T: PartialOrd +
             Copy +
             Debug
  {
    if x.0 > x.1 {
      mem::swap(&mut x.0, &mut x.1);
    }
    if y.0 > y.1 {
      mem::swap(&mut y.0, &mut y.1);
    }

    if x.0 >= y.1 || x.1 <= y.0 {
      return None;
    }

    if x.0 < y.0 {
      x.0 = y.0;
    }
    if x.1 > y.1 {
      x.1 = y.1;
    }

    Some(x)
  }

  //----------------------------------------------------------------------
  #[allow(dead_code)]

  pub fn is_ascii_digit(b: u8) -> bool {
    _if!(b >= ASCII_0 && b <= ASCII_9,
      true,
      false)
  }

  #[allow(dead_code)]

  pub fn is_ascii_uppercase(b: u8) -> bool {
    _if!(b >= b'A' && b <= b'Z',
      true,
      false)
  }

  #[allow(dead_code)]

  pub fn is_ascii_lowercase(b: u8) -> bool {
    _if!(b >= b'a' && b <= b'z',
      true,
      false)
  }

  #[allow(dead_code)]

  pub fn is_ascii_alphabetic(b: u8) -> bool {
    _if!(is_ascii_uppercase(b) || is_ascii_lowercase(b),
      true,
      false)
  }

  #[allow(dead_code)]

  pub fn to_ascii_lowercase(b: u8) -> u8 {
    _if!(is_ascii_uppercase(b),
      b + 0x20,
      b)
  }

  #[allow(dead_code)]

  pub fn to_ascii_uppercase(b: u8) -> u8 {
    _if!(is_ascii_lowercase(b),
      b - 0x20,
      b)
  }

  //----------------------------------------------------------------------
  pub trait WriteWith {
    fn write_with(&mut self, buf: &[u8], delim: &[u8]) -> io::Result<usize>;
  }

  impl<W> WriteWith for BufWriter<W>
    where W: io::Write
  {
    #[allow(dead_code)]
    #[inline(always)]
    fn write_with(&mut self, buf: &[u8], delim: &[u8]) -> io::Result<usize>
    {
      Ok(self.write(buf)? + self.write(delim)?)
    }
  } // impl<W> WriteWith for BufWriter<W>

  //----------------------------------------------------------------------
  macro_rules! pub_fn_ItoA_from_ty {
    (uint, $($name:ident => $_type:ty),*) => {$(
      #[allow(dead_code)]
      #[inline(always)]
      pub fn $name(&mut self, mut n: $_type) -> &[u8] {
        self.buf.clear();
        if n == 0 {
          self.buf.push(ASCII_0);
          return self.buf.as_slice();
        }

        while n > 0 {
          self.buf.push((n % 10) as u8 + ASCII_0);
          n /= 10;
        }
        self.buf.reverse();
        self.buf.as_slice()
      }
    )*};

    (int, $($name:ident => $_type:ty),*) => {$(
      #[allow(dead_code)]
      #[inline(always)]
      pub fn $name(&mut self, mut n: $_type) -> &[u8] {
        self.buf.clear();
        if n == 0 {
          self.buf.push(ASCII_0);
          return self.buf.as_slice();
        }

        let mut negative = false;
        if n.is_negative() {
          negative = true;
          n = n.abs();
        }

        while n > 0 {
          self.buf.push((n % 10) as u8 + ASCII_0);
          n /= 10;
        }
        if negative {
          self.buf.push(MINUS_SIGN);
        }
        self.buf.reverse();
        self.buf.as_slice()
      }
    )*};
  }

  #[derive(Debug)]
  pub struct ItoA {
    buf: Vec<u8>,
  }

  impl ItoA {
    #[allow(dead_code)]
    #[inline(always)]
    pub fn new() -> Self {
      ItoA {
        buf: Vec::new(),
      }
    }

    #[allow(dead_code)]
    #[inline(always)]
    pub fn with_capacity(cap: usize) -> Self {
      ItoA {
        buf: Vec::with_capacity(cap),
      }
    }

    pub_fn_ItoA_from_ty!(
      uint,
      from_usize => usize,
      from_u8    => u8,
      from_u16   => u16,
      from_u32   => u32,
      from_u64   => u64
    );

    pub_fn_ItoA_from_ty!(
      int,
      from_isize => isize,
      from_i8    => i8,
      from_i16   => i16,
      from_i32   => i32,
      from_i64   => i64
    );
  } // impl ItoA

/*
  //----------------------------------------------------------------------
  #[allow(dead_code)]
  #[inline(always)]
  pub fn rw<R, W>(cap: usize, r: R, w: W) -> (Scanner<BufReader<R>>, BufWriter<W>)
    where R: BufRead,
          W: io::Write
  {
    (
      Scanner::with_capacity(cap, BufReader::new(r)),
      BufWriter::new(w)
    )
  }

  #[allow(dead_code)]

  pub fn r<R>(cap: usize, r: R) -> Scanner<BufReader<R>>
    where R: BufRead
  {
    Scanner::with_capacity(cap, BufReader::new(r))
  }

  #[allow(dead_code)]

  pub fn w<W>(w: W) -> BufWriter<W>
    where W: io::Write
  {
    BufWriter::new(w)
  }
*/

/*
  //----------------------------------------------------------------------
  #[derive(Debug)]
  pub struct Scanner<R> {
    reader: R,
    buf   : Vec<u8>,
  }

  impl<R> Scanner<R>
    where R: BufRead
  {
    #[allow(dead_code)]

    pub fn new(reader: R) -> Self {
      Scanner {
        reader: reader,
        buf   : Vec::new(),
      }
    }

    #[allow(dead_code)]
    #[inline(always)]
    pub fn with_capacity(cap: usize, reader: R) -> Self {
      Scanner {
        reader: reader,
        buf   : Vec::with_capacity(cap),
      }
    }

    //--------------------------------------------------------------------

    #[allow(dead_code)]
    #[inline(always)]
    pub fn into_inner(self) -> R {
      self.reader
    }

    #[inline(always)]
    fn read_until(&mut self, delim: u8) {
      self.buf.clear();
      let mut len = self.reader
                      .read_until(delim, &mut self.buf)
                      .expect(&format!("read_until(): {}", line!()));
      if len == 0 {
        return;
      }

      len -= 1;
      if self.buf[len] == delim {
        self.buf.truncate(len);
      }
    }

    #[allow(dead_code)]

    fn read_until_delim(&mut self) {
      let mut buf: [u8; 1] = [0; 1];

      self.buf.clear();
      while self.reader
              .read(&mut buf)
              .expect(&format!("read(): {}", line!())) != 0 &&
            buf[0] != SP &&
            buf[0] != LF
      {
        self.buf.push(buf[0]);
      }
    }

    //--------------------------------------------------------------------
    // s -> n
    #[allow(dead_code)]

    pub fn parse_until<T>(&mut self, delim: u8) -> T
      where T: FromStr + Debug,
            <T as FromStr>::Err: Debug
    {
      self.read_until(delim);
      unsafe { str::from_utf8_unchecked(&self.buf) }
        .parse()
        .unwrap()
    }

    //--------------------------------------------------------------------
    #[allow(dead_code)]
    #[inline(always)]
    pub fn byte_until(&mut self, delim: u8) -> Vec<u8> {
      self.read_until(delim);
      self.buf.clone()
    }

    #[allow(dead_code)]
    #[inline(always)]
    pub fn string_until(&mut self, delim: u8) -> String {
      unsafe { String::from_utf8_unchecked(self.byte_until(delim)) }
    }

    //--------------------------------------------------------------------
    // s -> n
    #[allow(dead_code)]
    #[inline(always)]
    pub fn uint_until<T>(&mut self, delim: u8) -> T
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Default +
               From<u8> +
               Debug
    {
      self.read_until(delim);
      atoui(&self.buf)
    }

    // s -> n
    #[allow(dead_code)]
    #[inline(always)]
    pub fn int_until<T>(&mut self, delim: u8) -> T
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Neg<Output=T> +
               Default +
               From<u8> +
               Debug
    {
      self.read_until(delim);
      atoi(&self.buf)
    }

    // s -> n
    #[allow(dead_code)]

    pub fn int_1<T>(&mut self) -> T
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Neg<Output=T> +
               Default +
               From<u8> +
               Debug
    {
      self.read_until_delim();
      let mut n = T::default();
      if self.buf.len() == 0 {
        return n;
      }

      let mut i = 0;
      let mut negative = false;
      if self.buf[i] == MINUS_SIGN {
        negative = true;
        i += 1;
      } else if self.buf[i] == PLUS_SIGN {
        i += 1;
      }

      for b in &self.buf[i..] {
        n = (n * T::from(10)) + T::from(b - ASCII_0);
      }

      _if!(negative,
        n.neg(),
        n)
    }

    // s -> n
    #[allow(dead_code)]

    pub fn int<T>(&mut self) -> T
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Neg<Output=T> +
               Default +
               From<u8> +
               Debug
    {
      let mut buf: [u8; 1] = [0; 1];

      if self.reader
             .read(&mut buf)
             .expect(&format!("read(): {}", line!())) == 0 ||
         buf[0] == SP ||
         buf[0] == LF
      {
        panic!("int_until_x(): {}", line!());
      }

      let mut n = T::default();

      let mut negative = false;
      if buf[0] == MINUS_SIGN {
        negative = true;
      } else if buf[0] == PLUS_SIGN {
        // do nothing
      } else {
        n = (n * T::from(10)) + T::from(buf[0] - ASCII_0);
      }

      loop {
        self.reader
            .read(&mut buf)
            .expect(&format!("read(): {}", line!()));
        if buf[0] == SP || buf[0] == LF {
          break;
        } else {
          n = (n * T::from(10)) + T::from(buf[0] - ASCII_0);
        }
      }

      // while self.reader
      //         .read(&mut buf)
      //         .expect(&format!("read(): {}", line!())) != 0 &&
      //       buf[0] != SP &&
      //       buf[0] != LF
      // {
      //   n = (n * T::from(10)) + T::from(buf[0] - ASCII_0);
      // }

      _if!(negative,
        n.neg(),
        n)
    }

    //--------------------------------------------------------------------
    #[allow(dead_code)]

    pub fn uint_to_end<T, F>(&mut self, n: usize, delim: u8, mut init: T, mut func: F) -> T
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Default +
               From<u8> +
               Debug,
            F: ::std::ops::FnMut(T, T) -> T
    {
      for _ in 0..n - 1 {
        init = func(init, self.uint_until(delim));
      }
      func(init, self.uint_until(LF))
    }

    #[allow(dead_code)]

    pub fn int_to_end<T, F>(&mut self, n: usize, delim: u8, mut init: T, mut func: F) -> T
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Neg<Output=T> +
               Default +
               From<u8> +
               Debug,
            F: ::std::ops::FnMut(T, T) -> T
    {
      for _ in 0..n - 1 {
        init = func(init, self.int_until(delim));
      }
      func(init, self.int_until(LF))
    }

    #[allow(dead_code)]

    pub fn uint_n<T, F>(&mut self, n: usize, delim: u8, mut func: F)
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Default +
               From<u8> +
               Debug,
            F: ::std::ops::FnMut(T)
    {
      for _ in 0..n {
        func(self.uint_until(delim));
      }
    }

    #[allow(dead_code)]

    pub fn int_n<T, F>(&mut self, n: usize, delim: u8, mut func: F)
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Neg<Output=T> +
               Default +
               From<u8> +
               Debug,
            F: ::std::ops::FnMut(T)
    {
      for _ in 0..n {
        func(self.int_until(delim));
      }
    }

    //--------------------------------------------------------------------
    #[allow(dead_code)]

    pub fn uint_vec<T>(&mut self, n: usize, delim: u8) -> Vec<T>
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Default +
               From<u8> +
               Debug
    {
      let mut vec = Vec::with_capacity(n);
      for _ in 0..n - 1 {
        vec.push(self.uint_until(delim));
      }
      vec.push(self.uint_until(LF));
      vec
    }

    #[allow(dead_code)]

    pub fn int_vec<T>(&mut self, n: usize, delim: u8) -> Vec<T>
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Neg<Output=T> +
               Default +
               From<u8> +
               Debug
    {
      let mut vec = Vec::with_capacity(n);
      for _ in 0..n - 1 {
        vec.push(self.int_until(delim));
      }
      vec.push(self.int_until(LF));
      vec
    }

    // horizontal
    //
    // N
    // s1 s2 s3, ..., sN -> [n1, n2, n3, ..., nN]
    #[allow(dead_code)]

    pub fn uint_vec_h<T>(&mut self) -> Vec<T>
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Default +
               From<u8> +
               Debug
    {
      let n: usize = self.uint_until(LF);
      self.uint_vec(n, SP)
    }

    // horizontal
    //
    // N
    // s1 s2 s3, ..., sN -> [n1, n2, n3, ..., nN]
    #[allow(dead_code)]

    pub fn int_vec_h<T>(&mut self) -> Vec<T>
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Neg<Output=T> +
               Default +
               From<u8> +
               Debug
    {
      let n: usize = self.uint_until(LF);
      self.int_vec(n, SP)
    }

    // N M
    // s11 s12 s13 ... s1M
    // s21 s22 s23 ... s2M
    // s31 s32 s33 ... s3M
    //   :
    // sN1 sN2 sN3 ... sNM
    // -> [
    //      [n11, n12, n13, ..., n1M],
    //      [n21, n22, n23, ..., n2M],
    //      [n31, n32, n33, ..., n3M],
    //          :
    //      [nN1, nN2, nN3, ..., nNM],
    //    ]
    #[allow(dead_code)]

    pub fn uint_vec2<T>(&mut self, n: usize, m: usize) -> Vec<Vec<T>>
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Default +
               From<u8> +
               Debug
    {
      let mut vec = Vec::with_capacity(n);
      for _ in 0..n {
        vec.push(self.uint_vec(m, SP));
      }
      vec
    }

    // N M
    // s11 s12 s13 ... s1M
    // s21 s22 s23 ... s2M
    // s31 s32 s33 ... s3M
    //   :
    // sN1 sN2 sN3 ... sNM
    // -> [
    //      [n11, n12, n13, ..., n1M],
    //      [n21, n22, n23, ..., n2M],
    //      [n31, n32, n33, ..., n3M],
    //          :
    //      [nN1, nN2, nN3, ..., nNM],
    //    ]
    #[allow(dead_code)]

    pub fn int_vec2<T>(&mut self, n: usize, m: usize) -> Vec<Vec<T>>
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Neg<Output=T> +
               Default +
               From<u8> +
               Debug
    {
      let mut vec = Vec::with_capacity(n);
      for _ in 0..n {
        vec.push(self.int_vec(m, SP));
      }
      vec
    }

  } // impl<R> Scanner<R>
*/

} // mod my


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

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

fn main() {
    let n:usize = read();
    let x:i64 = read();
    let mut v = vec![x];
    for _ in 0..n {
        v.push(read());
    }
    let mut ans = v[1] - v[0];
    for i in 1..=n {
        ans = gcd(ans, v[i]-v[i-1]);
    }
    println!("{}", ans);
}

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


use std::cmp::min;
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let n:usize = read();
    let x:i64 = read();
    let mut v = vec![x];
    for _ in 0..n {
        v.push(read());
    }
    v.sort();
    let mut ans = v[1] - v[0];
    for i in 1..=n {
        ans = min(ans, v[i]-v[i-1]);
    }
    println!("{}", ans);
}


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

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

fn main() {
    let n:usize = read();
    let x:i64 = read();
    let mut v:Vec<i64> = (0..n).map(|_| read()).collect();
    v.sort();
    let mut ans = v[1] - v[0];
    for i in 1..=n {
        ans = gcd(ans, v[i]-v[i-1]);
    }
    println!("{}", ans);
}

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


import Foundation
//最大公約数を求める関数
func gcd(_ a: Int, _ b: Int) -> Int {
   let r = a % b
   if r != 0 {
       return gcd(b, r)
   } else {
       return b
   }
}
//３つ以上の数の最大公約数を求める
func gcdArr(_ numArr: [Int]) -> Int {
    var ans: Int = numArr[0]
    for i in numArr {
        ans = gcd(ans, i)
    }
    return ans
}

let rl = readLine()!.split(separator: " ").map({Int($0)!})
let N = rl[0]
let X = rl[1]
let xi = readLine()!.split(separator: " ").map({Int($0)!})

let absxi = xi.map({abs($0 - X)})

print(gcdArr(absxi))


// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///最大公約数を返す
func gcd(_ array: [Int]) -> Int {
    var value = array[0]
    if array.count > 1 {
        for i in 1..<array.count {
            value = gcd(value, array[i])
        }
    }
    return value
}

///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }

    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {

    mutating func remove(_ element: Element) {
        _ = firstIndex(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt

    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2

        if Int(ary[mid])! < key {
            left = mid

        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }

    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let nx = readInts()
    let (_, x) = (nx[0], nx[1])
    let aryX = readInts()
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    let aryXd = aryX.map {abs($0 - x)}

    print(gcd(aryXd))
}

main()


func gcd(x: Int, _ y: Int) -> Int {
    if y == 0 {
        return x
    } else {
        return gcd(y, x%y)
    }
}
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let x = (readLine()!.characters.split(" ").map{Int(String($0))!} + [input[1]]).sort()
let d = (1...input[0]).map{x[$0] - x[$0-1]}
var ans = 0
for i in d {
    ans = gcd(i, ans)
}
print(ans)


import Foundation
//最大公約数を求める関数
func gcd(_ a: Int, _ b: Int) -> Int {
   let r = a % b
   if r != 0 {
       return gcd(b, r)
   } else {
       return b
   }
}

let rl = readLine()!.split(separator: " ").map({Int($0)!})
let N = rl[0]
let X = rl[1]
let xi = readLine()!.split(separator: " ").map({Int($0)!})

let absxi = xi.map({abs($0 - X)})

print(absxi.min()!)


let N = readLine()!.characters.split(" ").map{Int(String($0))!}[1]
let x = (readLine()!.characters.split(" ").map{Int(String($0))!}+[N]).sort()
let d = (0..<x.count).map{x[$0+1]-x[$0]}
var ans = 0
for i in d {
    var (a, b) = (i, ans)
    while b > 0 {
        (a, b) = (b, a%b)
    }
    ans = a
}
print(ans)


let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let x = (readLine()!.characters.split(" ").map{Int(String($0))!}).sort()
let d = (1..<input[0]).map{x[$0]-x[$0-1]}
var ans = input[1]
for i in d {
    var (a, b) = (i, ans)
    while b > 0 {
        (a, b) = (b, a%b)
    }
    ans = a
}
print(ans)


function Main(input: string) {
  const lines = input.split('\n');
  const params1 = lines[0].split(' ');

  const n = parseInt(params1[0]);
  const x = parseInt(params1[1]);
  const xs = lines[1].split(' ').map(x => parseInt(x));

  const euclid: (m: number, n: number) => number = (m, n) => {
    if (m < n) return euclid(n, m);
    if (n === 0) return m;
    return euclid(n, m % n);
  };

  const d = xs
    .map(a => Math.abs(a - x))
    .reduce(euclid);

  console.log(d);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function Main(input: string) {
  const lines = input.split('\n');
  const params1 = lines[0].split(' ');

  const n = parseInt(params1[0]);
  const x = parseInt(params1[1]);
  const xs = lines[1].split(' ').map(x => parseInt(x));

  const euclid: (m: number, n: number) => number = (m, n) => {
    if (m < n) return euclid(n, m);
    if (n === 0) return m;
    return euclid(n, m % n);
  };

  const d =
    xs.map(a => Math.abs(a - x))
      .reduce(euclid);

  console.log(d);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function Main(input: string) {
  const lines = input.split('\n');
  const params1 = lines[0].split(' ');

  const x = parseInt(params1[1]);
  const xs = lines[1].split(' ').map(x => parseInt(x));

  const d = xs.map(a => Math.abs(a - x)).reduce(euclid);

  console.log(d);
}

function euclid(m: number, n: number): number {
  if (m < n) return euclid(n, m);
  if (n === 0) return m;
  return euclid(n, m % n);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


"use strict";
function Main(input) {
    const lines = input.split('\n');
    const params1 = lines[0].split(' ');
    const n = parseInt(params1[0]);
    const x = parseInt(params1[1]);
    const xs = lines[1].split(' ').map(x => parseInt(x));
    let l = Math.abs(xs[0] - x);
    xs.forEach(a => {
        l = Math.min(Math.abs(a - x), l);
    });
    let d = 1;
    // for (let i = 2; i <= l; i++) {
    //   if (xs.every(a => Math.abs(a - x) % i === 0)) d = i;
    // }
    for (let i = l; i >= 2; i--) {
        if (xs.every(a => Math.abs(a - x) % i === 0)) {
            d = i;
            break;
        }
    }
    console.log(d);
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//# sourceMappingURL=index.js.map


function Main(input: string) {
  const lines = input.split('\n');
  const params1 = lines[0].split(' ');

  const n = parseInt(params1[0]);
  const x = parseInt(params1[1]);
  const xs = lines[1].split(' ').map(x => parseInt(x));

  let l = Math.abs(xs[0] - x);
  xs.forEach(a => {
    l = Math.min(Math.abs(a - x), l);
  });

  let d = 1;
  // for (let i = 2; i <= l; i++) {
  //   if (xs.every(a => Math.abs(a - x) % i === 0)) d = i;
  // }
  for (let i = l; i >= 2; i--) {
    if (xs.every(a => Math.abs(a - x) % i === 0)) {
      d = i;
      break;
    }
  }

  console.log(d);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function Main(input: string) {
  const lines = input.split('\n');
  const params1 = lines[0].split(' ');

  const n = parseInt(params1[0]);
  const x = parseInt(params1[1]);
  const xs = lines[1].split(' ').map(x => parseInt(x));

  let l = Math.abs(xs[0] - x);
  xs.forEach(a => {
    l = Math.min(Math.abs(a - x), l);
  });

  let d = 1;
  for (let i = 2; i <= l; i++) {
    if (xs.every(a => Math.abs(a - x) % i === 0)) d = i;
  }

  console.log(d);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


import sys

N, Y = [int(x) for x in sys.stdin.readline().strip().split()]

a = Y // 10000
b = (Y - a * 10000) // 5000
c = (Y - a * 10000 - b * 5000) // 1000

while 1:
    t = a + b + c
    if N >= t + 9 and a > 0:
        a -= 1
        c += 10
        continue
    if N >= t + 4 and b > 0:
        b -= 1
        c += 5
        continue
    if N > t and a > 0:
        a -= 1
        b += 2
        continue
    break

if a + b + c != N or a < 0 or b < 0 or c < 0:
    print("-1 -1 -1")
else:
    print(a, b, c)
    #print(a + b + c)
    #print(a*10000+b*5000+c*1000)


a,sums= list(map(int,input().split()))
yuki = sums//10000
taishi = (sums%10000) //5000
noguchi = (sums%5000) //1000
while a>yuki+taishi+noguchi:
  if ((a-(yuki+taishi+noguchi))%4==0)&(taishi>0):
    taishi-=1
    noguchi+=5
  elif yuki>0:
    yuki-=1
    taishi+=2
  else:
    break
if a==yuki+taishi+noguchi:
  print(yuki,taishi,noguchi)
else:
  print("-1 -1 -1")


(N,Y) = [int(i) for i in input().split()]

y10k = Y // 10000
y5k, y1k = divmod((Y%10000)/1000, 5)

current_inbag = y10k+y5k+y1k
diff = N - current_inbag

if Y > 10000*N or Y < 1000*N or diff < 0:
    print('-1 -1 -1')
    exit()

while y10k > 0 and diff >= 9:
    y10k -= 1
    y1k += 10
    diff -= 9

if y10k > 0 and diff >= 5:
    y10k -= 1
    y5k += 1
    y1k += 5
    diff -= 5

while y10k > 0 and diff > 0:
    y10k -= 1
    y5k += 2
    diff -= 1

if y10k == 0 and diff > 0:
    while y5k > 0 and diff >= 4:
        y5k -= 1
        y1k += 5
        diff -= 4

if diff == 0:
    print('%d %d %d' % (y10k,y5k,y1k))
    exit()

print('-1 -1 -1')


N,Y = map(int, input().split())
for x in range(N+1):
    for y in range(N+1-x):
        z = Y - 10000*x - 5000*y
        if (10000*x + 5000*y + 1000*z) == Y and 0 <= z <= 2000:
            print(x,y,z)
            exit()

print("-1 -1 -1")


N,Y = map(int, input().split())
for x in range(1,N+1):
    for y in range(1,N+1):
        z = Y - 10000*x - 5000*y
        if (10000*x + 5000*y + 1000*z) == Y and 0 <= z <= 2000:
            print(x,y,z)
            exit()

print("-1 -1 -1")


N,Y = map(int, input().split())
for x in range(1,N+1):
    for y in range(1,N+1):
        if 0 <= Y - x - y < Y:
            print(x,y,Y-x-y)
            exit()
print("-1 -1 -1")


import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		new Main().solve();
	}

	List<List<int[]>> list;

	void solve() {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int Y = sc.nextInt()/1000;
		int[] m = new int[3];
		m[0] = Y/10;
		m[1] = Y%10/5;
		m[2] = Y%5;
		int f = N - m[0] - m[1] - m[2];
		for (int i = 0; i <= m[0]; i++) {
			int t = f - i;
			if (t < 0) break;
			if (t % 4 == 0 && t / 4 <= m[1] + i*2) {
				int a = m[0] - i;
				int b = m[1] + i * 2 - t / 4;
				int c = N - a - b;
				out(a + " " + b + " " + c);
				return;
			}
		}
		out("-1 -1 -1");
	}

	class Combination {
		final int mod;
		final int max;

		final long[] fact;
		final long[] inv;
		final long[] invfact;

		public Combination(int n) {
			this(n, 1_000_000_007);
		}

		public Combination(int n, int mod) {
			this.mod = mod;
			max = n + 1;
			fact = new long[max];
			invfact = new long[max];
			inv = new long[max];

			inv[1] = 1;
			for (int i = 2; i < inv.length; i++) {
				inv[i] = inv[mod % i] * (mod - mod / i) % mod;
			}

			fact[0] = 1;
			invfact[0] = 1;
			for (int i = 1; i < inv.length; i++) {
				fact[i] = i * fact[i - 1] % mod;
				invfact[i] = inv[i] * invfact[i - 1] % mod;
			}
		}

		public long get(int n, int r) {
			return fact[n] * invfact[n - r] % mod * invfact[r] % mod;
		}
	}

	public long gcd(long a, long b) {
		long remainder = a % b;
		if (remainder == 0) {
			return b;
		} else {
			return gcd(b, remainder);
		}
	}

	void out(String a) {
		System.out.println(a);
	}

	void out(int a) {
		System.out.println(a);
	}

	void out(long a) {
		System.out.println(a);
	}

	void out(double a) {
		System.out.println(a);
	}

	void out(char a) {
		System.out.println(a);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


import java.io.*;

class Main {
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] inputLine = br.readLine().split(" ");
        int n = Integer.valueOf(inputLine[0]), y = Integer.valueOf(inputLine[1]);
        int b10th = 0, b5th = 0, b1th = y / 1000;
        int redundant = b1th - n;

        for (int i = 0; i <= n; i++) {
            if (redundant < 4) {
                break;
            } else if (redundant % 9 == 0 && 10 * (redundant / 9) <= b1th) {
                b10th = redundant / 9;
                b1th -= 10 * b10th;
                break;
            } else {
                redundant -= 4;
                b5th += 1;
                b1th -= 5;
            }
        }

        if (b10th + b5th + b1th != n) {
            b10th = -1; b5th = -1; b1th = -1;
        }

        System.out.println(b10th + " " + b5th + " " + b1th);
    }
}


import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main implements Runnable {

	public static void main(String[] args) {

		new Thread(null, new Main(), "", 16 * 1024 * 1024).start();

	}

	@Override
	public void run() {
		exec();
	}

	private void exec() {

		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		int yen = sc.nextInt();
		if(yen % 1000 != 0) {
			System.out.println("-1 -1 -1");
			System.exit(0);
		}
		int x = 0;
		int y = 0;
		int z = 0;
		x = yen / 1000;
		if(x == n) {
			System.out.println("0 0 " + x);
			System.exit(0);
		}
		int sa = x - n;
		if(sa < 0) {
			System.out.println("-1 -1 -1");
			System.exit(0);
		}
		for(int i = 0 ; i * 4 <= sa ; i++) {
			for(int j = 0 ; i * 4 + j * 9 <= sa ; j++) {
				if(i * 4 + j * 9 == sa) {
					y = i;
					z = j;
					x -= (y * 5 + z * 10);
					if(x < 0) {
						System.out.println("-1 -1 -1");
					} else {
						System.out.println(z + " " + y + " " + x);
					}
					System.exit(0);
				}
			}
		}
		System.out.println("-1 -1 -1");
	}

}

class FastScanner {

	private final InputStream in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	public FastScanner(InputStream in) {
		this.in = in;
	}

	private boolean hasNextByte() {
		if(ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if(buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if(hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while(hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)){
				return minus ? -n : n;
			}else{
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

}


import java.util.*;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int y=sc.nextInt();
		for(int i=0; i<=n; i++) {
			for(int j=0; j<=n; j++) {
				if(i+j>n) continue;
				for(int k=0; k<=n; k++) {
					if(i+j+k>n) continue;
					if(10000*i + 5000*j + 1000*k == y) {
						System.out.println(i+" "+j+" "+k);
						sc.close();
						return;
					}
				}
			}
		}
		System.out.println("-1 -1 -1");
		sc.close();
	}
}


import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int y = sc.nextInt();
        for(int i = 0 ; i < n ; i ++){
        	for(int j = 0 ; j < n-i ; j ++){
            	int k = n-i-j;
                	if(y == 10000*i + 5000*j + 1000*k){
                    	System.out.println(i + " " + j + " " + k);
                      	return;
                    }

            }
        }
      	System.out.println("-1 -1 -1");

    }
}


import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int y = sc.nextInt();
        for(int i = 0 ; i < n ; i ++){
        	for(int j = 0 ; j < n-i ; j ++){
            	for(int k = 0 ; k < n-i-j ; k++){
                	if(n == 10000*i + 5000*j + 1000*k){
                    	System.out.println(i + " " + j + " " + k);
                      	return;
                    }
                }
            }
        }
      	System.out.println("-1 -1 -1");

    }
}


#include <bits/stdc++.h>
using namespace std;

int main() {
  int n,y;
  cin >> n >> y;

  int flg = 0;

  int p,q;

  for(int i=0; i<=y/10000; i++){
    if((y-10000*i-1000*(n-i)) % 4000 != 0 || (5000 * (n-i) - y + 10000 * i ) % 4000 != 0){
      continue;
    }
    p = (y - 10000 * i - 1000 * (n-i))/4000;
    q = (5000 * (n-i) - y + 10000 * i)/4000;
    if (p>=0 && q>=0){
      flg = 1;
      break;
    }
  }

  if (flg == 0){
    cout << -1 << " " << -1 << " " << -1 << endl;
  }else{
    cout << n-p-q << " " << p << " " << q << endl;
  }
}


#include <iostream>

using namespace std;

int main(){
    int N, Y;
    cin >> N >> Y;

    int n_1, n_5, n_10;

    int y = Y / 1000;

    n_10 = (y - N) / 9;
    n_5 = 10000009;

    int flag = 0;

    while(true){
        if(n_10 < 0){
            flag = 1;
            break;
        }

        if((y - N - 9 * n_10) % 4 == 0){
            n_5 = (y - N - 9 * n_10) / 4;
            break;
        } else {
            --n_10;
        }
    }

    n_1 = N - n_5 - n_10;

    if(flag == 1 | n_1 < 0 | n_5 < 0 | n_10 < 0){
        n_1 = -1; n_5 = -1; n_10 = -1;
    }

    cout << n_10 << " " << n_5 << " " << n_1 << endl;
//    cout << "sum = " << n_10 * 10000 + n_5 * 5000 + n_1 * 1000 << endl;
    return 0;

}


#include "iostream"
using namespace std;

int main() {
  int n, y;
  cin >> n >> y;
  y /= 1000;
  bool check = false;
  if (n == y) cout << 0 << " " << 0 << " " << n << endl;
  else {
    for (int i = y % 5; i < y; i += 5) {
      if (5 * (n - i) <= y - i && y - i <= 10 * (n - i)) {
        cout <<  ((y - i) - 5 * (n - i)) / 5  << " " << (10 * (n - i) - (y - i)) / 5 << " " << i << endl;
        check = true;
        break;
      }
    }
    if (check == 0) {
      cout << -1 << " " << -1 << " " << -1 << endl;
    }
  }
}


#pragma warning(disable:4996)
#include<iostream>
#include<algorithm>
#include<memory.h>
#include<string>
using namespace std;
typedef long long ll;
const int Max = 1e5 + 5;

int main()
{
	int n, y;
	cin >> n >> y;
	int f = 0;
	for (int i = 0; i <= y / 10000; i++)
	{
		for (int j = 0; j <= y / 5000; j++)
		{
			if (i + j > 0)continue;
			if ((n - i - j) * 1000 + i * 10000 + 5000 * j == y)
			{
				cout << i << " " << j << " " << n - i - j;
				return 0;
			}
		}
	}
	if (f == 0)cout << -1 << " " << -1 << " " << -1;
}


#pragma warning(disable:4996)
#include<iostream>
#include<algorithm>
#include<memory.h>
#include<string>
using namespace std;
typedef long long ll;
const int Max = 1e5 + 5;

int main()
{
	int n, y;
	cin >> n >> y;
	for (int i = 0; i <= y / 10000; i++)
	{
		for (int j = 0; j <= y / 5000; j++)
		{
			if (i + j > 0)continue;
			if ((n - i - j) * 1000 + i * 10000 + 5000 * j == y)
			{
				cout << i << " " << j << " " << n - i - j;
				return 0;
			}
		}
	}
}


#pragma warning(disable:4996)
#include<iostream>
#include<algorithm>
#include<memory.h>
#include<string>
using namespace std;
typedef long long ll;
const int Max = 1e5 + 5;

int main()
{
	int n, y;
	cin >> n >> y;
	for (int i = 0; i <= y / 10000; i++)
	{
		for (int j = 0; j <= y / 5000; j++)
		{
			if ((n - i - j) * 1000 + i * 10000 + 5000 * j == y)
			{
				cout << i << " " << j << " " << n - i - j;
				return 0;
			}
		}
	}
}


#include <stdio.h>
#include <stdlib.h>

int main (void){
        int N,Y,now,man=0,gosen=0,sen=0;
        scanf("%d %d",&N,&Y);
        if (N*10000<Y||N*1000>Y) {
                printf("-1 -1 -1");
                return 0;
        }
        now=(Y-N*1000)/1000;
        man=now/9;
        now=now%9;
        gosen=now/4;
        now=now%4;
        while (now!=0) {
                man--;
                now+=9;
                while (now>0) {
                        gosen++;
                        now-=4;
                }
        }
        sen=N-gosen-man;
        if (sen<0||man<0||gosen<0) {
                printf("-1 -1 -1");
                return 0;
        }
        printf("%d %d %d",man,gosen,sen);
        return 0;
}


#include<stdio.h>
#include<limits.h>

int main(){
	int i,j,k,N,Y;
	int mannum,gosennum,sennum;
	int endflag = 0;

	scanf("%d",&N);
	scanf("%d",&Y);

	mannum = Y / 10000;
	gosennum = (Y - mannum*10000) / 5000;
	sennum = (Y - mannum*10000 - gosennum*5000) / 1000;

	for(i = mannum;i >= 0;i --){

		gosennum = (Y - i*10000) / 5000;

		for(j = gosennum; j >= 0;j--){
			k = (Y - i*10000 - j*5000) / 1000;
			if( ( (i*10000 + j*5000 + k*1000) == Y ) && ( (i+j+k) == N ) ){
				endflag =1;
				break;
			}
			if( (i+j+k) > N )break;
		}

		if(endflag == 1)break;

	}

	if( ( (i*10000 + j*5000 + k*1000) == Y ) && ( (i+j+k) == N ) ){
		printf("%d %d %d\n",i,j,k);
	}else printf("-1 -1 -1\n");

	return 0;
}


#include<stdio.h>
#include<math.h>

int calc(int x,int N,int Y){
    double y,z;
    y = (Y-1000*N-9000*x)/4000.0;
    z = (5000*x+5000*N-Y)/4000.0;
    //printf("%f,%f\n",y,z);
    if(ceil(y)!=floor(y)||ceil(z)!=floor(z)){
        return -1;
    }
    if(y<0 || z<0){
        return -1;
    }
    if(x+y+z!=N){
        return -1;
    }
    return y;
}

int main(void){
    int N,Y,y;
    scanf("%d %d",&N,&Y);
    for(int i=0;i<=N;i++){
        y = calc(i,N,Y);
        if(y!=-1){
            printf("%d %d %d",i,y,N-i-y);
            return 0;
        }
    }
    printf("-1 -1 -1");
    return 0;
}


#include <stdio.h>
int main(void){
  int n,y,i,j,k;
  int ans10000,ans5000,ans1000;
  scanf("%d %d",&n,&y);
  for(i=0;i<=n;i++){
    for(j=0;j<=n;j++){
        k=n-i-j;
      if(i+j<n && 10000*i+5000*j+1000*k==y){
          ans10000=i;
          ans5000=j;
          ans1000=k;
          printf("%d %d %d \n",ans10000,ans5000,ans1000);
          return 0;
      }else if(i+j>=n && 10000*i+5000*j==y){
        ans10000=i;
        ans5000=j;
        ans1000=0;
        printf("%d %d %d \n",ans10000,ans5000,ans1000);
        return 0;
      }
    }
  }
  printf("%d %d %d",-1,-1,-1);
  return 0;
}


#include<stdio.h>

int main(){
  int N,Y,i,j,ans=0;
  scanf("%d%d",&N,&Y);
  Y/=1000;

  for (i = 0; i <= N; i++){
    for ( j = 0; j <= N-(i*5); j++)
    {
      if(Y==((N-j-i)*10+(i*5)+j)){
        ans=1;
        break;
      }
    }
    if (ans==1){break;}
  }

  ans > 0 ?  printf("%d %d %d",N-i-j,i,j):puts("-1 -1 -1");

  return 0;
}


import sys

def main():
    N, Y = [int(_) for _ in input().split()]

    for n_10k in range(N+1):
        for n_5k in range(N - n_10k + 1):
            n_1k = N - n_10k - n_5k

            if n_10k * 10000 + n_5k * 5000 + n_1k * 1000 == Y:
                print(n_10k, n_5k, n_1k)
                sys.exit()

    print(-1,-1,-1)

main()


'use strict'
const inputs = require('fs').readFileSync(0, 'utf8').split(' ')
const n = inputs[0]
const y = inputs[1]
for (let j = 0;j <= 8;j++) {
  const remain = y - 5000 * j
  if (remain < 0) break
  const man = (remain - 1000 * (n - j)) / 9000
  if (Number.isInteger(man) && man >= 0 && n - j - man >= 0) return console.log(man, j, n - j - man)
}
return console.log(-1, -1, -1)


// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
    var raw = input[0].split(" ");
    var N = parseInt(raw[0],10);
    var Y = parseInt(raw[1],10);
    var W = Y/1000;
    var flag = false;
    for(var z=0; z<=N; z++){
      var A = W-z
      if(A%5!==0) continue;
      var M = N-z;
      if(10*M >= A && A >= 5*M) {
        flag = true;
        var y = (10*M-A)/5;
        var x = M-y;
        console.log('%d %d %d',x,y,z);
        break;
      }
    }
    if(!flag) {
       console.log('%d %d %d',-1,-1,-1);
    }

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


function main(input) {
  const input_array = input.split(' ');
  const sum_price = input_array[1];
  const paper_money_count = input_array[0];

  for(count_10000=0; count_10000<=paper_money_count ;count_10000++){
    maximum_price = 10000 * count_10000 + 5000 * (paper_money_count - count_10000);
    minimum_price = 10000 * count_10000 + 1000 * (paper_money_count - count_10000);
    if(sum_price > maximum_price || sum_price < minimum_price){
      continue;
    }
    for(count_5000=0; count_5000<=paper_money_count - count_10000 ;count_5000++){
      count_1000 = paper_money_count - (count_10000 + count_5000)
      if(count_10000 * 10000 + count_5000 * 5000 + count_1000 * 1000 == sum_price){
        console.log(`${count_10000} ${count_5000} ${count_1000}`);
        return;
      }
    }
  }

  console.log('-1 -1 -1');
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function spilitInput(input) {
  var splited = [];
  var rows = input.split('\n');
  for (var i = 0; i < rows.length; i += 1) {
    splited.push(rows[i].split(' '));
  }
  return splited;
}
function Main(input) {
  var splited = spilitInput(input);
  var N = splited[0][0];
  var Y = splited[0][1];
  var ax = 10000;
  var ay = 5000;
  var az = 1000;
  var x = -1;
  var y = -1;
  var z = -1;
  var hit = false;

  for(var iz = 0; iz <= N && !hit; iz += 1) {
  for(var iy = 0; iy <= N && !hit; iy += 1) {
    var ix = N - iz - iy;
    var total = (ax*ix)+(ay*iy)+(az*iz);
    if (total == Y) {
      x = ix;
      y = iy;
      z = iz;
      hit = true;
    }
  }
  }
  console.log(x+' '+y+' '+z);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


function spilitInput(input) {
  var splited = [];
  var rows = input.split('\n');
  for (var i = 0; i < rows.length; i += 1) {
    splited.push(rows[i].split(' '));
  }
  return splited;
}
function Main(input) {
  var splited = spilitInput(input);
  var N = splited[0][0];
  var Y = splited[0][1];
  var ax = 10000;
  var ay = 5000;
  var az = 1000;
  var x = -1;
  var y = -1;
  var z = -1;

  x = Math.floor(Y / ax);
  Y = (Y - (ax * x));

  y = Math.floor(Y / ay);
  Y = (Y - (ay * y));

  z = Math.floor(Y / az);
  Y = (Y - (az * z));

  if (Y == 0 && (x+y+z) == N) {
    console.log(x+' '+y+' '+z);
  } else {
    console.log('-1 -1 -1');
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


function spilitInput(input) {
  var splited = [];
  var rows = input.split('\n');
  for (var i = 0; i < rows.length; i += 1) {
    splited.push(rows[i].split(' '));
  }
  return splited;
}
function Main(input) {
  var splited = spilitInput(input);
  var N = splited[0][0];
  var Y = splited[0][1];
  var ax = 10000;
  var ay = 5000;
  var az = 1000;
  var x = -1;
  var y = -1;
  var z = -1;

  x = (Y / ax);
  Y = (Y - (ax * x));

  y = (Y / ay);
  Y = (Y - (ay * y));

  z = (Y / az);
  Y = (Y - (az * z));

  if (Y == 0) {
    console.log(x+' '+y+' '+z);
  } else {
    console.log('-1 -1 -1');
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`
				`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	//fmt.Fprintln(out, "[DEBUG]", time.Now())
	//https://atcoder.jp/contests/abc165/tasks/abc165_f
	//https://www.dropbox.com/sh/nx3tnilzqz7df8a/AAA0887IQFx5BcrZcrpRD7uga/ABC165/F?dl=0&subfolder_nav_tracking=1

	n := nextInt()
	yen := nextInt()

	x := -1
	y := -1
	z := -1

	for i := 0; i <= yen/1000; i++ {
		xx := yen + 4000*i - 5000*n
		yy := 10000*n - 9000*i - yen
		if xx >= 0 && xx%5000 == 0 && yy >= 0 && yy%5000 == 0 {
			x = xx / 5000
			y = yy / 5000
			z = i
			break
		}
	}
	fmt.Fprintln(out, x, y, z)

	//	fmt.Fprintln(out, "[DEBUG]]", a)
	//fmt.Fprintln(out, ans)
}

//------------------------------------------------------------------------------

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}


package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"math"
	"os"
	"strconv"
)

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

func main() {
	N := getInt()
	Y := getInt()

	tmpX := Y/10000
	tmpY := (Y%10000)/5000
	tmpZ := ((Y%10000)%5000)/1000
	total := tmpX + tmpY + tmpZ

	if N < total || Y/1000 < N {
		fmt.Println(-1, -1, -1)
		return
	}

	if total == N {
		fmt.Println(tmpX, tmpY, tmpZ)
		return
	}

	for ; ; {
		if total < N {
			if N - total >= 4 && tmpY >= 1 {
				tmpY--
				tmpZ += 5
			} else if tmpX >= 1 {
				tmpX--
				tmpY += 2
			}
		} else {
			if total - N >= 4 && tmpZ >= 5 {
				tmpY++
				tmpZ -= 5
			} else if tmpY >= 2 {
				tmpX++
				tmpY -= 2
			}
		}

		before := total
		total = tmpX + tmpY + tmpZ

		if before == total {
			tmpX = -1
			tmpY = -1
			tmpZ = -1
			break
		}

		if total == N {
			break
		}
	}

	fmt.Println(tmpX, tmpY, tmpZ)
}

type Graph struct {
	n     int
	edges [][]int
}

func NewGraph(n int) *Graph {
	g := &Graph{
		n:     n,
		edges: make([][]int, n),
	}
	return g
}

func (g *Graph) AddEdge(u, v int) {
	g.edges[v] = append(g.edges[v], u)
	g.edges[u] = append(g.edges[u], v)
}

func dfs(c int, edges [][]int, visited map[int]struct{}) {
	visited[c] = struct{}{}

	for _, v := range edges[c] {
		_, flag := visited[v]
		if flag {
			continue
		}
		dfs(v, edges, visited)
	}
}

func bfs(c int, graph *Graph) {
	next := make([]int, 0)
	next = append(next, c)
	visited := make(map[int]struct{})

	for ; len(next) != 0; {
		u := next[0]
		next = next[1:]
		visited[u] = struct{}{}

		for _, v := range graph.edges[u] {
			_, flag := visited[v]
			if flag {
				continue
			}

			// なにか処理

			next = append(next, v)
		}
	}
}

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getIntArray(n int) []int {
	array := make([]int, n)
	for i := 0; i < n; i++ {
		array[i] = getInt()
	}
	return array
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func getStringArray(n int) []string {
	array := make([]string, n)
	for i := 0; i < n; i++ {
		array[i] = getString()
	}
	return array
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func powMod(n, p int) int {
	if p == 0 {
		return 1
	} else if p%2 == 0 {
		t := powMod(n, p/2)
		return calcMod(t * t)
	} else {
		return calcMod(n * powMod(n, p-1))
	}
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray)-1])
}

func calcMod(x int) int {
	return x % mod
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func isPrime(n int) bool {
	if n < 2 {
		return false
	} else if n == 2 {
		return true
	} else if n % 2 == 0 {
		return false
	}

	sqrtN := int(math.Sqrt(float64(n)))
	for i := 3; i <= sqrtN; i += 2 {
		if n % i == 0 {
			return false
		}
	}

	return true
}

func contains(s []int, e int) bool {
	for _, v := range s {
		if e == v {
			return true
		}
	}
	return false
}

func makeRange(min, max int) []int {
	a := make([]int, max-min+1)
	for i := range a {
		a[i] = min + i
	}
	return a
}

func powerset2(nums []int) [][]int {
	length := int(math.Pow(2, float64(len(nums))))
	result := make([][]int, length)

	index := 0
	result[index] = []int{}
	index++

	for _, n := range nums {
		max := index
		for i := 0; i < max; i++ {
			result[index] = copyAndAppend(result[i], n)
			index++
		}
	}

	return result
}

func copyAndAppend(nums []int, n int) []int {
	dst := make([]int, len(nums)+1)
	copy(dst, nums)
	dst[len(nums)] = n
	return dst
}

func calcGcd(x, y int) int {
	if y == 0 {
		return x
	} else if x >= y {
		return calcGcd(y, x % y)
	} else {
		return calcGcd(x, y % x)
	}
}

func getDivisor(n int) []int {
	var divisor []int
	divisor = append(divisor, 1)
	if n != 1 {
		divisor = append(divisor, n)
	}

	sqrt := int(math.Sqrt(float64(n)))
	for i := 2; i <= sqrt; i++ {
		if n % i == 0 {
			divisor = append(divisor, i)
			divisor = append(divisor, n/i)
		}
	}
	return divisor
}

type intHeap []int

func (h intHeap) Len() int {
	return len(h)
}

func (h intHeap) Less(i, j int) bool {
	return h[i] > h[j]
}

func (h intHeap) Swap(i, j int) {
	h[i], h[j] = h[j], h[i]
}

func (h *intHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *intHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func initHeap() *intHeap {
	ih := &intHeap{}
	heap.Init(ih)
	return ih
}

func (h *intHeap) pushHeap(n int) {
	heap.Push(h, n)
}

func (h *intHeap) popHeap() int {
	return heap.Pop(h).(int)
}

func factMod(n int) int {
	value := 1
	for ; n > 1; n-- {
		value = calcMod(value * n)
	}
	return value
}

func combinationMod(n, k int) int {
	factN := factMod(n)
	factK := factMod(k)
	factNK := factMod(n - k)
	factKR := powMod(factK, mod - 2)
	factNKR := powMod(factNK, mod - 2)
	return calcMod(factN * calcMod(factKR * factNKR))
}


// ABC085C - Otoshidama
package main

import "fmt"

func main() {
	var N, sum int
	fmt.Scanf("%d %d", &N, &sum)
	sum /= 1000

	// 10, 5, 1
	var n10, n5, n1 int

	n1 = sum % 5
	N -= n1
	sum -= n1

	// n10 * 10 + n5 * 5 = sum
	// n10 + n5 = N
	// n10 = sum/5 - N
	// n5  = 2N - sum/5

	for N >= 0 {
		n10 = sum/5 - N
		n5 = 2*N - sum/5

		if n1 >= 0 && n5 >= 0 && n10 >= 0 {
			fmt.Printf("%d %d %d\n", n10, n5, n1)
			return
		}

		n1 += 5
		N -= 5
		sum -= 5
	}

	fmt.Println("-1 -1 -1")
}


import "fmt"

func main() {
	var N, Y int
	fmt.Scan(&N, &Y)

	for i := 0; i < N; i++ {
		for j := 0; j <= N-i; j++ {
			if 10000*i+5000*j+1000*(N-i-j) == Y {
				fmt.Printf("%v %v %v\n", i, j, N-i-j)
				return
			}
		}
	}
	fmt.Println(-1, -1, -1)
}


package main

import "fmt"

func main() {
	var N, Y int
	fmt.Scan(&N, &Y)

	for i := 0; i < N; i++ {
		for j := 0; j <= N-i; j++ {
			if 10000*i+5000*j+1000*(N-i-j) == Y {
				fmt.Println(i, j, N-i-j)
				return
			}
		}
	}
	fmt.Println(-1, -1, -1)
}


import "fmt"

func main() {
	var N, Y int
	fmt.Scan(&N, &Y)

	for i := 0; i < N; i++ {
		for j := 0; j < N-i; j++ {
			if 10000*i+5000*j+1000*(N-i-j) == Y {
				fmt.Println(i, j, N-i-j)
			}
		}
	}
	fmt.Println(-1, -1, -1)
}


n, y = gets.split.map(&:to_i)

y/=1000
y-=n # 全部千円の場合の不足額

if y < 0
  puts [-1,-1,-1] * " "
  exit
end

if y == 0
  puts [0,0,n] * " "
  exit
end

# p y
m=y%4; y-=9*m # 万札必要量
if y < 0
  puts [-1,-1,-1] * " "
  exit
end
m+=y/36*4; y%=36 # 万札貪欲
g=y/4 # 五千円札
s=n-m-g # 残りが千円札
ans = s < 0 ? [-1,-1,-1] : [m, g, s]
puts ans * " "


n, y = gets.split.map(&:to_i)

y/=1000
y-=n # 全部千円の場合の不足額

if y < 0
  puts [-1,-1,-1] * " "
  exit
end

# p y
m=y%4; y-=9*m # 万札必要量
if y < 0
  puts [-1,-1,-1] * " "
  exit
end
m+=y/36*4; y%=36 # 万札貪欲
g=y/4 # 五千円札
s=n-m-g # 残りが千円札
ans = s < 0 ? [-1,-1,-1] : [m, g, s]
puts ans * " "


N,Y=gets.split.map &:to_i
Y/=1000

L=[(Y-2*N)/4.to_f,2*(Y-N)/9.to_f,(-Y-N)/5.to_f].max.ceil
H=[(Y-N)/4,(2*Y-N)/9,Y/5].min.floor

if H<L
  print("-1 -1 -1")
else
x=-4*H+Y-N
y=9*H-2*Y+2*N
z=-5*H+Y
print(x," ",y," ",z)
end


n,y=gets.split.map(&:to_i)
a,b,c=-1,-1,-1
(0..n).each do |i|
  (0..n).each do |j|
    a,b,c=n-i-j,j,i if i*1000+j*5000+(n-i-j)*10000==y
  end
end
puts [a,b,c].join ' '


n,y=gets.split.map(&:to_i)
a,b,c=-1,-1,-1
(0..n).each do |i|
  (0..n).each do |j|
    if i*1000+j*5000+(n-i-j)*10000==y
      a,b,c=n-i-j,j,i
      break
    end
  end
end
puts [a,b,c].join ' '


n,y=gets.split.map(&:to_i)
a,b,c=-1,-1,-1
(0..n).each do |i|
  (0..n).each do |j|
    if i*1000+j*5000+(n-i-j)*10000==y
      a,b,c=n-i-j,j,i
      break
    end
  end
end
puts [c,b,a].join ' '