#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int nx = 1e5 + 5;
int n, m;
vector<pair<int,int>> a;
vector<int> b;
int main() {
ios_base::sync_with_stdio(0), cin.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; i++) {
int s, v;
cin >> s >> v;
a.emplace_back(v, s);
}
for (int i = 1; i <= m; i++) {
int c; cin >> c;
b.emplace_back(c);
}
sort(a.begin(),a.end(),greater<pair<int,int>>());
sort(b.begin(),b.end(),greater<int>());
int i = 0, j = 0;
int ans = 0;
while (i < n && j < m) {
if (a[i].second <= b[j]) {
ans++; j++;
}
i++;
}
cout << ans;
}
/*
3 4
10 20
5 1
3 5
4
6
10
4
2
*/