#include <bits/stdc++.h>
using namespace std;
unsigned long long mod = 1000000007;
unsigned long long powermodm(unsigned long long x, unsigned long long n,
                             unsigned long long M) {
  unsigned long long result = 1;
  while (n > 0) {
    if (n % 2 == 1) result = (result * x) % M;
    x = (x * x) % M;
    n = n / 2;
  }
  return result;
}
unsigned long long power(unsigned long long _a, unsigned long long _b) {
  unsigned long long _r = 1;
  while (_b) {
    if (_b % 2 == 1) _r = (_r * _a);
    _b /= 2;
    _a = (_a * _a);
  }
  return _r;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  unsigned long long n, k;
  cin >> n >> k;
  unsigned long long x[n + 1], y[n + 1];
  vector<
      pair<unsigned long long, pair<unsigned long long, unsigned long long> > >
      g;
  for (int i = 1; i <= n; i++) {
    cin >> x[i] >> y[i];
    g.push_back({x[i], {y[i], i}});
  }
  sort(g.begin(), g.end());
  vector<unsigned long long> v;
  unsigned long long ind = 0;
  multiset<pair<unsigned long long, unsigned long long> > s;
  for (int i = 1; i <= 2e5; i++) {
    for (int j = ind; j < g.size(); j++) {
      if (g[j].first == i) {
        s.insert({g[j].second.first, g[j].second.second});
        ind = j + 1;
      } else {
        ind = j;
        break;
      }
    }
    if (s.size() > k) {
      unsigned long long temp = s.size() - k;
      while (temp--) {
        auto it = s.end();
        it--;
        v.push_back(it->second);
        s.erase(it);
      }
    }
    while (!s.empty()) {
      auto it = s.begin();
      if (it->first == i) {
        s.erase(it);
      } else {
        break;
      }
    }
  }
  cout << v.size() << endl;
  for (int i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  return 0;
}
