#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2e5 + 10;
struct node {
  int l, r, id;
  friend bool operator<(node A, node B) {
    return A.r == B.r ? A.l < B.l : A.r < B.r;
  }
};
node a[N];
bool add[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll n, m;
  ;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i].l >> a[i].r;
    a[i].id = i;
  }
  sort(a + 1, a + 1 + n);
  multiset<int> b;
  for (int i = 0; i < m; ++i) b.insert(0);
  for (int i = 1; i <= n; ++i) {
    auto p = b.lower_bound(a[i].l);
    if (p != b.begin()) {
      add[a[i].id] = 1;
      --p;
      b.erase(p);
      b.insert(a[i].r);
    }
  }
  vector<int> ans;
  for (int i = 1; i <= n; ++i)
    if (!add[i]) ans.emplace_back(i);
  cout << ans.size() << endl;
  for (auto i : ans) cout << i << ' ';
  cout << endl;
}
