#include <bits/stdc++.h>
using namespace std;
static const int maxn = 2e5 + 5;
struct data {
  long long int sum;
  data() : sum(0) {}
};
long long int store[maxn];
struct SegTree {
  int N;
  vector<data> st;
  vector<bool> cLazy;
  vector<long long int> lazy;
  void init(int n) {
    N = n;
    st.resize(4 * N + 5);
    cLazy.resize(4 * N + 5);
    lazy.resize(4 * N + 5);
  }
  void merge(data &cur, data &l, data &r) { cur.sum = max(l.sum, r.sum); }
  void propagate(int node, int L, int R) {
    if (L != R) {
      int lft = node * 2;
      int rgt = lft + 1;
      cLazy[lft] = 1;
      cLazy[rgt] = 1;
      lazy[lft] = lazy[lft] + lazy[node];
      lazy[rgt] = lazy[rgt] + lazy[node];
    }
    st[node].sum = st[node].sum + lazy[node];
    cLazy[node] = 0;
    lazy[node] = 0;
  }
  void build(int node, int L, int R) {
    if (L == R) {
      st[node].sum = store[L];
      cLazy[node] = 0;
      lazy[node] = 0;
      return;
    }
    int lft = node * 2;
    int rgt = lft + 1;
    int M = (L + R) / 2;
    build(lft, L, M);
    build(rgt, M + 1, R);
    merge(st[node], st[lft], st[rgt]);
  }
  data Query(int node, int L, int R, int i, int j) {
    if (cLazy[node]) propagate(node, L, R);
    if (j < L || i > R) return data();
    if (i <= L && R <= j) return st[node];
    int lft = node * 2;
    int rgt = lft + 1;
    int M = (L + R) / 2;
    data p = Query(lft, L, M, i, j);
    data q = Query(rgt, M + 1, R, i, j);
    data cur;
    merge(cur, p, q);
    return cur;
  }
  data pQuery(int node, int L, int R, int pos) {
    if (cLazy[node]) propagate(node, L, R);
    if (L == R) return st[node];
    int lft = node * 2;
    int rgt = lft + 1;
    int M = (L + R) / 2;
    if (pos <= M)
      return pQuery(lft, L, M, pos);
    else
      return pQuery(rgt, M + 1, R, pos);
  }
  void update(int node, int L, int R, int i, int j, long long int val) {
    if (cLazy[node]) propagate(node, L, R);
    if (j < L || i > R) return;
    if (i <= L && R <= j) {
      cLazy[node] = 1;
      lazy[node] = lazy[node] + val;
      propagate(node, L, R);
      return;
    }
    int lft = node * 2;
    int rgt = lft + 1;
    int M = (L + R) / 2;
    update(lft, L, M, i, j, val);
    update(rgt, M + 1, R, i, j, val);
    merge(st[node], st[lft], st[rgt]);
  }
  void pUpdate(int node, int L, int R, int pos, long long int val) {
    if (cLazy[node]) propagate(node, L, R);
    if (L == R) {
      cLazy[node] = 1;
      lazy[node] = lazy[node] + val;
      propagate(node, L, R);
      return;
    }
    int lft = node * 2;
    int rgt = lft + 1;
    int M = (L + R) / 2;
    if (pos <= M)
      pUpdate(lft, L, M, pos, val);
    else
      pUpdate(rgt, M + 1, R, pos, val);
    merge(st[node], st[lft], st[rgt]);
  }
  data query(int pos) { return pQuery(1, 1, N, pos); }
  data query(int l, int r) { return Query(1, 1, N, l, r); }
  void update(int pos, long long int val) { pUpdate(1, 1, N, pos, val); }
  void update(int l, int r, long long int val) { update(1, 1, N, l, r, val); }
};
int l[maxn];
int r[maxn];
int segs[maxn];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, k;
  cin >> n >> k;
  SegTree Tree;
  int N = 2e5;
  Tree.init(N);
  for (int i = 1; i <= n; i++) {
    cin >> l[i] >> r[i];
    segs[i] = i;
  }
  sort(segs + 1, segs + n + 1, [&](int i, int j) { return r[i] < r[j]; });
  vector<int> del;
  for (int i = 1; i <= n; i++) {
    int q = Tree.query(l[segs[i]], r[segs[i]]).sum;
    if (q == k)
      del.push_back(segs[i]);
    else
      Tree.update(l[segs[i]], r[segs[i]], 1);
  }
  cout << del.size() << '\n';
  for (int x : del) cout << x << " ";
}
