#include <bits/stdc++.h>
using namespace std;
const int MX = 100;
pair<int, int> p[MX];
int n, k, cnt;
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> p[i].first >> p[i].second;
    p[i].second *= -1;
  }
  sort(p, p + n);
  reverse(p, p + n);
  k--;
  for (int i = 0; i < n; i++) {
    if (p[i] == p[k]) cnt++;
  }
  cout << cnt << endl;
  return 0;
}
