#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, a, b, cnt;
  vector<pair<int, int> > V, V2;
  while (scanf("%d %d", &n, &k) != EOF) {
    V.clear();
    for (int i = 0; i < n; i++) {
      scanf("%d %d", &a, &b);
      V.push_back(make_pair(a, -b));
      V2.push_back(make_pair(a, -b));
    }
    sort(V.rbegin(), V.rend());
    cnt = 0;
    for (int i = 0; i < n; i++) {
      if (V[k - 1] == V[i]) {
        cnt++;
      }
    }
    printf("%d\n", cnt);
  }
  return 0;
}
