#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 0, 1, 1, 1, 0, -1, -1}, dy[] = {-1, -1, -1, 0, 1, 1, 1, 0};
int cx[] = {1, 1, 2, 2, -1, -1, -2, -2}, cy[] = {2, -2, 1, -1, 2, -2, 1, -1};
int main() {
  ios_base::sync_with_stdio(false);
  int n, s, i;
  int f, t;
  cin >> n >> s;
  int ans = 0;
  for (i = 1; i <= n; i++) {
    cin >> f >> t;
    ans =
        (ans > (s - f > t ? s - f : t) + f ? ans : (s - f > t ? s - f : t) + f);
  }
  cout << ans;
  return 0;
}
