use std::io;
use std::io::BufRead;

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

    lines.next().unwrap().unwrap();

    let mut first_list = [false; 10];
    let mut second_list = [false; 10];

    lines.next().unwrap().unwrap().split(" ")
        .map(|x| x.parse::<usize>().unwrap())
        .for_each(|x| first_list[x] = true);
    lines.next().unwrap().unwrap().split(" ")
        .map(|x| x.parse::<usize>().unwrap())
        .for_each(|x| second_list[x] = true);

    let mut min_first = 10;
    let mut min_second = 10;

    for i in 1..10 {
        if first_list[i] && second_list[i] {
            println!("{}", i);
            return;
        }
        if first_list[i] && min_first > i {
            min_first = i;
        }
        if second_list[i] && min_second > i {
            min_second = i;
        }
    }

    let result = if min_first > min_second {
        min_second * 10 + min_first
    } else {
        min_first * 10 + min_second
    };

    println!("{}", result);

}

use std::boxed::Box;
use std::cmp::*;
use std::io;

struct Rand {
    state: u64,
}

impl Rand {
    pub fn new() -> Self {
        Rand { state: 13 }
    }

    pub fn rand(&mut self) -> u64 {
        self.state = ((self.state ^ 1000000007) * 10000009) % 1000000013;
        self.state
    }
}

#[derive(Clone)]
struct Node<T: Ord + Clone> {
    pub key: T,
    pub weight: u64,
    pub left: Option<Box<Node<T>>>,
    pub right: Option<Box<Node<T>>>,
}

impl<T: Ord + Clone> Node<T> {
    fn new(value: T, weight: u64) -> Self {
        Node {
            key: value,
            weight: weight,
            left: None,
            right: None,
        }
    }

    pub fn split(
        node: Option<Box<Node<T>>>,
        key: &T,
    ) -> (Option<Box<Node<T>>>, Option<Box<Node<T>>>) {
        match node {
            None => (None, None),
            Some(mut node) => match node.key.cmp(key) {
                Ordering::Less => {
                    let (l, r) = Self::split(node.right, key);
                    node.right = l;
                    (Some(node), r)
                }
                _ => {
                    let (l, r) = Self::split(node.left, key);
                    node.left = r;
                    (l, Some(node))
                }
            },
        }
    }

    pub fn merge(left: Option<Box<Node<T>>>, right: Option<Box<Node<T>>>) -> Option<Box<Node<T>>> {
        match (left, right) {
            (None, None) => None,
            (left, None) => left,
            (None, right) => right,
            (Some(mut left), Some(mut right)) => match left.weight.cmp(&right.weight) {
                Ordering::Less => {
                    left.right = Self::merge(left.right, Some(right));
                    Some(left)
                }
                _ => {
                    right.left = Self::merge(Some(left), right.left);
                    Some(right)
                }
            },
        }
    }

    fn find(node: &Option<Box<Node<T>>>, key: &T) -> bool {
        match node {
            None => false,
            Some(node) => match node.key.cmp(key) {
                Ordering::Less => Self::find(&node.right, key),
                Ordering::Greater => Self::find(&node.left, key),
                Ordering::Equal => true,
            },
        }
    }

    fn less(node: &Box<Node<T>>) -> T {
        match node.left {
            None => node.key.clone(),
            Some(ref left) => Self::less(left),
        }
    }
}

struct Treap<T: Ord + Clone> {
    root: Option<Box<Node<T>>>,
}

impl<T: Ord + Clone + std::fmt::Display> Treap<T> {
    pub fn insert(&mut self, key: T, weight: u64) {
        let (mut l, r) = Node::split(self.root.take(), &key);
        l = Node::merge(l, Some(Box::new(Node::new(key, weight))));
        self.root = Node::merge(l, r);
    }

    pub fn delete(&mut self, key: &T) {
        let (l, mut r) = Node::split(self.root.take(), key);
        r = match r {
            None => None,
            Some(node) => {
                if &node.key == key {
                    Node::merge(node.left, node.right)
                } else {
                    Some(node)
                }
            }
        };
        self.root = Node::merge(l, r);
    }

    pub fn find(&self, key: &T) -> bool {
        Node::find(&self.root, key)
    }

    pub fn less(&self) -> Option<T> {
        match self.root {
            Some(ref root) => Some(Node::less(root)),
            _ => None,
        }
    }

    pub fn new() -> Self {
        Treap { root: None }
    }
}

fn main() {
    let mut buffer = String::new();
    let mut rand = Rand::new();
    io::stdin().read_line(&mut buffer);
    buffer = String::new();
    io::stdin().read_line(&mut buffer);
    buffer.retain(|s| s != '\r' && s != '\n');
    let a: Vec<u64> = buffer
        .split_whitespace()
        .map(|n| n.parse::<u64>().unwrap())
        .collect();

    buffer = String::new();
    io::stdin().read_line(&mut buffer);
    buffer.retain(|s| s != '\r' && s != '\n');
    let b: Vec<u64> = buffer
        .split_whitespace()
        .map(|n| n.parse::<u64>().unwrap())
        .collect();

    let mut t1 = Treap::new();
    let mut t2 = Treap::new();
    //println!("{:?} | {:?}", &a, &b);
    for n in a {
        t1.insert(n, rand.rand() as u64);
    }
    let mut m3 = 99;
    for n in b {
        t2.insert(n, rand.rand() as u64);
        if t1.find(&n) {
            m3 = std::cmp::min(m3, n);
        }
    }
    let (m1, m2) = (t1.less().unwrap(), t2.less().unwrap());

    if m1 != m2 && m3 < 99 {
        println!("{}", m3);
    } else {
        match m1.cmp(&m2) {
            Ordering::Less => println!("{}{}", m1, m2),
            Ordering::Greater => println!("{}{}", m2, m1),
            Ordering::Equal => println!("{}", m2),
        }
    }
}

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

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

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

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

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

    #[allow(dead_code)]
    pub fn get2<T: FromStr, U: FromStr>() -> (T, U)
    where
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }

    #[allow(dead_code)]
    pub fn get3<S: FromStr, T: FromStr, U: FromStr>() -> (S, T, U)
    where
        <S as FromStr>::Err: Debug,
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }
}

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

fn main() {
    let (_n, _m): (usize, usize) = util::get2();
    let a: HashSet<usize> = util::gets().iter().cloned().collect();
    let b: HashSet<usize> = util::gets().iter().cloned().collect();

    for i in 1..100 {
        if i < 10 {
            if a.contains(&i) && b.contains(&i) {
                println!("{}", i);
                return;
            }
        } else {
            if (a.contains(&(i / 10)) || a.contains(&(i % 10))) &&
                (b.contains(&(i / 10)) || b.contains(&(i % 10)))
            {
                println!("{}", i);
                return;
            }
        }
    }
}

use std::io::{self, BufReader, Stdin};
use std::io::prelude::*;
use std::collections::BTreeSet;
use std::iter::Map;
use std::str::SplitWhitespace;

fn main() {
    let mut reader = ReadIn::new();

    reader.read_line();
    let a: BTreeSet<i32> = reader.read_iter().collect();
    let b: BTreeSet<i32> = reader.read_iter().collect();
    let c: BTreeSet<i32> = a.intersection(&b).map(|&x| x).collect();
    let res = (if !c.is_empty() { c.iter().map(|&x| x).next() } else {
        a.iter().next().and_then(
            |&ax| b.iter().next().map(
                |&bx| if (ax < bx) { ax * 10 + bx } else { bx * 10 + ax }))
    }).unwrap();
    print!("{}", res);
}

struct ReadIn { reader: BufReader<Stdin>, buf: String }

impl ReadIn {
    fn new() -> ReadIn { ReadIn { reader: BufReader::new(io::stdin()), buf: String::new() } }
    fn read_i32(s: &str) -> i32 { s.parse().unwrap() }
    fn read_line(&mut self) {
        self.buf.clear();
        self.reader.read_line(&mut self.buf);
    }
    fn read_iter(&mut self) -> Map<SplitWhitespace, fn(&str) -> i32> {
        self.read_line();
        self.buf.split_whitespace().map(ReadIn::read_i32)
    }
    fn read_vec(&mut self) -> Vec<i32> {
        self.read_iter().collect()
    }
}

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

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

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

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

const N: i64 = 998_244_353;

fn extended_euclid(a: i64, b: i64) -> (i64, i64, i64) {
    if b == 0 {
        (a, 1, 0)
    } else {
        let (d0, x0, y0) = extended_euclid(b, a % b);
        (d0, y0, x0 - a / b * y0)
    }
}

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

    let f_v: Vec<usize> = get_vec();
    let s_v: Vec<usize> = get_vec();

    let first_list = f_v.into_iter()
        .fold(vec![false; 9], |mut acc, d| {
            acc[d - 1] = true;
            acc
        });

    let second_list = s_v.into_iter()
        .fold(vec![false; 9], |mut acc, d| {
            acc[d - 1] = true;
            acc
        });

    if let Some(i) = (0..first_list.len()).filter(|&i| first_list[i] && second_list[i]).min() {
        println!("{}", i + 1);
    } else {
        let f = first_list.into_iter().position(|p| p).unwrap() + 1;
        let s = second_list.into_iter().position(|p| p).unwrap() + 1;
        print!("{}", min(f, s));
        println!("{}", max(f, s));
    }
}

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

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

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

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

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

    #[allow(dead_code)]
    pub fn get2<T: FromStr, U: FromStr>() -> (T, U)
    where
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }

    #[allow(dead_code)]
    pub fn get3<S: FromStr, T: FromStr, U: FromStr>() -> (S, T, U)
    where
        <S as FromStr>::Err: Debug,
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }
}

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

fn main() {
    let (_n, _m): (usize, usize) = util::get2();
    let a: HashSet<usize> = util::gets().iter().cloned().collect();
    let b: HashSet<usize> = util::gets().iter().cloned().collect();

    for i in 1..99 {
        if i < 10 {
            if a.contains(&i) && b.contains(&i) {
                println!("{}", i);
                return;
            }
        } else {
            if a.contains(&(i / 10)) && b.contains(&(i % 10)) {
                println!("{}", i);
                return;
            }
        }
    }
}

use std::io::{self, BufReader, Stdin};
use std::io::prelude::*;
use std::collections::BTreeSet;
use std::iter::Map;
use std::str::SplitWhitespace;

fn main() {
    let mut reader = ReadIn::new();

    reader.read_line();
    let a: BTreeSet<i32> = reader.read_iter().collect();
    let b: BTreeSet<i32> = reader.read_iter().collect();
    let c: BTreeSet<i32> = a.intersection(&b).map(|&x| x).collect();
    let res = (if !c.is_empty() { c.iter().map(|&x| x).next() } else {
        a.iter().next().and_then(
            |ax| b.iter().next().map(
                |bx| ax * 10 + bx))
    }).unwrap();
    print!("{}", res);
}

struct ReadIn { reader: BufReader<Stdin>, buf: String }

impl ReadIn {
    fn new() -> ReadIn { ReadIn { reader: BufReader::new(io::stdin()), buf: String::new() } }
    fn read_i32(s: &str) -> i32 { s.parse().unwrap() }
    fn read_line(&mut self) {
        self.buf.clear();
        self.reader.read_line(&mut self.buf);
    }
    fn read_iter(&mut self) -> Map<SplitWhitespace, fn(&str) -> i32> {
        self.read_line();
        self.buf.split_whitespace().map(ReadIn::read_i32)
    }
    fn read_vec(&mut self) -> Vec<i32> {
        self.read_iter().collect()
    }
}


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

fn main() {
    let mut counter = 0;
    let mut col_checked = false;

    for i in 0..8 {
        let mut input_text = String::new();
        io::stdin()
            .read_line(&mut input_text)
            .expect("failed to read from stdin");

        let trimmed = input_text.trim();
        if (trimmed.eq("BBBBBBBB")) {
            counter = counter + 1;
            continue;
        }

        if (col_checked) {
            continue;
        }

        col_checked = true;
        for j in 0..8 {
            let char_at = trimmed.as_bytes()[j];
            if ((char_at as char) == 'B') {
                counter = counter + 1;
            }
        }
    }

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

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

const W: char = 'W';
const B: char = 'B';

fn parse_problem<B: BufRead>(input: B) -> io::Result<[[u8; 8]; 8]> {
    let mut matrix = [[0; 8]; 8];
    for (i, maybe_line) in input.lines().enumerate().take(8) {
        let line = maybe_line?;
        for (j, c) in line.chars().enumerate().take(8) {
            match c {
                B => matrix[i][j] = 1,
                W => {},
                _ => return Err(io::Error::new(io::ErrorKind::InvalidInput,
                                               "not a B or W")),
            }
        }
    }
    Ok(matrix)
}

fn main() -> io::Result<()> {
    let board = parse_problem(io::stdin().lock())?;
    let mut r: u32 = 0;
    let mut c: u32 = 0;
    'outer_row: for i in 0..8 {
        for j in 0..8 {
            if board[i][j] == 0 {
                continue 'outer_row;
            }
        }
        r += 1;
    }
    'outer_col: for j in 0..8 {
        for i in 0..8 {
            if board[i][j] == 0 {
                continue 'outer_col;
            }
        }
        c += 1;
    }
    let result = if r < 8 && c < 8 { r + c } else { 8 };
    println!("{}", result);
    Ok(())
}

macro_rules! scanln {
    () => ({
        let mut buffer = String::new();
        ::std::io::stdin().read_line(&mut buffer).expect("Unable to read line");
        buffer
    });
    ($($t: ty),+) => ({
        scanln!($($t),+, |c: char| c.is_whitespace())
    });
    ($($t: ty),+, $sp: expr) => ({
        let mut buffer = scanln!();
        let mut iter = buffer.split($sp);
        ($(iter.next().unwrap().parse::<$t>().expect("Unable to parse token")),+)
    });
}

fn main() {
    let mut board = Vec::new();
    let mut count = 0;
    let mut checked = false;
    for _ in 0..8 {
        let line = scanln!(String);
        let row: Vec<char> = line.split(' ').flat_map(|s| s.chars()).collect();
        board.push(row);
    }
    for r in board {
        let blacks = r.iter().filter(|c| **c == 'B').count();
        count += if blacks == 8 {
            1
        } else if blacks > 0 && !checked {
            checked = true;
            blacks
        } else {
            0
        }
    }
    println!("{}", count);
}


// Try Codeforces
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        () => (get!(i64));
        ($t:ty) => (get().parse::<$t>().unwrap());
    }

    let n = 14;
    let mut xs = vec![];
    for _ in 0..n {
        let x = get!();
        xs.push(x);
    }
    let mut ans = 0;
    for i in 0..n {
        let x = xs[i];
        let d = x / 14;
        let r = (x % 14) as usize;
        xs[i] = 0;
        let mut tmp = 0;
        for j in 0..n {
            let mut e = xs[j] + d;
            if i < j && j <= i + r {
                e += 1;
            } else if i < j + 14 && j + 14 <= i + r {
                e += 1;
            }
            if e % 2 == 0 {
                tmp += e;
            }
        }
        ans = std::cmp::max(ans, tmp);
        xs[i] = x;
    }
    println!("{}", ans);
}

fn main() {
    use std::io::prelude::*;
    use std::io;

    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();

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

    let mut max_ans = 0;

    let modulo = |a, b| {
        if a < 0 {
            a % b + b
        } else {
            a % b
        }
    };
    let modsub = |a, b| {
        modulo(a - b, 14)
    };

    for (i, &ai) in a.iter().enumerate() {
        let q = ai / 14;
        let r = ai % 14;

        let mut ans = 0;
        let mut j = i + 1;
        for _ in 0..13 {
            let cnt = a[modulo(j, 14)] + q + if r < modsub(j, i) as i64 { 0 } else { 1 };
            if cnt % 2 == 0 {
                ans += cnt;
            }

            j += 1
        }

        if q % 2 == 0 {
            ans += q;
        }

        if max_ans < ans {
            max_ans = ans;
        }
    }

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

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

fn main() {
    let stdin = stdin();
    let mut sc = Scanner::new(stdin.lock());
    let mut a: [usize; 14] = [0; 14];
    for i in 0..14 {
        a[i] = sc.next::<usize>();
    }
    let mut max: u64 = 0;
    for i in 0..14 {
        if a[i] == 0 {
            continue;
        }
        let mut b: [usize; 14] = a.clone();
        b[i] = 0;
        for j in 0..14 {
            b[(i + j + 1) % 14] += a[i] / 14 + (if j < a[i] % 14 { 1 } else { 0 });
        }

        let mut sum: u64 = 0;
        for j in 0..14 {
            if b[j] % 2 == 0 {
                sum += b[j] as u64;
            }
        }
        max = std::cmp::max(max, sum);
    }
    println!("{}", max);
}

// 基本的に 14 割った数足す

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

impl<B: BufRead> Scanner<B> {
    pub fn new(reader: B) -> Self {
        Self {
            reader,
            buffer: Vec::new(),
        }
    }

    pub fn next<T: FromStr>(&mut self) -> T
    where
        T::Err: ::std::fmt::Debug,
    {
        if let Some(front) = self.buffer.pop() {
            front.parse::<T>().expect(&front)
        } else {
            let mut input = String::new();
            self.reader.read_line(&mut input).expect("Line not read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
            self.next()
        }
    }
}

fn main() {
    use std::io::prelude::*;
    use std::io;

    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();

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

    let mut max_ans = 0;

    let modulo = |a, b| {
        if a < 0 {
            a % b + b
        } else {
            a % b
        }
    };
    let modsub = |a, b| {
        modulo(a - b, 14)
    };

    for (i, &ai) in a.iter().enumerate() {
        let q = ai / 14;
        let r = ai % 14;

        let mut ans = 0;
        let mut j = i + 1;
        for _ in 0..13 {
            let cnt = a[modulo(j, 14)] + q + if r < modsub(j, i) as i32 { 0 } else { 1 };
            if cnt % 2 == 0 {
                ans += cnt;
            }

            j += 1
        }

        if q % 2 == 0 {
            ans += q;
        }

        if max_ans < ans {
            max_ans = ans;
        }
    }

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

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

fn main() {
    let stdin = stdin();
    let mut sc = Scanner::new(stdin.lock());
    let mut a: [usize; 14] = [0; 14];
    for i in 0..14 {
        a[i] = sc.next::<usize>();
    }
    let mut max = 0;
    for i in 0..14 {
        if a[i] == 0 {
            continue;
        }
        let mut b: [usize; 14] = a.clone();
        b[i] = 0;
        for j in 0..14 {
            b[(i + j + 1) % 14] += a[i] / 14 + (if j < a[i] % 14 { 1 } else { 0 });
        }

        let mut sum = 0;
        for j in 0..14 {
            if b[j] % 2 == 0 {
                sum += b[j]
            }
        }
        max = std::cmp::max(max, sum);
    }
    println!("{}", max);
}

// 基本的に 14 割った数足す

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

impl<B: BufRead> Scanner<B> {
    pub fn new(reader: B) -> Self {
        Self {
            reader,
            buffer: Vec::new(),
        }
    }

    pub fn next<T: FromStr>(&mut self) -> T
    where
        T::Err: ::std::fmt::Debug,
    {
        if let Some(front) = self.buffer.pop() {
            front.parse::<T>().expect(&front)
        } else {
            let mut input = String::new();
            self.reader.read_line(&mut input).expect("Line not read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
            self.next()
        }
    }
}


use std::io;

fn main() {

    let mut str = String::new();

    io::stdin().read_line(&mut str).expect("You are failure");

    let mut vals = [0; 2];

    let str = str.trim().split(" ");

    let mut f = 0;
    for i in str{
        vals[f] = i.parse().expect("err");
        f+=1;
    }

    let mut printable = true;

    if vals[1] == 0 || (vals[0]%2 == vals[1]%2) || (vals[1]==1 && vals[0] != 0) || vals[1] > vals[0] + 1{
        printable = false;
    }

    println!("{}", if printable {"YES"} else {"NO"});

}

// Try Codeforces
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        () => (get().parse::<i64>().unwrap());
        ($t:ty) => (get().parse::<$t>().unwrap());
    }

    let x = get!();
    let y = get!();

    if y == 0 || (y == 1 && x > 0) || x < y - 1 {
        println!("No");
        return;
    }

    let d = x - (y - 1);

    if d % 2 != 0 {
        println!("No");
        return;
    }

    println!("Yes");

}

/*
 *
 * Author : fcbruce <fcbruce8964@gmail.com>
 *
 * Time : Sat 10 Feb 2018 18:51:25
 *
 */

fn check(copy: i32, origin: i32) -> bool {
  let y = origin - 1;
  let x = copy - y;

  return y == 0 && x == 0 || x >= 0 && y > 0 && x % 2 == 0;
}

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

  let mut numbers = buffer.split_whitespace();

  let copy:i32 = numbers.next().unwrap().parse().unwrap();
  let origin:i32 = numbers.next().unwrap().parse().unwrap();

  if check(copy, origin) {
    println!("Yes");
  } else {
    println!("No");
  }

}

/*
 *
 * Author : fcbruce <fcbruce8964@gmail.com>
 *
 * Time : Sat 10 Feb 2018 18:51:25
 *
 */
// n - c, m - o
//
// 6 3
//
// 2x + y = n
// 1 + y = m
//
// y = 2

fn check(copy: i32, origin: i32) -> bool {
  let y = origin - 1;
  let x = copy - y;

  return x >= 0 && y >= 0 && x % 2 == 0;
}

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

  let mut numbers = buffer.split_whitespace();

  let copy:i32 = numbers.next().unwrap().parse().unwrap();
  let origin:i32 = numbers.next().unwrap().parse().unwrap();

  if check(copy, origin) {
    println!("Yes");
  } else {
    println!("No");
  }

}

use std::io;

fn main() {

    let mut str = String::new();

    io::stdin().read_line(&mut str).expect("You are failure");

    let mut vals = [0; 2];

    let str = str.trim().split(" ");

    let mut f = 0;
    for i in str{
        vals[f] = i.parse().expect("err");
        f+=1;
    }

    let mut printable = true;

    if vals[1] == 0 || (vals[0]%2 == vals[1]%2) || (vals[1]==1 && vals[0] != 0) {
        printable = false;
    }

    println!("{}", if printable {"YES"} else {"NO"});

}

use std::io;

fn main() {

    let mut str = String::new();

    io::stdin().read_line(&mut str).expect("You are failure");

    let mut vals = [0; 2];

    let str = str.trim().split(" ");

    let mut f = 0;
    for i in str{
        vals[f] = i.parse().expect("err");
        f+=1;
    }

    let mut printable = true;

    if vals[1] == 0 || (vals[0]%2 == vals[1]%2) || (vals[1]==1 && vals[0] != 0) || vals[0] > vals[1] + 1{
        printable = false;
    }

    println!("{}", if printable {"YES"} else {"NO"});

}


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

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

    let n = input.u();
    let s = input.sl();
    let mut a = std::collections::HashMap::<String,i32>::new();
    for i in 0..n-1 {
        let t = String::from(&s[i..i+2]);
        let k = 1 + if let Some(&k) = a.get(&t) { k } else { 0 };
        a.insert(t, k);
    }
    let best = a.values().max().unwrap();
    let sol = a.iter().filter(|&(_,k)| best == k).next().unwrap().0;
    println!("{}", sol);
}

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

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

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

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

fn main() {
  readln!();
  let s = readln!();
  let mut ss : Vec<(char,char)>= s.chars().zip(s.chars().skip(1)).collect();
  ss.sort();
  let gg = String::new();
  let mut res = (0,gg);
  let mut i = 0;
  while i < ss.len() {
    let fr = i;
    while i < ss.len() && ss[i] == ss[fr] {
      i+=1;
    }
    let mut z = String::new();
    z.push(ss[fr].0);
    z.push(ss[fr].1);
    if (i-fr,z.clone()) > res {
      res = (i-fr,z);
    }
  }
  println!("{}",res.1);
}

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

use std::char::*;
use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::str::FromStr;

macro_rules! debug {($($a:expr),*) => {eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

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

use std::f64;

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

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

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

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

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

    fn dfs(&mut self, crt: usize) {
        if self.f[crt] { return; }
        self.c += 1;
        self.f[crt] = true;
        self.v.push(crt);
        self.vc[crt] = self.c;
        self.u[crt] = self.v.len()-1;
        for i in 0..self.e[crt].len() {
            self.dfs(self.e[crt][i]);
        }
        //debug!(crt, self.c, self.vc[crt]);
        self.vc[crt] = self.c - self.vc[crt];
    }
}

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

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

fn main() {
    //let t:usize = read();

    //'outer: for _ in 0..t {
        let n:usize = read();
        let s:Vec<char> = read::<String>().chars().collect();

        let mut v:Vec<(String,i64)> = vec![];
        for i in 0..n-1 {
            let mut t = String::new();
            t.push(s[i]);
            t.push(s[i+1]);
            let mut f = false;
            for j in 0..v.len() {
                if t == v[j].0 {
                    v[j].1 += 1;
                    f = true;
                }
            }
            if !f {
                v.push((t,1));
            }
        }

        let mut t = String::new();
        let mut mx = 0;
        for i in 0..v.len() {
            if v[i].1 > mx {
                t = v[i].0.clone();
                mx = v[i].1;
            }
        }

        println!("{}", t);

    //}
}

/*

*/

#[allow(dead_code)]
use std::cmp::min;
use std::collections::HashMap;
use std::io;
use std::str::FromStr;
use std::io::Read;

struct Input {
  tokens: <std::vec::Vec<std::string::String> as IntoIterator>::IntoIter,
  read_all: bool,
}

impl Input {
  pub fn new(read_all: bool) -> Input {
    if read_all {
      let mut all = String::new();
      io::stdin().read_to_string(&mut all).unwrap();
      let tokens: Vec<String> = all.split_whitespace().map(|s| s.to_string()).collect();
      Input {
        tokens: tokens.into_iter(),
        read_all: true,
      }
    } else {
      Input {
        tokens: vec!().into_iter(),
        read_all: false,
      }
    }
  }

  fn refresh_next_line(&mut self) {
    if self.read_all {
      panic!();
    }
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let tokens: Vec<String> = buf.split_whitespace().map(|s| s.to_string()).collect();
    self.tokens = tokens.into_iter();
  }

  fn next_impl(&mut self) -> String {
    loop {
      if let Some(next) = self.tokens.next() {
        return next.to_string();
      }
      self.refresh_next_line();
    }
  }

  pub fn next<T: FromStr>(&mut self) -> T where <T as std::str::FromStr>::Err: std::fmt::Debug {
    let next_str = self.next_impl();
    next_str.parse().unwrap()
  }

  pub fn next_vec<T: FromStr>(&mut self, len: usize) -> Vec<T> where <T as std::str::FromStr>::Err: std::fmt::Debug {
    (0..len).map(|_i| self.next()).collect()
  }

  pub fn next_vec_read_len<T: FromStr>(&mut self) -> Vec<T> where <T as std::str::FromStr>::Err: std::fmt::Debug {
    let len = self.next();
    self.next_vec(len)
  }
}

fn main() {
  let mut input = Input::new(false);
  let n: usize = input.next();
  let s: String = input.next();
  let mut two_grams = HashMap::new();
  for i in 0..(n - 1) {
    let two_gram = &s[i..i + 2];
    let mut counter = two_grams.entry(two_gram).or_insert(0);
    *counter += 1
  }
  let max_times = *two_grams.values().max().unwrap();
  for (key, val) in&two_grams {
    if *val == max_times {
      println!("{}", key);
      return;
    }
  }
}

use std::collections::HashMap;

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

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

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

fn _main() {
    let mut scan = Scan::new();
    let _n: usize = scan.next();
    let input: Vec<char> = scan.next::<String>().chars().collect();
    let mut map: HashMap<String, usize> = HashMap::new();
    let mut res: String = String::new();
    let mut cnt = 0usize;
    for i in 0..input.len() - 1 {
        let current: String = input[i..=i + 1].iter().collect();
        map.entry(current.clone())
            .and_modify(|x| {
                *x += 1;
            })
            .or_insert(1);
        if map[&current] > cnt {
            cnt = map[&current];
            res = current.clone();
        }
    }
    println!("{}", res);
}

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

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

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

use std::io::Write;

fn solve(writer: &mut std::io::BufWriter<std::io::Stdout>) {
    let n = parse_line!(usize);
    let s: Vec<u8> = parse_line!(String).bytes().collect();
    let mut counts = std::collections::HashMap::new();
    let mut best = 0;
    let mut result = Vec::new();
    for i in 1..n {
        let cnt = counts.entry(s[i - 1..=i].iter().copied().collect::<Vec<u8>>()).or_insert(0);
        *cnt += 1;
        if *cnt > best {
            best = *cnt;
            result = s[i - 1..=i].iter().copied().collect::<Vec<u8>>();
        }
    }
    writeln!(writer, "{}", String::from_utf8(result).unwrap()).unwrap();
}

fn main() {
    let mut writer = std::io::BufWriter::new(std::io::stdout());
    let tests = 1; // parse_line!(usize);
    for _ in 0..tests {
        solve(&mut writer);
    }
}

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

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

    // let stdout = stdout();
    // let mut wr = BufWriter::new(stdout.lock());

    let n = sc.next::<usize>();
    let s = sc.next::<String>();
    let mut h = HashMap::new();

    for i in 1..n {
        let v = h.entry(&s.as_str()[i - 1..i + 1]).or_insert(0);
        *v += 1;
    }

    let mut max = -1;
    let mut result: &str = "";
    for (k, v) in &h {
        if *v > max {
            max = *v;
            result = k;
        }
    }
    println!("{}", result);
}

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

impl<B: BufRead> Scanner<B> {
    pub fn new(reader: B) -> Self {
        Self {
            reader,
            buffer: Vec::new(),
        }
    }

    pub fn next<T: FromStr>(&mut self) -> T
    where
        T::Err: ::std::fmt::Debug,
    {
        if let Some(front) = self.buffer.pop() {
            front.parse::<T>().expect(&front)
        } else {
            let mut input = String::new();
            self.reader.read_line(&mut input).expect("Line not read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
            self.next()
        }
    }
}

// pub trait BinarySearch<T> {
//     fn lower_bound(&self, &T) -> usize;
//     fn upper_bound(&self, &T) -> usize;
// }

// impl<T: Ord> BinarySearch<T> for [T] {
//     fn lower_bound(&self, x: &T) -> usize {
//         let mut low = 0;
//         let mut high = self.len();

//         while low != high {
//             let mid = (low + high) / 2;
//             match self[mid].cmp(x) {
//                 std::cmp::Ordering::Less => {
//                     low = mid + 1;
//                 }
//                 std::cmp::Ordering::Equal | std::cmp::Ordering::Greater => {
//                     high = mid;
//                 }
//             }
//         }
//         low
//     }

//     fn upper_bound(&self, x: &T) -> usize {
//         let mut low = 0;
//         let mut high = self.len();

//         while low != high {
//             let mid = (low + high) / 2;
//             match self[mid].cmp(x) {
//                 std::cmp::Ordering::Less | std::cmp::Ordering::Equal => {
//                     low = mid + 1;
//                 }
//                 std::cmp::Ordering::Greater => {
//                     high = mid;
//                 }
//             }
//         }
//         low
//     }
// }

use std::io;
use std::collections::HashMap;

fn main() {
    let n = read_one::<usize>();
    let s = read_one::<String>()
        .chars()
        .collect::<Vec<char>>();

    let mut hm = HashMap::new();

    for i in 0..n - 1 {
        *hm.entry(s[i..i + 2].iter().collect::<String>()).or_insert(0) += 1;
    }

    let mut v: Vec<_> = hm.iter().collect();
    v.sort_by_key(|&(_, v)| v);
    v.reverse();
    println!("{}", v[0].0);
}

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

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

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

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

    let n = input.u();
    let s = input.sl();
    let a = build_counting_hashmap((0..n-1).map(|i| String::from(&s[i..i+2])));
    let best = a.values().max().unwrap();
    let sol = a.iter().filter(|&(_,k)| best == k).next().unwrap().0;
    println!("{}", sol);
}


//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

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

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

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

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

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

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

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

fn main() {
    let (mut a, mut b): (u64, u64);
    input!(a, b);

    while !(a == 0) && !(b == 0) {
        if a >= 2 * b {
            let buf = a / (2 * b);
            a = a - 2 * b * buf;
        } else if b >= 2 * a {
            let buf = b / (2 * a);
            b = b - 2 * a * buf;
        } else {
            break;
        }
    }
    println!("{} {}", a, b);
}

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

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

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

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

fn brute_force(a: i64, b: i64) -> (i64, i64) {
    let mut a = a;
    let mut b = b;
    while a > 0 && b > 0 {
        if a >= 2 * b {
            a = a % (2 * b);
        } else if b >= 2 * a {
            b = b % (2 * a);
        }
        else {
            return (a, b);
        }
    }
    (a, b)
}

fn solve<R: io::BufRead, W: io::Write>(scan: &mut Scanner<R>, out: &mut W) {
    let a: i64 = scan.token();
    let b: i64 = scan.token();
    let (a, b) = brute_force(a, b);
    writeln!(out, "{} {}", a, b).ok();
}

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

#![allow(unused_imports, unused_variables, dead_code, non_snake_case, unused_macros)]
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

fn getline() -> String{
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
}

macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

macro_rules! mvec {
    ($v: expr, $s: expr) => {
        vec![$v; $s]
    };
    ($v: expr, $s: expr, $($t: expr),*) => {
        vec![mvec!($v, $($t),*); $s]
    };
}

macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn printiter<'a, T>(v: &'a T)
where
    &'a T: std::iter::IntoIterator,
    <&'a T as std::iter::IntoIterator>::Item: std::fmt::Display {
    for (i,e) in v.into_iter().enumerate() {
        if i != 0 {
            print!(" ");
        }
        print!("{}", e);
    }
    println!("");
}

struct ContestPrinter {
    s: String,
}

impl ContestPrinter {
    fn new() -> ContestPrinter {
        ContestPrinter {
        s: String::new(),
        }
    }

    fn print<T>(&mut self, x: T)
        where T: std::fmt::Display {
        self.s.push_str(format!("{}", x).as_str());
    }

    fn println<T>(&mut self, x: T)
        where T: std::fmt::Display {
        self.s.push_str(format!("{}\n", x).as_str());
    }
}

impl std::ops::Drop for ContestPrinter {
    fn drop(&mut self) {
        print!("{}", self.s);
    }
}

fn main() {
    let mut printer = ContestPrinter::new();

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

// Try Codeforces
// author: Leonardone @ NEETSDKASU

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

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

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

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

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

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

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

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

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

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

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

use std::io;

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

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

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

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

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

// ここまで

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

fn main() {
    run();
}

fn main() {
    let mut input = String::new();
    use std::io;
    use std::io::prelude::*;
    io::stdin().read_to_string(&mut input).unwrap();

    let mut it = input.split_whitespace();

    let mut a: u64 = it.next().unwrap().parse().unwrap();
    let mut b: u64 = it.next().unwrap().parse().unwrap();

    loop {
        if a == 0 || b == 0 {
            break;
        } else if 2 * b <= a {
            a %= 2 * b;
        } else if 2 * a <= b {
            b %= 2 * a;
        } else {
            break;
        }
    }

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

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

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

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

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

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

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


use std::io;

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

fn read_line_vec() -> Vec<u64> {
    return read_line().split(' ')
        .map(|s| s.parse().unwrap())
        .collect();
}

fn read_line_pair() -> (u64, u64) {
    let vec = read_line_vec();
    return (vec[0], vec[1]);
}

fn get_fixed_num(n: u32) -> u32 {
    let str: String = n.to_string().chars().filter(|c| *c != '0').collect();
    return str.parse().unwrap();
}

fn main() {
    let a: u32 = read_line().parse().unwrap();
    let b: u32 = read_line().parse().unwrap();

    let c = a + b;

    if get_fixed_num(a) + get_fixed_num(b) == get_fixed_num(c) {
        println!("YES");
    } else {
        println!("NO");
    }

    // let a_line_fixed: String = a_line.chars().filter(|c| c == '0').collect();
    // let b_line_fixed: String = b_line.chars().filter(|c| c == '0').collect();

    // let a_fixed: u32 = a_line_fixed.parse();
    // let b_fixed: u32 = b_line_fixed.parse();

    // println!("{}", get_fixed_num(203));

}

#![allow(non_snake_case, unused_imports)]

// Input macros
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,VecDeque,BinaryHeap};

// Functions
fn remove_zero(n: u64) -> u64{
    let mut ret = 0;
    let mut nz:Vec<u64> = Vec::new();
    for d in n.to_string().chars(){
        if d!='0'{
            nz.push(d as u64 -48);
        }
    }
    for d in nz{
        ret = ret*10 + d;
    }
    return ret;
}

// Main
fn main(){
    input!{
        A: u64,
        B: u64
    }
    let na = remove_zero(A);
    let nb = remove_zero(B);
    let nc = remove_zero(A+B);
    println!("{}", if na+nb==nc{"YES"}else{"NO"});
}

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

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

    l!(a,b = input.i());
    let c = a + b;
    let f = |x: i32| -> i32 {
        let mut d = 1_000_000_000;
        let mut res = 0;
        while d > 0 {
            let y = x / d % 10;
            if y > 0 {
                res = res * 10 + y;
            }
            d /= 10;
        }
        res
    };
    if f(a) + f(b) == f(c) {
        println!("YES");
    } else {
        println!("NO");
    }
}

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

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

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

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

fn no_zeros(x: u64) -> u64 {
    let mut result = 0u64;
    let mut current = x;
    let mut current10 = 1;
    while current > 0 {
        let dig = current % 10;
        if dig != 0 {
            result += current10 * dig;
            current10 *= 10;
        }
        current /= 10;
    }
    result
}

fn _main() {
    let mut scan = Scan::new();
    let a: u64 = scan.next();
    let b: u64 = scan.next();
    let c = a + b;
    println!(
        "{}",
        if no_zeros(a) + no_zeros(b) == no_zeros(c) {
            "YES"
        } else {
            "NO"
        },
    );
}

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