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