#include <bits/stdc++.h>
using namespace std;
int floorvalue[10009];
int main() {
  int n, s;
  cin >> n >> s;
  pair<int, int> ar[n];
  for (int i = 0; i < n; i++) {
    int u, v;
    cin >> u >> v;
    floorvalue[u] = max(floorvalue[u], v);
  }
  for (int i = s - 1; i >= 0; i--) {
    floorvalue[i] = max(floorvalue[i], floorvalue[i + 1] + 1);
  }
  cout << floorvalue[0];
}
