#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iterator>
#include <cstring>

using namespace std;
const int INF = (1<<30);
typedef pair<int, int> P;
typedef long long ll;
#define PB push_back
#define rep(i, a) for (int i = 0; i < a; i++)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define mp make_pair



//出力チェック用
int qqq;

ll x[100001],v[100001];

int main() 
{
	ll n, c;
	cin >> n >> c;
	rep(i, n) cin >> x[i] >> v[i];
	ll a = 0, b = 0,d=0,e=0;

	ll vc[100001] = { 0 }, vac[100001] = { 0 };
	
	//PatternA
	ll walk = 0;
	ll aMax＝0;
	rep(i, n) {
		walk += x[i];
		a += v[i] - (x[i]-walk);
		aMax= max(aMax, a);
	}
	cout << max(a, b) << endl;
	cin >> qqq;
	return 0;
}
