#include <bits/stdc++.h>
using namespace std;
int n, k;
pair<int, int> pt[55];
bool cmp(pair<int, int> fir, pair<int, int> sec) {
  if (fir.first == sec.first) {
    return fir.second < sec.second;
  }
  return fir.first > sec.first;
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> pt[i].first >> pt[i].second;
  }
  sort(pt, pt + n, cmp);
  pair<int, int> res = pt[k - 1];
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (res.first == pt[i].first && res.second == pt[i].second) {
      ans++;
    }
  }
  cout << ans;
  return 0;
}
