using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics.CodeAnalysis;
using System.Reflection.Emit;
using System.Runtime.InteropServices;
namespace quali_24_5_
{
    internal class Plasma
    {
            static void Main(string[] args)
            {

            string[] r1 = Console.ReadLine().Split(' ');
            int N = int.Parse(r1[0]);
            int Q = int.Parse(r1[1]);
            int pack = 0;
            bool canEat = true;
            int day = 0;
            int packs = 0;
            int R = 0;
            int e = 0;
            int k = 0;
            int[] D = new int[N];
            int[] P = new int[N];
            for (int i = 0; i < N; i++)
            {
                string[] r2 = Console.ReadLine().Split();
                D[i] = int.Parse(r2[0]);
                P[i] = int.Parse(r2[1]);
            }
            for (int j = 0; j < Q; j++)
                {
                    k = (int)Convert.ToInt64(Console.ReadLine());
                }
            packs = 0;
            day =1;
            for (int y = 0; y < k; y++)
            {
                packs-=1;
                day+=1;
                if (packs>0)
                {
                    e+=1;
                }
                if (day==y)
            {
                packs+=P[R];
                R+=1;
            }
            }
            Console.WriteLine(e);
        }
    }
}