/******************************************************************************

                            Online C# Compiler.
                Code, Compile, Run and Debug C# program online.
Write your code in this editor and press "Run" button to execute it.

*******************************************************************************/

using System;
class HelloWorld {
  static void Main() {
      string [] s= Console.ReadLine().Split();
      long D = long.Parse(s[0]);
      long J = long.Parse(s[1]); 
      long k = 0;
      long a = 0;
      long br =0;
     
          if(J == 1)
          {
              
          
      for(long i = 0; i<D;i++)
      {
          string [] s1= Console.ReadLine().Split();
          k = long.Parse(s1[0]);
          a = long.Parse(s1[1]);
      
      
 {
    
         br = br + a;
        
     
 }
      
          
      }
          }
          
     long P = long.Parse(Console.ReadLine());
 br = br -P;
 Console.WriteLine(br);
    
     
  }
}