#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> starts(m), ends(m), results;
  for (int i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;
    starts[l - 1]++;
    ends[r - 1]++;
  }
  int open = 0;
  for (int i = 0; i < m; i++) {
    open += starts[i];
    if (open == 0) results.push_back(i + 1);
    open -= ends[i];
  }
  std::cout << results.size() << std::endl;
  for (auto p : results) cout << p << ' ';
  cout << endl;
  return 0;
}
