#include <bits/stdc++.h>
#define pii pair<int,int>
using namespace std;
const int N = 2e5+10;
int n,m,ans,t[N];
struct node {
int l,r;
}a[N];
bool cmp (node x,node y) {
if (x.l==y.l) return x.r<y.r;
return x.l<y.l;
}
priority_queue<pii,vector<pii>,greater<pii> >q;
int main () {
freopen("dream.in","r",stdin);
freopen("dream.out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> n >> m;
for (int i=1;i<=n;i++) cin >> a[i].l >> a[i].r;
for (int i=1;i<=m;i++) cin >> t[i];
sort(a+1,a+1+n,cmp);
sort(t+1,t+m+1);
int idx=1;
for (int i=1;i<=m;i++) {
while (idx<=n&&a[idx].r<t[i]) idx++;
while (idx<=n&&a[idx].l<=t[i]&&t[i]<=a[idx].r)q.push(make_pair(a[idx].r,idx)),idx++;
while (q.size()&&q.top().first<t[i]) q.pop();
if (q.size()) ans++,q.pop();
}
cout << ans <<endl;
return 0;
}