#include <bits/stdc++.h>
using namespace std;
int tim[1005];
int main() {
  int n, s;
  cin >> n >> s;
  for (int i = 1; i <= n; i++) {
    int f, t;
    cin >> f >> t;
    if (tim[f] < t) tim[f] = t;
  }
  int ans = tim[s];
  for (int i = s - 1; i >= 1; i--) {
    ans = max(ans + 1, tim[i]);
  }
  cout << ans + 1 << endl;
}
