#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 1;
pair<int, int> ar[N];
bool comp(pair<int, int> &a, pair<int, int> &b) {
  if (a.first == b.first) return a.second < b.second;
  return a.first > b.first;
}
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> ar[i].first >> ar[i].second;
  sort(ar + 1, ar + n + 1, comp);
  pair<int, int> x = ar[k];
  cout << count(ar + 1, ar + 1 + n, x);
  return 0;
}
