#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

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

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

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

struct HopcroftKarp {
    l_size: usize,
    r_size: usize,
    list: Vec<Vec<usize>>,
    seen: Vec<bool>,
    matched: Vec<bool>,
    level: Vec<isize>,
    matching: Vec<usize>,
}
impl HopcroftKarp {
    fn new(l: usize, r: usize) -> Self {
        HopcroftKarp {
            l_size: l,
            r_size: r,
            list: vec![Vec::new(); l],
            seen: vec![false; l],
            matched: vec![false; l],
            level: vec![-1; l + 1],
            matching: vec![l; r],
        }
    }
    fn add_edge(&mut self, from: usize, to: usize) {
        self.list[from].push(to);
    }
    fn bfs(&mut self) {
        let mut queue = VecDeque::new();
        for left in 0..self.l_size {
            self.level[left] = -1;
            if !self.matched[left] {
                queue.push_back(left);
                self.level[left] = 0;
            }
        }
        self.level[self.l_size] = self.l_size as isize;
        while let Some(left) = queue.pop_front() {
            for i in 0..self.list[left].len() {
                let right = self.list[left][i];
                let next = self.matching[right];
                if self.level[next] == -1 {
                    self.level[next] = self.level[left] + 1;
                    queue.push_back(next);
                }
            }
        }
    }
    fn dfs(&mut self, left: usize) -> bool {
        if left == self.l_size {
            return true;
        } else if self.seen[left] {
            return false;
        }
        self.seen[left] = true;
        for i in 0..self.list[left].len() {
            let right = self.list[left][i];
            let next = self.matching[right];
            if self.level[next] > self.level[left] && self.dfs(next) {
                self.matching[right] = left;
                return true;
            }
        }
        false
    }
    fn solve(&mut self) -> usize {
        self.seen = vec![false; self.l_size];
        self.matched = vec![false; self.l_size];
        self.level = vec![-1; self.l_size + 1];
        self.matching = vec![self.l_size; self.r_size];
        let mut res = 0;
        loop {
            self.bfs();
            self.seen = vec![false; self.l_size];
            let mut finished = true;
            for left in 0..self.l_size {
                if !self.matched[left] && self.dfs(left) {
                    self.matched[left] = true;
                    res += 1;
                    finished = false;
                }
            }
            if finished {
                break;
            }
        }
        res
    }
}

fn solve() {
    let n = get!(usize);
    let ab = get!(usize, usize; n);
    let cd = get!(usize, usize; n);

    let mut solver = HopcroftKarp::new(n,n);

    for i in 0..n {
        for j in 0..n {
            if ab[i].0 < cd[j].0 && ab[i].1 < cd[j].1 {
                solver.add_edge(i,j);
            }
        }
    }
    println!("{}", solver.solve());
}


Measured memory_bytes: 8572