using System;
using System.Collections.Generic;
using System.Data.OleDb;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Drugi_zadatak
{
    internal class Program
    {
        static void Main()
        {
            var u = Console.ReadLine().Split();
            int n = int.Parse(u[0]);
            int q = int.Parse(u[1]);
            int[] di = new int[n];
            int[] pi = new int[n];
            for (int i = 0; i < n; i++)
            {
                var u1 = Console.ReadLine().Split();
                di[i] = int.Parse(u1[0]);
                pi[i] = int.Parse(u1[1]);
            }
            long[] kj = new long[q];
            for (int i = 0; i < q; i++)
            {
                kj[i] = long.Parse(Console.ReadLine());
            }
            int zaliha = 0; 
            int indkup = 0;
            int ukp = 0;
            foreach (var d in kj)
            {
                if (indkup < n && di[indkup] <= d)
                {
                    zaliha += pi[indkup];
                    indkup++;
                }
                if (zaliha > 0)
                {
                    ukp++;
                    zaliha--;
                }
                
            }
            Console.WriteLine(ukp);
        }
    }
}