#include <bits/stdc++.h>
int main() {
  int x, y[1005], z, i, n, s, time;
  while (scanf("%d%d", &n, &s) != EOF) {
    time = 0;
    memset(y, 0, sizeof y);
    for (i = 0; i < n; i++) {
      scanf("%d", &x);
      scanf("%d", &z);
      if (!y[x])
        y[x] = z;
      else
        y[x] = y[x] > z ? y[x] : z;
    }
    for (i = s; i > 0; i--) {
      if (y[i] <= time)
        time++;
      else
        time += y[i] - time + 1;
    }
    printf("%d\n", time);
  }
  return 0;
}
