CodeEff/ECCO huggingface dataset:
# Original solution
from functools import reduce
l = [int(eval(input())) for _ in range(5)]
r = [10 if i % 10 == 0 else i %  10 for i in l]
m = [i  if i % 10 == 0 else i // 10 * 10 + 10 for i in l]
print((sum(m) + min(r) - 10))

# Optimized solution
l = [int(eval(input())) for _ in range(5)]
r = [10 if i % 10 == 0 else i %  10 for i in l]
m = [i  if i % 10 == 0 else i // 10 * 10 + 10 for i in l]
print((sum(m) + min(r) - 10))
# Original solution
import math
a = [input().rstrip() for _ in range(5)]
a = sorted(a, key=lambda x: x[-1], reverse=True)

while True:
    m = a.pop()
    if m[-1] == '0':
        a.insert(0, m)
    else:
        break

s = sum([math.ceil(int(n) / 10) * 10 for n in a])
s += int(m)

print(s)



# Optimized solution
s = 0
mod = 0
for _ in range(5):
    i = int(eval(input()))
    m = i % 10
    if m != 0:
        if mod == 0:
            mod = m
        else:
            mod = min(mod, m)
        s += (i // 10 + 1) * 10
    else:
        s += i
if mod != 0:
    s = s - 10 + mod

print(s)
# Original solution
A = [int(eval(input())) for i in range(5)]
B = [(10 - a % 10) % 10 for a in A]
print((sum(A) + sum(B) - max(B)))


# Optimized solution
A = [int(eval(input())) for i in range(5)]
# A = [101, 86, 119, 108, 57]
# A = [29, 20, 7, 35, 120]
# A = [123, 123, 123, 123, 123]
B = [(10-a % 10) % 10 for a in A]
C = [-(-a//10)*10 for a in A]
print((sum(C)-max(B)))
# Original solution
"""ABC091 2D Plane 2N Points diff:
"""

N = int(eval(input()))

ab = [tuple(map(int, input().split())) for _ in range(N)]
cd = [tuple(map(int, input().split())) for _ in range(N)]

ans_x = 0
cd.sort(key=lambda x: x[0])
ab.sort(key=lambda x: x[1], reverse=True)
ab_used = [0]*N
for i, (c, d) in enumerate(cd):
    for j, (a, b) in enumerate(ab):
        if not ab_used[j] and a < c and b < d:
            ab_used[j] = 1
            ans_x += 1
            break

ans_y = 0
cd.sort(key=lambda x: x[1])
ab.sort(key=lambda x: x[0], reverse=True)
ab_used = [0]*N
for i, (c, d) in enumerate(cd):
    for j, (a, b) in enumerate(ab):
        if not ab_used[j] and a < c and b < d:
            ab_used[j] = 1
            ans_y += 1
            break

print((max(ans_x, ans_y)))

# Optimized solution
"""ABC091 2D Plane 2N Points diff:
"""

N = int(eval(input()))

ab = [tuple(map(int, input().split())) for _ in range(N)]
cd = [tuple(map(int, input().split())) for _ in range(N)]

ans_x = 0
cd.sort(key=lambda x: x[0])
ab.sort(key=lambda x: x[1], reverse=True)
ab_used = [0]*N
for i, (c, d) in enumerate(cd):
    for j, (a, b) in enumerate(ab):
        if not ab_used[j] and a < c and b < d:
            ab_used[j] = 1
            ans_x += 1
            break

# ans_y = 0
# cd.sort(key=lambda x: x[1])
# ab.sort(key=lambda x: x[0], reverse=True)
# ab_used = [0]*N
# for i, (c, d) in enumerate(cd):
#     for j, (a, b) in enumerate(ab):
#         if not ab_used[j] and a < c and b < d:
#             ab_used[j] = 1
#             ans_y += 1
#             break

print(ans_x)
# Original solution
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N = I()
A,B = [], []
for n in range(N):
    A.append(LI())
for n in range(N):
    B.append(LI())

"""
一旦赤い点がどの青い点を持てるのかを洗い出す
lenが小さい順に青を消していく。
何個消せるかで勝負
"""

b_a = []
for b in B:
    tmp = []
    for a in A:
        if a[0] < b[0] and a[1] < b[1]:
            # 赤が青より小さいとき
            tmp.append(a)
    if tmp:
        b_a.append(tmp)
#  print(b_a)

result = 0
results = []
#  print('ba', b_a)
def dfs(arr, count):
    for i in range(len(arr)-1, -1, -1):
        tmp = sorted(arr, reverse=True, key=lambda x: len(x))
        popped = tmp.pop()
        #  print('popped', popped)
        #  tmp = [_ for _ in arr]
        for p in popped:
            l = [[k for k in j if k != p] for j in tmp]
            l = [j for j in l if j != []]
            #  print('l',l)
            if not l:
                results.append(count+1)
            else:
                dfs(l, count+1)


dfs(b_a, 0)
#  print(results)
if not results:
    print(0)
    exit()
print(max(results))



# Optimized solution
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N = I()
A,B = [], []
for n in range(N):
    A.append(LI())
for n in range(N):
    B.append(LI())

#  N = 100
#  A,B = [], []
#  for n in range(N):
#      A.append([random.randint(0,2*N), random.randint(0, 2*N)])
#  for n in range(N):
#      B.append([random.randint(0,2*N), random.randint(0, 2*N)])

B = sorted(B, key=lambda x: x[0])

result = 0
for b in B:
    tmp = [a for a in A if a[0] < b[0] and a[1] < b[1]]
    if not tmp:
        continue
    result += 1
    closest = max(tmp, key=lambda x: x[1])
    A.remove(closest)
print(result)
# Original solution
n = int(eval(input()))
red = [list(map(int,input().split())) for _ in range(n)]
blue = [list(map(int,input().split())) for _ in range(n)]
red_count = []
import copy

for i in range(n):
  index_list = []
  for j in range(n):
    if blue[j][0]>red[i][0] and blue[j][1]>red[i][1]:
      index_list.append(j)
  red_count.append(index_list)
red_count.sort(key=lambda x: len(x))

def redcounter(count,i,red_count):
  if i == len(red_count)-1 and red_count[i]:
    return count+1
  elif  i == len(red_count)-1:
    return count
  
  if red_count[i]:
    for index in range(len(red_count[i])): ## removeするindex
      remove_index = red_count[i][index]
      red_count_copy = copy.deepcopy(red_count)
      c = count
      for j in range(i+1,len(red_count_copy)): ## removeしていく
        if remove_index in red_count_copy[j]:
          red_count_copy[j].remove(remove_index)
      c = max(count,redcounter(c,i+1,red_count_copy))
    return c+1
  else:
    return redcounter(count,i+1,red_count)
   
print((redcounter(0,0,red_count)))
  


    

# Optimized solution
n = int(eval(input()))
lired = [list(map(int,input().split())) for _ in range(n)]
liblue = [list(map(int,input().split())) for _ in range(n)]
lired = sorted(lired,key = lambda x:-x[1])
liblue = sorted(liblue,key = lambda x:x[0])
li = list(range(n))
count = 0

for i in range(n):
  for j in li:
    if lired[i][0] < liblue[j][0] and lired[i][1] < liblue[j][1]:
      count += 1
      li.remove(j)
      break
print(count)
# Original solution
n = int(eval(input()))
red = [list(map(int,input().split())) for _ in range(n)]
blue = [list(map(int,input().split())) for _ in range(n)]
blue.sort(key=lambda x:(x[0],x[1]))
check = [False]*n
for i in range(n):
    a = -1
    c = -1
    for j in range(n):
        if check[j]:continue
        if blue[i][0] > red[j][0] and blue[i][1] > red[j][1]:
            if a < red[j][1]:
                a = red[j][1]
                c = j
    if c != -1:
        check[c] = True
print((check.count(True)))

# Optimized solution
n = int(eval(input()))
red = [list(map(int,input().split())) for _ in range(n)]
red.sort(key=lambda x:(x[1]))
blue = sorted(list(map(int,input().split())) for _ in range(n))
blue.sort(key=lambda x:(x[0],x[1]))
seen = [False]*n
for i in range(n):
    check = -1
    for j in range(n):
        if seen[j]:continue
        if blue[i][0] > red[j][0] and blue[i][1] > red[j][1]:
            check = j
    if check != -1:seen[check] = True
print((seen.count(True)))
# Original solution
import heapq

N = int(eval(input()))

red = []
for i in range(N):
    x,y = list(map(int, input().split()))
    heapq.heappush(red, (-y, x))

blue = []
for i in range(N):
    x,y = list(map(int, input().split()))
    heapq.heappush(blue, (x,y))

ans = 0
for i in range(N):
    tmp = []
    bx,by = heapq.heappop(blue)
    flag = True
    while flag:
        mry, rx = heapq.heappop(red)
        if bx > rx and by > -mry:
            ans += 1
            flag = False
            if len(tmp) > 0:
                for mry,rx in tmp:
                    heapq.heappush(red, (mry, rx))
        else:
            tmp.append((mry, rx))

        if len(red) == 0:
            if len(tmp) > 0:
                for mry,rx in tmp:
                    heapq.heappush(red, (mry, rx))
            break
            
print(ans)


# Optimized solution



N = int(eval(input()))

r = []
for _ in range(N):
    x,y = list(map(int, input().split()))
    r.append((-y,x))

b = []
for _ in range(N):
    x,y = list(map(int, input().split()))
    b.append((x,y))

r.sort()
b.sort()

ans = 0
for my,x in r:
    for j in range(len(b)):
        if  -my < b[j][1] and x < b[j][0]:
            ans += 1
            b.pop(j)
            break

print(ans)
# Original solution
n=int(eval(input()))
ab=[list(map(int, input().split())) for _ in range(n)] 
cd=[list(map(int, input().split())) for _ in range(n)] 

#ab = sorted(ab, key=lambda x:x[1]*(-1))
ab.sort(key=lambda x: x[1],reverse=True)
cd=sorted(cd)

cnt=0
for i in range(n):#ab
    for j in range(len(cd)):#cd
        if ab[i][0]<cd[j][0] and ab[i][1]<cd[j][1]:
            cnt+=1
            cd.pop(j)
            break
print(cnt)

# Optimized solution
n=int(eval(input()))
ab=[list(map(int, input().split())) for _ in range(n)] 
cd=[list(map(int, input().split())) for _ in range(n)] 

#ab = sorted(ab, key=lambda x:x[1]*(-1))
ab.sort(key=lambda x: x[0],reverse=True)
ab.sort(key=lambda x: x[1],reverse=True)
cd=sorted(cd)

cnt=0
for i in range(n):#ab
    for j in range(len(cd)):#cd
        if ab[i][0]<cd[j][0] and ab[i][1]<cd[j][1]:
            cnt+=1
            cd.pop(j)
            break
print(cnt)
# Original solution
import sys
sys.setrecursionlimit(10000)
def resolve():
    N = int(eval(input()))
    Reds = [list(map(int, input().split(" "))) for i in range(N)]
    Blues = [list(map(int, input().split(" "))) for i in range(N)]
    maxpairs = 0
    BluePerms = permutations(Blues)
    for blues in BluePerms:
        npairs = 0
        for i in range(N):
            if able_to_be_pair(Reds[i], blues[i]):
                npairs += 1
        maxpairs = max(maxpairs, npairs)
    print(maxpairs)

def able_to_be_pair(red, blue):
    return True if (blue[0] - red[0]) > 0 and (blue[1] - red[1]) > 0 else False

import itertools
def permutations(array, choose=None):
    if choose is None:
        choose = len(array)
    return list(itertools.permutations(array, choose))

if '__main__' == __name__:
    resolve()

# Optimized solution
import sys
import itertools
sys.setrecursionlimit(10000)
def resolve():
    N = int(eval(input()))
    Reds = [list(map(int, input().split(" "))) for i in range(N)]
    Blues = [list(map(int, input().split(" "))) for i in range(N)]
    maxpairs = 0
    for blues in itertools.permutations(Blues, N):
        npairs = 0
        for i in range(N):
            if able_to_be_pair(Reds[i], blues[i]):
                npairs += 1
        maxpairs = max(maxpairs, npairs)
    print(maxpairs)

def able_to_be_pair(red, blue):
    return True if (blue[0] - red[0]) > 0 and (blue[1] - red[1]) > 0 else False

if '__main__' == __name__:
    resolve()
# Original solution
n = int(eval(input()))
r=[list(map(int, input().split())) for i in range(n)]
b=[list(map(int, input().split())) for i in range(n)]
p=[]
v=[0]*n

def dfs(li,m,num):
    global ma

    if num==n:
        ma=max(ma,m)
        return

    for i in p[num]:
        if li[i]==0:
            li[i]=1
            m+=1
            dfs(li,m,num+1)
            li[i]=0
            m-=1
    dfs(li,m,num+1)

ma = 0

for i in range(n):
    q=[]
    for j in range(n):
        if r[i][0]<b[j][0] and r[i][1]<b[j][1]:
            q.append(j)
    p.append(q)

dfs(v,0,0)

print(ma)


# Optimized solution
n = int(eval(input()))
r=[list(map(int, input().split())) for i in range(n)]
b=[list(map(int, input().split())) for i in range(n)]
b.sort(key=lambda x:x[0])
p=[]
r_used=[0]*n
for i in range(n):
    q=[]
    for j in range(n):
        if r[j][0]<b[i][0] and r[j][1]<b[i][1]:
            q.append([r[j][1],j])
    q.sort(key=lambda x:x[0],reverse=True)
    p.append(q)
ans = 0
for i in range(n):
    for j in range(len(p[i])):
        if p[i][j][0]<b[i][1] and r_used[p[i][j][1]]==0:
            ans+=1
            r_used[p[i][j][1]]=1
            break
print(ans)
# Original solution
import itertools

N = int(eval(input()))
red = [tuple(map(int, input().split())) for i in range(N)]
blue = [tuple(map(int, input().split())) for i in range(N)]

res = 0
for _blue in itertools.permutations(blue):
    sum_pair = len([1 for (a, b), (c, d) in zip(red, _blue) if a < c and b < d])
    res = max(res, sum_pair)
print(res)

# Optimized solution

N = int(eval(input()))
red = [list(map(int, input().split())) for i in range(N)]
blue = [list(map(int, input().split())) for i in range(N)]

red.sort(key=lambda x:x[1], reverse=True)
blue.sort()

c = 0
for bx, by in blue:
    for i, (rx, ry) in enumerate(red):
        if rx<bx and ry<by:
            c += 1
            red.pop(i)
            break

print(c)
# Original solution
import sys


def resolve():
    readline = sys.stdin.readline    # 1行だけ文字列にする

    N = int(readline())
    NN = 2 * N + 1

    # 青色はx座標をlistのindex,y座標をlistのvalueとして入力，赤は逆
    red = [[] for _ in [0] * NN]
    blue = [[] for _ in [0] * NN]
    for _ in [0] * N:
        a, b = list(map(int, readline().split()))
        red[b].append(a)
    for _ in [0] * N:
        c, d = list(map(int, readline().split()))
        blue[c].append(d)

    # 青色でvalueのy座標について降順(大きい順)でソート
    # 赤色ではvalueのx座標について降順でソート
    # これで青色はx座標は昇順(index)，y座標は降順(value)にソートされる
    # 赤色はy座標が昇順(index)，x座標が降順(value)
    for i in range(NN):
        r = red[i]
        b = blue[i]
        r.sort(reverse=True)
        b.sort(reverse=True)
        r[0:0] = [i]
        b[0:0] = [i]

    # 青点はx座標の昇順で，赤点はy座標の降順
    # 最小のxの青点で最大のyを持つ赤点を選択
    ans = 0
    flag = False
    while blue:
        cd_blue = blue.pop(0)
        c = cd_blue.pop(0)
        if cd_blue:
            for d in cd_blue:
                for ba_red in red[::-1]:
                    b = ba_red[0]
                    if ba_red[1:]:
                        for i in range(1, len(ba_red)):
                            a = ba_red[i]
                            if a <= c and b <= d:
                                ans += 1
                                del red[b][i]
                                flag = True
                                break
                        if flag:
                            break
                if flag:
                    flag = False
                    break
    print(ans)


resolve()


# Optimized solution
def resolve():
    import sys
    
    readline = sys.stdin.readline    # 1行だけ文字列にする

    N = int(readline())

    # 赤，青点をx,y座標の2次元リストとして入力
    red = [list(map(int, readline().split())) for _ in [0] * N]
    blue = [list(map(int, readline().split())) for _ in [0] * N]

    # 赤はy座標で降順ソート，青はx座標で昇順ソート
    red.sort(key=lambda x: x[1], reverse=True)
    blue.sort()

    ans = 0
    for c, d in blue:
        for a, b in red:
            if a <= c and b <= d:
                ans += 1
                red.remove([a, b])
                break
    print(ans)


resolve()
# Original solution
# AtCoder Beginner Contest 091
# C - 2D Plane 2N Points
# https://atcoder.jp/contests/abc091/tasks/arc092_a

N = int(eval(input()))
A = [tuple(map(int, input().split())) for _ in range(N)]
B = [tuple(map(int, input().split())) for _ in range(N)]

A.sort(key=lambda x: x[0])
B.sort(key=lambda x: x[0])

used = [False]*N

cnt = 0
for u, v in B:
    maxy = -1
    maxi = -1

    for i, (x, y) in enumerate(A):

        if x >= u:
            break
        if used[i] or y >= v:
            continue

        if maxy < y:
            maxy = y
            maxi = i

    if maxy > -1:
        used[maxi] = True
        cnt += 1

print(cnt)


# Optimized solution
N = int(eval(input()))
A = [tuple(map(int, input().split())) for _ in range(N)]
B = [tuple(map(int, input().split())) for _ in range(N)]

A.sort()
B.sort()

cnt = 0
for u, v in B:
    maxy = -1
    maxi = -1

    for i, (x, y) in enumerate(A):

        if x >= u:
            break
        if y >= v:
            continue

        if maxy < y:
            maxy = y
            maxi = i

    if maxy > -1:
        A.pop(maxi)
        cnt += 1

print(cnt)
# Original solution
N=int(eval(input()))
AB=list()
for i in range(N):
    AB.append(list(map(int,input().split())))
CD=list()
for i in range(N):
    CD.append(list(map(int,input().split())))
import itertools
ans=0
for v in itertools.permutations(CD):
    s=0
    for x,y in zip(AB,v):
        if x[0]<y[0] and x[1]<y[1]:
            s+=1
    if s>ans:
        ans=s
print(ans)


# Optimized solution
n=int(eval(input()))
ab=list()
cd=list()
for i in range(n):
    ab.append(list(map(int,input().split())))
for j in range(n):
    cd.append(list(map(int,input().split())))
cd.sort(key=lambda x:x[0])
AB=[[-1,-1]]*n
for i in range(n):
    S=[x for x in ab if x[0]<cd[i][0] and x[1]<cd[i][1]]
    S.sort(key=lambda k:k[1])
    if len(S)>0:
        AB[i]=S[-1]
        ab.remove(S[-1])
print((len(AB)-AB.count([-1,-1])))
# Original solution
n = int(eval(input()))
red_point_list = [[int(j) for j in input().split()] for i in range(n)]
blue_point_list = [[int(j) for j in input().split()] for i in range(n)]

px = red_point_list[0][0]
py = red_point_list[0][1]

tmp = []
for i, p in enumerate(blue_point_list):
    if px < p[0] and py < p[1]:
        new_blue_points = blue_point_list.copy()
        new_blue_points.pop(i)
        tmp.append((1, new_blue_points))

if len(tmp) == 0:
    tmp = [(0, blue_point_list)]

for a, b in red_point_list[1:]:
    new_tmp = []
    for count, blue_points in tmp:
        for i, p in enumerate(blue_points):
            if a < p[0] and b < p[1]:
                new_blue_points = blue_points.copy()
                new_blue_points.pop(i)
                new_tmp.append((count+1, new_blue_points))
            else:
                new_tmp.append((count, blue_points))
    tmp = new_tmp

print((max(tmp, key=lambda x: x[0])[0]))


# Optimized solution
n = int(eval(input()))
red_point_list = [[int(j) for j in input().split()] for i in range(n)]
blue_point_list = [[int(j) for j in input().split()] for i in range(n)]

count = 0
for c, d in sorted(blue_point_list, key=lambda x: x[0]):
    tmp_index = 0
    tmp_y = -1
    for i, p in enumerate(red_point_list):
        if c > p[0] and d > p[1]:
            if p[1] >= tmp_y:
                tmp_index = i
                tmp_y = p[1]

    if tmp_y > -1:
        count += 1
        red_point_list.pop(tmp_index)

print(count)
# Original solution
#入力
N = int(eval(input()))

red_x = []
red_y = []
for i in range(N):
    a = list(map(int, input().split()))
    red_x += [a]
    red_y += [a[::-1]]
red_x.sort(reverse = False)
red_y.sort(reverse = False)
#print (red_x, red_y)


blue_x = []
blue_y = []

for i in range(N):
    a = list(map(int, input().split()))
    blue_x += [a]
    blue_y += [a[::-1]]
blue_x.sort(reverse = False)
blue_y.sort(reverse = False)
#print (blue_x, blue_y)

def judge_x(m): #blue[m]がペアを作れるかどうかをTrue or Falseで返す x優先
    INF = 10 ** 9
    count = 0
    memo = -1
    for i in range(N):
        if blue_x[m][0] > red_x[i][0]: #x座標が条件を満たすか確認
            
            #条件を満たす中で最大のy座標を探す

            #y座標の確認をしてない！！！！ｓ
            #
            if memo < red_x[i][1] and blue_x[m][1] > red_x[i][1]: 
                count = 1
                memo = max(memo, red_x[i][1]) #最も大きいy座標を記録
                memo_i = i
    if count == 0: #iのループを回してもカウントが増えない=x座標が条件を満たすことが一度もない
        return False
    else: #少なくとも一回は条件を満たした。
        red_x[memo_i][0] = INF #使ったものをINFで書き換え
        red_x[memo_i][1] = INF #使ったものをINFで書き換え
#        print (red_x)
        return True
    return False

def judge_y(m): #blue[m]がペアを作れるかどうかをTrue or Falseで返す y優先
    INF = 10 ** 9
    for i in range(N):
        if blue_y[m][1] > red_y[i][1]:
            if blue_y[m][0] > red_y[i][0]:
                red_y[i][1] = INF
                return True
        else:
            pass
    return False

count_x = 0
for s in range(N): #blue内のxが最も小さいののから着目
    if judge_x(s):
        count_x += 1
print (count_x)

#count_y = 0    
#for t in range(N):
#    if judge_y(t):
#        count_y += 1
#print (count_y)

#print (max(count_x, count_y))
#print (judge(0))
#print (judge(1))
#print (judge(2))
#print (judge(3))
#print (judge(4))


# Optimized solution
#入力
N = int(eval(input()))

#赤の座標を取得-->並び替えて左ほど小さくする
red = []
for i in range(N):
    a = list(map(int, input().split()))
    red += [a]
red.sort(reverse = False)

#青の座標を取得-->並び替えて左ほど小さくする
blue = []
for i in range(N):
    a = list(map(int, input().split()))
    blue += [a]
blue.sort(reverse = False)

#blue[m]がペアを作れるかどうかをTrue or Falseで返す
def judge(m): 
    INF = 10 ** 9
    count = 0
    memo = -1
    for i in range(N): #redのリストを小さい順に探索
        if blue[m][0] > red[i][0]: #x座標が条件を満たすか確認       
            #条件を満たす中で最大のy座標を探す
            if memo < red[i][1] and blue[m][1] > red[i][1]: 
            #red[i][1]=赤のy座標が最も大きくかつ、blue[m][1]=青のy座標より小さい時    
                count = 1 #1つでも条件を満たすものがあれば、count = 1にする
                memo = max(memo, red[i][1]) #最も大きいy座標を記録
                memo_i = i #最も大きくなるときのiをメモ
    if count == 0: #iのループを回してもカウントが増えない=x座標が条件を満たすことが一度もない
        return False
    else: #少なくとも一回は条件を満たした。
        red[memo_i][0] = INF #使ったものをINFで書き換え
        red[memo_i][1] = INF #使ったものをINFで書き換え
        return True

count = 0
for s in range(N): #blue内のxが最も小さいののから着目
    if judge(s):
        count += 1
print (count)
# Original solution
N = int(eval(input()))
red = [list(map(int, input().split())) for _ in range(N)]
blue = [list(map(int, input().split())) for _ in range(N)]

# x座標でソート
blue.sort(key=lambda x: x[1])

# y座標で降順ソート
red.sort(reverse=True)

# print(blue)
# print(red)

# blue_list = [0] * N
red_list = [0] * N


for b in range(N):
    for r in range(N):
        if red_list[r] == 1:
            continue
        if red[r][0] < blue[b][0] and red[r][1] < blue[b][1]:
            # print(b, r)
            # blue_list[b] = 1
            red_list[r] = 1
            break

print((sum(red_list)))


# Optimized solution
N = int(eval(input()))
red = [list(map(int, input().split())) for _ in range(N)]
blue = [list(map(int, input().split())) for _ in range(N)]

# 青をx座標で昇順ソート
blue.sort(key=lambda x: x[1])

# 赤をy座標で降順ソート
red.sort(key=lambda x: x[0], reverse=True)

red_list = [0] * N

for b in range(N):
    for r in range(N):
        if red_list[r] == 1:
            continue
        if red[r][0] < blue[b][0] and red[r][1] < blue[b][1]:
            red_list[r] = 1
            break

print((sum(red_list)))