#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, c;
  cin >> n >> c;
  vector<vector<int> > v(c + 1);
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
  }
  int time = 0;
  for (int i = c; i >= 0; i--) {
    int m = -1e9;
    for (int j = 0; j < v[i].size(); j++) {
      m = max(m, v[i][j]);
    }
    if (m > time) {
      time = m;
    }
    time++;
  }
  cout << time - 1;
  return 0;
}
