#include <bits/stdc++.h>
using namespace std;
void swap(int& p, int& q) {
  int t = p;
  p = q;
  q = t;
}
int main() {
  int n, k;
  cin >> n >> k;
  int p[n], t[n];
  for (int i = 0; i < n; i++) cin >> p[i] >> t[i];
  for (int i = 0; i < n - 1; i++) {
    int best = i;
    for (int j = i; j < n; j++)
      if (p[j] > p[best] || (p[j] == p[best] && t[j] < t[best])) best = j;
    swap(p[best], p[i]);
    swap(t[best], t[i]);
  }
  int r[n];
  for (int i = 0; i < n; i++) r[i] = i + 1;
  int d = 0;
  for (int i = 1; i < n; i++) {
    if (p[i] == p[i - 1] && t[i] == t[i - 1])
      d++;
    else
      d = 0;
    r[i] -= d;
  }
  int cnt = 0;
  for (int i = 0; i < n; i++)
    if (r[i] == r[k - 1]) cnt++;
  cout << cnt << endl;
  return 0;
}
