#include <bits/stdc++.h>
using namespace std;
int a[200005];
struct node {
  int l, r, id;
  bool operator<(const node &a) const {
    if (r == a.r) return l < a.l;
    return r > a.r;
  }
} no[200005];
int vis[200005];
int main() {
  int n, k;
  cin >> n >> k;
  int ll = 0x3f3f3f3f;
  int rr = 0;
  for (int i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;
    no[i].l = l;
    no[i].r = r;
    no[i].id = i + 1;
    ll = min(ll, l);
    rr = max(rr, r);
    a[l]++;
    a[r + 1]--;
  }
  sort(no, no + n);
  int kk = 0;
  vector<int> ans;
  for (int i = ll; i <= rr; i++) {
    a[i] = a[i - 1] + a[i];
    if (a[i] > k) {
      for (int z = 0; z < n && a[i] > k; z++) {
        if (no[z].r < i) break;
        if (no[z].l <= i && vis[z] == 0) {
          a[i]--;
          ans.push_back(no[z].id);
          vis[z] = 1;
          a[no[z].r + 1]++;
        }
      }
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << " ";
  }
}
