#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, s;
  cin >> n >> s;
  int a[s];
  memset(a, 0, sizeof a);
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    a[x - 1] = max(a[x - 1], y);
  }
  int t = 0;
  for (int i = 0; i < s; i++) {
    t += max(a[s - i - 1] - t, 0);
    t++;
  }
  cout << t << endl;
  return 0;
}
