#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s, ret = 0, secs = 0;
  map<int, int> mp;
  cin >> n >> s;
  for (int i = 0; i < n; i++) {
    int foo, bar;
    cin >> foo >> bar;
    mp[foo] = max(mp[foo], bar);
  }
  for (int i = s; i >= 0; ret++, i--) ret = max(ret, mp[i]);
  cout << ret - 1 << endl;
}
