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

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);

// ===

struct Matching {
    n: usize,
    graph: Vec<Vec<Vec<usize>>>,
    deg: Vec<usize>,
    itr: Vec<usize>,
    lvl: Vec<i32>,
}

impl Matching {
    fn new(n: usize) -> Self {
        Matching {
            n: n,
            graph: vec![vec![]; n],
            deg: vec![0; n],
            itr: vec![0; n],
            lvl: vec![0; n]
        }
    }

    fn add_edge(&mut self, u: usize, v: usize, cap: usize) {
        let udeg = self.deg[u];
        let vdeg = self.deg[v];
        self.graph[u].push(vec![v, cap, vdeg]);
        self.graph[v].push(vec![u, 0, udeg]);
        self.deg[u] += 1;
        self.deg[v] += 1;
    }

    fn dfs(&mut self, v: usize, t: usize, f: usize) -> usize {
        if v == t {
            return f;
        }
        let mut it = self.itr[v];
        while it < self.graph[v].len() {
            self.itr[v] = it;

            let to = self.graph[v][it][0];
            let left_cap = self.graph[v][it][1];
            let rev_idx = self.graph[v][it][2];
            if left_cap > 0 && self.lvl[v] < self.lvl[to] {
                let d = self.dfs(to, t, min(left_cap, f));
                if d > 0 {
                    self.graph[v][it][1] -= d;
                    self.graph[to][rev_idx][1] += d;
                    return d;
                }
            }
            it += 1;
        }
        0
    }

    fn bfs(&mut self, s: usize) {
        for i in 0..self.n {
            self.lvl[i] = -1;
        }
        self.lvl[s] = 0;

        let mut queue = VecDeque::new();
        queue.push_back(s);
        while queue.len() >= 1 {
            let v = queue.pop_front().unwrap();
            let lv = self.lvl[v];
            let en = self.graph[v].len();
            for i in 0..en {
                let to = self.graph[v][i][0];
                let cap = self.graph[v][i][1];
                if cap > 0 && self.lvl[to] < 0 {
                    self.lvl[to] = lv + 1;
                    queue.push_back(to);
                }
            }
        }
    }

    fn max_flow(&mut self, s: usize, t: usize) -> usize {
        let mut flow = 0;
        loop {
            self.bfs(s);
            if self.lvl[t] < 0 {
                return flow;
            }
            for i in 0..self.n {
                self.itr[i] = 0;
            }
            loop {
                let f = self.dfs(s, t, 100000);
                if f == 0 {
                    break;
                }
                flow += f;
            }
        }
    }
}

fn main() {
    let n: usize = read();
    let red_points: Vec<(i32, i32)> = readn(n);
    let blue_points: Vec<(i32, i32)> = readn(n);

    let mut matching = Matching::new(2*n+2);

    for i in 0..n {
        matching.add_edge(2*n, i, 1);
        matching.add_edge(i+n, 2*n+1, 1);
    }
    for i in 0..n {
        for j in 0..n {
            if red_points[i].0 < blue_points[j].0 && red_points[i].1 < blue_points[j].1 {
                matching.add_edge(i, n+j, 1);
            }
        }
    }

    println!("{}", matching.max_flow(2*n, 2*n+1));
}


Measured memory_bytes: 4352