#include <iostream>
using namespace std;



int main()
{
    long long n, q;
    cin>>n>>q;
    long long d[n], p[n], pitanja[q];
    for(long long i = 0;i<n;i++){
        cin>>d[i]>>p[i];
    }
    for(long long i = 0;i<q;i++){
        cin>>pitanja[i];
    }
   long long dan = 1, brojac = 0;
    for(long long k = 0;k<q;k++)
{ 
    while(dan<=pitanja[k]){
        for(long long i = 0;i<n;i++)
        {
            if(p[i] != 0)
            {
                if(dan >= d[i]){
                p[i]--;
                brojac++;
                break;}
                else
                {break;
                }
            }  
        }
    dan ++;
    }
cout<<brojac<<endl;

}
    
    return 0;
}