#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
const int MAXN = 1e6 + 5;
const int inf = (int)2e9 + 5;
const int infll = (int)4e18 + 5;
const int mod = (int)1e9 + 7;
void solve(){
int n, k;
cin >> n >> k;
vector<int> a(n + 1), h(n + 1), x(k + 1);
for(int i = 1; i <= n; i++) {
cin >> a[i] >> h[i];
}
for(int i = 1; i <= k; i++) {
cin >> x[i];
}
map<int,int> mp;
sort(x.begin(), x.end());
int res = 0;
for(int i = 1; i <= n; i++) {
int ind = lower_bound(x.begin(), x.end(), a[i]) - x.begin();
int cost = h[i];
bool f = false;
if(ind != n + 1 and x[ind] - a[i] < cost) {
f = true;
mp[x[ind]]++;
cost = x[ind] - a[i];
}
if(ind > 1 and a[i] - x[ind-1] < cost) {
if(f) mp[x[ind]]--;
mp[x[ind - 1]]++;
cost = a[i] - x[ind-1];
}
res+=cost;
}
for(auto [k,v] : mp) {
if(v > 0) res++;
}
cout << res << endl;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t = 1;
//cin >> t;
while(t--)
solve();
return 0;
}