//package power.rankings;
import java.util.*;
import java.io.*;
public class Main{//PowerRankings {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static StringTokenizer st;
static class pair{
int sz, val; public pair(int sz0, int val0){sz=sz0; val=val0;}
}
static class cmp implements Comparator<pair>{
public int compare(pair a, pair b){
return Integer.compare(a.val,b.val);
}
}
public static void main(String[] args) throws IOException {
int n = readInt(), m = readInt(), framsz[] = new int[m+1];
pair pic[] = new pair[n+1]; for(int i = 1; i <= n; i++)pic[i] = new pair(readInt(),readInt());
Arrays.sort(pic, 1, n+1,new cmp());
for(int i = 1; i <= m; i++){framsz[i] = readInt();}
Arrays.sort(framsz,1,m+1);
int dp[][] = new int[n+1][m+1];
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
if(pic[i].sz <= framsz[j]){
dp[i][j] = Math.max(Math.max(dp[i-1][j-1]+1, dp[i-1][j]),dp[i][j-1]);
}else{
dp[i][j] = Math.max(dp[i-1][j], dp[i][j-1]);
}
}
}
System.out.println(dp[n][m]);
}
static String next() throws IOException {
while (st == null || !st.hasMoreTokens()) {
st = new StringTokenizer(br.readLine().trim());
}
return st.nextToken();
}
static long readLong() throws IOException {
return Long.parseLong(next());
}
static int readInt() throws IOException {
return Integer.parseInt(next());
}
static double readDouble() throws IOException {
return Double.parseDouble(next());
}
static char readCharacter() throws IOException {
return next().charAt(0);
}
static String readLine() throws IOException {
return br.readLine().trim();
}
static int upper_bound(ArrayList<Integer> a, int key) {
int lo = 0, hi = a.size() - 1;
while (lo <= hi) {
int mid = (lo + hi) / 2;
if (a.get(mid) == key) {
lo = mid + 1;
} else if (a.get(mid) > key) {
hi = mid - 1;
} else {
lo = mid + 1;
}
}
return hi;
}
static int lower_bound(ArrayList<Integer> a, int key) {
int lo = 0, hi = a.size() - 1;
while (lo <= hi) {
int mid = (lo + hi) / 2;
if (a.get(mid) == key) {
hi = mid - 1;
} else if (a.get(mid) > key) {
hi = mid - 1;
} else {
lo = mid + 1;
}
}
return lo;
}
static int gcd(int x, int y) {
return y == 0 ? x : gcd(y, x % y);
}
public static long modexponent(long x, long exp, long mod) {
if (exp == 0) {
return 1;
}
long t = modexponent(x, exp / 2, mod);
t = (t * t) % mod;
if (exp % 2 == 0) {
return t;
}
return (t * x % mod) % mod;
}
public static boolean next_permutation(int a[]) {
int n = a.length;
int p = n - 2;
int q = n - 1;
while (p >= 0 && a[p] >= a[p + 1]) {
p--;
}
if (p < 0) {
return false;
}
while (a[q] <= a[p]) {
q--;
}
int t = a[p];
a[p] = a[q];
a[q] = t;
for (int i = p + 1, j = n - 1; i < j; i++, j--) {
t = a[i];
a[i] = a[j];
a[j] = t;
}
return true;
}
static long getSubHash(long hash[], long pow[], int l, int r) {
return hash[r] - hash[l - 1] * pow[r - l + 1];
}
}
Compilation message
joi2019_ho_t2.java:6: error: class Main is public, should be declared in a file named Main.java
public class Main{//PowerRankings {
^
1 error