#include <bits/stdc++.h>
using namespace std;
const int MAXS = 1123;
int mt[MAXS];
int main() {
  std::ios_base::sync_with_stdio(false);
  int n, s;
  cin >> n >> s;
  int i;
  for (i = 0; i <= s; i++) mt[i] = std::numeric_limits<int>::min();
  int f, t;
  for (i = 0; i <= n - 1; i++) {
    cin >> f >> t;
    if (t > mt[f]) mt[f] = t;
  }
  int curr = s;
  int ans = 0;
  while (curr > 0) {
    ans = max(ans, mt[curr]) + 1;
    curr--;
  }
  cout << ans;
  return 0;
}
