#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, f, cnt = 0;
  cin >> n >> f;
  pair<long long, long long> x[n];
  for (int i = 0; i < n; i++) {
    cin >> x[i].first >> x[i].second;
  }
  sort(x, x + n);
  reverse(x, x + n);
  long long i = 0, t = 0;
  while (f != 0) {
    if (i < n && f == x[i].first) {
      t = max(x[i].second, t);
      i++;
      continue;
    }
    t++;
    f--;
  }
  cout << t << endl;
  return 0;
}
