#include <bits/stdc++.h>
using namespace std;
void sort_p(int p[], int t[], int n) {
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      if (p[j] > p[i]) {
        int temp = p[j];
        int temp2 = t[j];
        p[j] = p[i];
        t[j] = t[i];
        p[i] = temp;
        t[i] = temp2;
      }
    }
  }
}
void sort_t(int p[], int t[], int n) {
  int start, end;
  for (int i = 0; i < n; i++) {
    if (p[i] == p[i + 1]) {
      start = i;
      int k;
      for (k = i + 2; k < n && p[k] == p[i]; k++)
        ;
      end = --k;
      i = k;
      for (int a = start; a < end; a++) {
        for (int b = a + 1; b <= end; b++) {
          if (t[b] < t[a]) {
            int temp = t[b];
            t[b] = t[a];
            t[a] = temp;
          }
        }
      }
    }
  }
}
void run_case(void) {
  int n, k;
  cin >> n >> k;
  int p[n];
  int t[n];
  for (int i = 0; i < n; i++) cin >> p[i] >> t[i];
  sort_p(p, t, n);
  sort_t(p, t, n);
  int count = 0;
  k--;
  for (int i = 0; i < n; i++) {
    if (p[i] < p[k]) break;
    if (p[i] == p[k] && t[i] == t[k]) count++;
  }
  cout << count << endl;
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  run_case();
  return 0;
}
