#include <iostream>
using namespace std;

int main()
{
	int N, Q;
	int i, j, k;
    int plazmakeks = 0; 
	int brojac = 0;
	cin >> N >> Q;
	int* pitanje = new int[Q];
  int dani[300005];
	int plazma[300005];
	for (i = 0; i < N; i++) {
		cin >> dani[i] >> plazma[i];
	}
	for (k = 0; k < Q; k++) {
		cin >> pitanje[k];
	}
	for (k = 0; k < Q; k++) {
		for (i = 0; i < N; i++) {
			for (j = 0; j <= pitanje[k]; j++) {
				if (dani[i] == j) {
					plazmakeks += plazma[i];
				}
				if (plazmakeks > 0) {
					plazmakeks--;
					brojac++;
				}

			}
		}
	}
	cout << brojac;
}