#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T abs(T t) {
  return t < 0 ? -t : t;
}
const long long modn = 1000000007;
inline long long mod(long long x) { return x % modn; }
int n, s, mx[2000];
int main() {
  int f, t, i;
  scanf("%d %d", &n, &s);
  for (i = 0; i < n; i++) scanf("%d %d", &f, &t), mx[f] = max(mx[f], t);
  int ans = 0;
  for (i = s; i > 0; i--)
    if (ans < mx[i])
      ans = mx[i] + 1;
    else
      ans++;
  printf("%d\n", ans);
  return 0;
}
