#include <bits/stdc++.h>
using namespace std;
const int N = 55;
pair<int, int> pt[N];
bool comp(pair<int, int> a, pair<int, int> b) {
  if (a.first != b.first) return (a.first > b.first);
  return a.second < b.second;
}
int main() {
  int n, k;
  int ans;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> pt[i].first >> pt[i].second;
  for (int i = 0; i < n; i++) pt[i].first *= -1;
  sort(pt, pt + n);
  auto r = equal_range(pt, pt + n, pt[k - 1]);
  ans = r.second - r.first;
  cout << ans << "\n";
  return 0;
}
