#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(0);
// freopen("other/input.txt", "r", stdin);
int N, M;
cin >> N >> M;
vector<pair<int, int>> painting(N, {0, 0}); // value - size
vector<int> frames(M, 0);
for (int i = 0; i < N; i++) {
cin >> painting[i].second >> painting[i].first;
}
for (int j = 0; j < M; j++) {
cin >> frames[j];
}
sort(painting.begin(), painting.end());
sort(frames.begin(), frames.end());
int ans = 0;
int pP = 0, fP = 0;
while (pP < N && fP < M) {
if (painting[pP].second <= frames[fP]) {
pP++;
fP++;
ans++;
continue;
} else {
if (fP == M - 1) {
pP++;
continue;
}
fP++;
}
}
cout << ans;
return 0;
}