#include <bits/stdc++.h>
using namespace std;
bool comp(pair<int, int> a, pair<int, int> b) {
  if (a.first != b.first)
    return (a.first < b.first);
  else
    return (a.second > b.second);
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<pair<int, int> > v;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    v.push_back(make_pair(x, y));
  }
  sort(v.begin(), v.end(), comp);
  reverse(v.begin(), v.end());
  map<pair<int, int>, int> hash;
  for (int i = 0; i < n; i++) {
    if (hash.find(v[i]) == hash.end())
      hash[v[i]] = 1;
    else
      hash[v[i]]++;
  }
  cout << hash[v[k - 1]];
  return 0;
}
