#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double eps = 1e-10;
const double PI = acos(-1.0);
const int maxn = 1000009;
const int maxm = 1000009;
int main() {
  int n, s, a, b;
  while (cin >> n >> s) {
    vector<pair<int, int> > vt;
    for (int i = 0; i < n; i++) {
      cin >> a >> b;
      vt.push_back(make_pair(a, b));
    }
    sort(vt.begin(), vt.end());
    int t = 0, prev = s;
    bool flag = false;
    for (int i = 0; i < n; i++) {
      if (vt[i].second > s - vt[i].first && !flag) {
        t = vt[i].second;
        flag = true;
        prev = vt[i].first;
      }
      if (vt[i].second > (t + prev - vt[i].first) && flag) {
        t = vt[i].second;
        prev = vt[i].first;
      }
    }
    cout << t + prev << endl;
  }
  return 0;
}
